Sunday, 29 April 2018

Four-Step Sequencer in Gen for the OWL Pedal

Normally this blog talks about an investigation that I have done, or describes the design and features of some software that I have produced. This posting is slightly different from this because I've finally got around to delving into Gen the 'next level deeper' bit of MaxForLive or Max, and I'm going to show you how I used Gen to create a simple four-step sequencer patch. Instead of just telling you about what I have made, this time I'm going to show you how I programmed it as well - so 'next level deeper' two ways! This is just an experiment, so what happens next depends on the feedback that I get, or don't get.

Okay, so I have known about Gen for a long time (since it was called gen~, in fact), and I have always kind of overlooked it. I'm sure I'm not the only person who glances at it and thinks that learning to program in it is going to require time to learn it, and given the plethora of programming languages that I already know, acquiring yet another one is revisiting that 'start at the bottom yet again and claw your way up to the point when you can actually program things that almost do some of what you intended' learning curve that I have climbed many times before.

Just as in writing a novel, learning Gen requires something that breaks the hero/heroine of the story out of their normal humdrum ordered world, and forces them to go out and have an interesting adventure instead. In my case, the trigger was a casual conversation with a name producer, who said that what they really wanted was something that would let them do [possible subject of a future blog posting]. I made the mistake of saying that you could easily do that as a MaxForLive plug-in, and they pointed out that in this particular application, they had to be DAW-less, and so the trap was set. I then said that there were ways of doing this without needing a laptop or computer, and they said: 'You're on!' The trap was sprung and I was caught. I was committed to going on an adventure...

At the back of my mind, driving my confident assertion: 'there are ways', were the various hardware platforms that let you program them, not in Max, but in Gen. Things like the MOD Duo, or the Rebel Technology OWL Pedal. After comparing the specifications and the prices, I went for the OWL Pedal as my first test development platform, leaving the MOD Duo as a potential future addition to my portfolio.


Rebel Technology OWL Pedal

Rebel Technology describe themselves as a London based tech collective creating radically innovative music electronics since 2009', so they immediately sounded interesting - and they were at the 2017 SynthFest UK in Sheffield too! Alongside a variety of Eurorack modular stuff, they also do a completely programmable microcontroller-based development platform called OWL, that is available as a pedal or as a rack module (and more variations coming up soon). I went for the OWL pedal, and after the usual 'wait for the postman' delay, I soon had one. Having a piece of hardware kind of ups the commitment level, so I read all the documentation, watched their YouTube videos, and generally immersed myself in Gen. [Montage of time passing whilst being immersed in Gen...] 

What I discovered was interesting, and there was an annoying little 'told you so!' voice at the back of my mind that kept reminding me what Cycling '74 have always said about Gen: that it isn't as scary as people think, and that it enables you to do amazing things, but that the one enabling thing you need to learn is a different way of looking at programming. In the case of Gen, that 'different way' is having to think about doing everything at the sampling rate, and that's quite a fundamental change in the way you conceptualise things. It's a bit like learning to hand-craft web-pages using only HTML, and then discovering that you've done it all wrong because you should have been using CSS for the layout, and HTML for the content.

My learning style hasn't changed much over the years. From the Intel 8080 onwards, my first program has always been a 'Hello World!' type of simple test, and then I have iteratively added bells and whistles (sometimes literally) until I eventually get to that 'do some of what you wanted' point. This method works for the small projects that I tend to work on, but there are lots of other ways of learning and programming that may suit you better. Whatever works for you.

So as my first patch, I wrote a patch for the OWL pedal (and it should work on the modular rack module too) that used an Expression pedal connected to the OWL Pedal to control the volume of an audio signal passing through the OWL pedal. Yep, 'Hello World!' for audio on the OWL pedal. Here's the basic patch, written in Gen:


Now it isn't immediately apparent when you first look at the patch, but there's something really interesting happening here: all of this is audio signals sampled at 48 kHz. So there are two audio inputs (in 1 and in 2 for the left and right input channels of the pedal), and these are connected to two multiply boxes (which contain just '*') and the output of the multiply boxes are connected to the two audio outputs (out 1 and out 2 for the left and right output channels of the pedal). So for every sample (48 thousand times per second), the in 1 audio input sample value is multiplied by the multiply box and the output goes to the out 1 audio output. If you multiply something by zero then you get nothing out, and if you multiply something by one then you just get the original value out. The source of this 'multiply' value is the Expression pedal (Exp). So this means that 48 thousand times a second, the position of the Expression pedal is sampled, and that sample value (between 0 and 1) is used to multiply the audio sample value from in 1 and in 2, an the outputs get sent to out 1 and out 2. That's 96 thousand multiplies happening per second inside the Owl pedal so that the volume of the inputs can be changed by the Expression pedal. Also, it means that if the Expression pedal potentiometer is even slightly imperfect, then we aren't going to get a smooth volume change, because the Expression pedal is sampled for each and every sample! Any noise or bad connection in the potentiometer is going to give the wrong value for the multiply value, and the output will jump up and down in volume. This patch design has lots of scope for improvement!

I followed this with a second patch that used the Expression pedal to pan the audio signal from left to right, and which used one of the OWL pedal's four control knobs to set the 'pan' law so that you had some control over how abruptly or smoothly the panning happened. Here's the basic patch:


This patch sorts out some of the problems in the first patch by adding a few extra boxes - compare the two patches first so that you can see what the changes are... The Expression pedal is now passed through a 'slide' box. This smooths the value so that any sudden jumps don't appear at the output. The final outputs from the multiply boxes are now limited to +1/-1, so if the multiply value somehow gets bigger than 1, then we aren't going to get excessively loud outputs - just distortion limited to +1/-1. The previous patch treated the two channels the same, but here we want to pan from one channel to the other, and so the smoothed Expression pedal sample is inverted for the in 1/out 1 (left) channel using the box with '!- 1.' in it. What this box does is subtract the Expression pedal value from 1, so a value of 0 outputs a 1, and a value of 1 outputs a 0. (This is just a weirdness of the way that Max does this type of function - just think of it as 'inverting' the value) So as the Expression pedal goes from 0 to 1, then the two channels will get opposite multiply values.

Unfortunately, pan isn't quite as straightforward as this in practice. So here's a revised version that sounds much better - and notice the extra multiply boxes, two new boxes and a new control...


What those boxes do is change the 'pan' law - the amount of overlap as the audio is panned across the stereo image. What happens is that the smoothed D' control knob on the OWL pedal is used to control if the law is linear or uses a quarter sine wave 'non-linear' law. (this is what the 'expo' box is doing). This isn't a perfect way of doing this, and there are much better ways of doing it, but it is simple and works quite well for my ears.

(Don't worry about going back and re-reading this explanation as you trace through the patch diagram  - there's a lot happening here, and as I have said too many times already, it all happens 48 thousand times per second!)

Having said that Gen is a 'deeper level' than Max, then it is probably time to show how Gen fits into the Max programming environment. Here's the Max patch that the Gen code is 'inside':


As you can see, the Gen code looks just like any other Max object, and the programming environment is familiar. It's just that things work a little bit different inside the 'gen' object... At the level of the Max patch, then we set up the inputs and outputs, and you can see that I have left a couple of number boxes and 'scope' objects in the patch, ready for using to view what is happening inside the Gen object -
which is the little box on the mid left hand side that I have put a purple rectangle around.


Gen doesn't provide the same depth of assistance as Max does, and so you need to do a bit more work to monitor what is happening inside a Gen object by using extra in or out objects. I think of it as a bit like trying to do things through the letterbox in a front door... I will try to show how this works as we go along, because it is one of the key skills to have when developing Gen, and it is easy to overlook when concentrating on the Gen code itself...

(It is also important to point out here that the OWL Pedal is only going to do the stuff inside that 'gen~' box. Some of the standard Max functionality isn't implemented in Gen for a variety of reasons, and so you need to approach things slightly differently - so it isn't just a case of putting standard Max objects inside that gen~ box, and you can't add Max objects outside of the gen~ box and expect them to work. 'Inside the gen~ box' is the key to this.)

My next patch took one of my old MaxForLive patches, and turned it into Gen. I had to do quite a bit of user interface simplification in order to cope with only having four control knobs, an Expression pedal and a pushbutton, but the result was quite encouraging: a stereo delay box with an unconventional way of doing things, and some quite unusual sounds. Rather than bore you here with yet another 'unique' delay patch (for some reason, the world is full of delay patches whose creators think are amazingly different),  then it felt like time for some more novel writing 'advance the plot' activity. If you are interested, then you can find the patch in the online library for the OWL devices - I'm called 'registration' because that's the email account name that I used. I'm also going to upload it to my Github repository at some stage...

Anyway, having told you about all of this preparatory work, it was now time for the next step nearer to what I had been so confident I could make for that producer. I took an idea and turned it into a patch, without basing it on a tutorial. This patch is the real topic of this blog post!

Four Step Sequencer

The OWL pedal has four control knobs, so it makes a four-step sequencer an obvious choice, and I wanted to make something self-contained: a step sequencer plus a simple sound generator. Using the pushbutton as a tap tempo source leaves just the Expression pedal as a possible timbal control. So if you have only one control, what gives the widest range of sounds?

After a bit of experimentation... Okay, after a lot of messing about... I dragged myself away from my modulars and decided on a slightly unconventional approach influence by Reaktor-style sound generators (Look up 'Flintpope' for some amazing examples!). I would use that single remaining control to set the rate of an LFO that sweeps a resonant low-pass filter past a pair of detuned oscillators, which is quite a lot of indirection... This means that this patch is more self-contained, and a bit more like a factory demo than a generically useful patch (and I've done various bits of paid 'impressive demo'-oriented work over the years), but as a learning patch, as something for people to tweak, to derive other patches from, then I think there is huge value in demo patches, especially when they aren't buried in reverb.

So how do you do timing in a the world of Gen? If everything is happening 48 thousand times per second, how do you work at a slower rate? The solution I chose is to just use a counter so that we slow down those thousands of times per second into something that works at a more human-oriented rate. You can do this in gen~ by using the 'phasor' object, which is a counter that counts from 0 to 1 at a rate set by a clock rate derived from the processors chip's master clock. There are lots of other ways to do timing in Gen - using the 'phasor' object is just how I did it in this case. Let's start by looking at the whole finished patch:


Okay, so there's lots more happening in this patch! So let's break it down into sections and look at each of those in isolation.


Top right deals with the timing, and that's where we will start. Across on the top left is the sequencer, and the lower half is the audio section.

Let's start with the timing. There are two linked timings that we need: one to produce the 4 steps that we will use for the sequencer timing, and another one to produce the envelope timing for the notes played by the sequencer. The sequencer timing is the easier of these to understand, so let's start with that.

Step sequencer



The box at the top right is the illuminated push-button in the centre of the OWL pedal - not to be confused with the big chunky foot-switch that can be used to bypass the pedal, in standard guitar-pedal style. The little pushbutton outputs zeroes normally, and ones whenever it is pressed. This appears at point (A) in the Gen code, and on the timing diagram below.


The output of the push-button goes into a pre-prepared 'encapsulated' gen~ object (from a Rebel Technology tutorial example) that measures how many 48 kHz clocks happen between presses of the push-button ('taps' in tap-tempo-speak) - a 'tap-tempo' box. The 48 kHz clock is the master timing source in the microprocessor used inside the OWL pedal, so this is how fast we sample those push button presses, and the measurement of the number of clocks that this gives us is thus the 'time' between buttons presses - in other words: beats.

We will be using the Max/Gen 'phasor' object to do our timing. The 'phasor' object produces a sawtooth waveform at a rate set by a 'frequency' input. Essentially, it is just a counter that starts at zero and counts upwards. But the 'phasor' Gen object that we are going to use to produce all our timing requires a frequency input, and all we have from the tap tempo is a time - so how do we convert time to frequency?

By dividing the 'time between push button presses (beats)' by the 48 kHz sample rate (Gen's variable for this is called 'samplerate'!), then you get the frequency of pressing the push-button. Assuming four beats per bar when the push-button was tapped, then this frequency is four times too fast, so we need to have a division by 4 - this will give the correct frequency for a complete bar from the phasor object.

Here's a quick aside about tempo and frequency.

Unfortunately, tempo isn't expressed in frequency - it is normally in beats per minute, and our frequency is going to be in Hertz. Let's go through this with some real-world numbers. Suppose the time between taps is 1 second, This means we are tapping at 60 beats per minute, because that's once every second for 60 seconds to fill the minute. 60 taps per second is 1 Hz, or one cycle per second. If we tapped twice as quickly, then the time between taps would be half a second, and in the 60 seconds in a minute, we would have tapped 120 times. 120 taps per second is 2 Hz.

The last thing we need to think about to produce the frequency for the phasor object is the length of a bar. So far we have figured out that 120 bpm is 2Hz, but if we have 4 beats per bar, then the bars per minute is going to be a quarter of 120, which is 30 bars per minute. We want the phasor object to produce one sawtooth per bar, so that's why we want to set the phasor object to run at a quarter of the beat frequency that we have measured using the tap tempo.

If you plot the time from the output of the tap tempo against the frequency that we need to drive the phasor for one sawtooth per bar, then it looks like this:

tap tempo time per beatphasor frequency
2.00.125
1.00.25
0.50.5
0.251.0
0.1252.0



And this shows us how time and frequency are related: it is called an 'inverse' relationship. As the time between taps gets longer, the frequency goes down, whereas as the time between taps gets shorter, the frequency goes up.

And back to the sequencer...

The conversion of the beat frequency to what the phasor needs is done by the box that contains '!/ 0.25'. 0.25 is 1/4, which takes care of the 4 beats per bar.



The 'phasor' object in Gen works much the same as in Max - it outputs a rising count at a rate that depends on the input. In this case, the rate is set by the tempo, and so we get a sawtooth (rising count) that resets every bar, starting at 0, and rising up to 1 (I'm going to totally ignore the internal representation of numbers inside the OWL pedal - because you don't need to know about 'floating point representations' and 'this number of bits' to program in Gen.). Multiplying this sawtooth by 8 gives us a minimum of 0, and a maximum of 8 (it just makes the 'height' of the sawtooth bigger), and this is used for timing elsewhere in this patch. For a four step sequencer then we need it to go from 0 to 4, and this time I'm gong to do it sensibly - by multiplying by a half!

(Notice that when I multiply the 'time between taps' measurement, then this affects the tempo, but multiplying the sawtooth waveform that the phasor object produces just changes its size (or amplitude in tech-speak).)

The sawtooth that goes from 0 to 4 once every bar is at point (J) in the Gen code and in the timing diagram. The final object of the 'ceil' box, and this just converts the sawtooth into the integer equivalent. It does this rather generously, and so it outputs 1 whilst the sawtooth goes up from 0 to 1, then 2 whilst the sawtooth goes up from 1 to 2, and so on. 'Ceil' is shorthand for 'ceiling', which explains why it takes the high value! Notice that it never outputs 0, so all the time that the sawtooth is less than 1, the 'ceil' object is outputting 1.


So at point (K), the output of the 'ceil' box only has four direct values: 1,2,3 and 4. We will use these to make the step sequencer choose values from the four rotary controls. The 'selector' object box is like a four-way switch: only one input is connected to the output at one time, and the control input (on the left hand side) controls which switch is closed. So when we connect the four rotary controls to the inputs of the 'selector' object and connect the 1,2,3,4 stepped sawtooth waveform into the control input, then the selector switch will scan across the four rotary controls at a rate set by the tap tempo.



I have to apologise at this point. In their most basic form, sequencers really are exactly this simple. They repeatedly scan across a number of controls, getting the value from each control, and outputting it. Look at the Gen code and follow the text above again if you aren't sure that the code is just a direct translation of what a sequencer does.

Debugging

I mentioned earlier that I would show how debugging works in Gen, and you probably wondered how I know what the waveforms at points A, J and K actually look like... To do this, you just add extra outputs ('out' objects) in the Gen code, and then connect these outputs to scope or number objects in the Max environment, so that you can look at the waveforms.

So here's a close up of the J and K points:


So the point that I have labelled as 'J' previously is now connected to an added 'out' object: 'out3' in this case, and the 'K' point is connected to 'out4'. In the Max environment, then we just use scope~ objects to see what the waveforms look like:


The 'out3' output shows the sawtooth waveform output of the phasor object, and so is connected to a 'scope~' object so we can see what it looks like. (I then turned this into the diagrams used earlier).

The 'out4' output is also connected to a number box, so that I can double-check that the 'ceil' object only outputs 1,2,3 and 4. I didn't show that bit of the Gen code, but there's also an 'out5' being used here, but the scope~ object for that is cropped off the bottom of the screenshot.

So that's how you see what is happening inside the Gen code, and this is one way to debug as you develop your design. When you don't need the debugging any longer, then you just delete all the added 'out' objects in the Gen code.

Main timing (envelope)




The timing for the envelopes uses the same phasor object, but this time I wanted to have envelopes lasting half of the step lengths: so 1/8th notes. This is why the phasor is multiplied so that it goes from 0 to 8. You can see this at point C.

If we use the 'wrap' object, then that 0 to 8 sawtooth gets 'wrapped' into the space between 0 and 1, and we get the waveform at point D. This is a sawtooth running at 8 times the bar length, and twice the step sequencer rate: in other words - 1/8th notes. Unfortunately, the 'phasor' object outputs a rising sawtooth, and percussive sounds require a falling sawtooth, so we invert it by multiplying by -1 (the  '*-1' object ) to give point E, and then we add 1 to it ( '+ 1' ) to get point F. This is a falling 'ramp' at twice the step sequencer rate, so we need to do some more processing to get four ramps to match the step sequencer.

This is achieved by using the 'ceil' object again, and this turns the unwrapped 0-8 sawtooth into a series of numbers: 1, 2, 3, 4, 5, 6, 7, and 8, and then using the '==1' object to produce a 'gating' signal. The '==1' object is normally 0, and goes high when the input is equal to 1 - hence the '==1'. So by putting four '==' objects in parallel, we can produce gates that go to 1 for the 1st, 3rd, 5th and 7th falling ramps. Using these gates on the falling sawtooth will give us just four 1/8th note falling ramps which are perfect for using as percussive envelopes, and which are locked in sync with the step sequencer - you can see this is you compare all of the points:



So if you look at K, the the four percussive envelopes in H match exactly to the four steps in K.

Note that if you change the '==' numbers, then you can choose different timings for these notes.  I will leave it to you to work out the limitations of this approach...

Here's a screenshot from actual debugging during development, showing points B, C, G and H, all output using 'out' objects into four scope~ objects in Max.


LFO and Frequency control


The Expression control (an eternal control pedal plugged into the OWL pedal) is used to control the rate of an LFO that modulates the cut-off frequency of the 'VCF' in the audio section. This time, instead of the phasor object, the 'cycle~' object is a better choice, because it outputs a sine wave, and the smooth waveform is perfect for slow filter modulation. The Expression pedal output (from 0 to 1) is adjusted to a suitable range of rates for the LFO, and the output of the LFO (-1 to +1) is scaled and has an offset added so that it output a sine wave that goes from 0 to 1.

Audio section


The audio section takes the four pitches from the step sequencer and uses them to drive two slightly detuned sawtooth oscillators made using 'phasor' objects. These are then mixed together and fed into two low-pass resonant filters in series. The percussive envelopes from point H are fed into the same 'slide' object that has been used to 'smooth' all of the rotary control knobs and the Expression pedal input, but this time it is used to lengthen the release time by lengthening the ramp. If you change the 'i 1' object to a higher value number (e.g. i 50), then the attack time will lengthen and you won't have as percussive a sound. The LFO sine wave and the percussive envelope are scaled (LFO sweeps a 5000Hz range, whilst the envelope only sweeps through 1000Hz) and are used to control the cut-off frequency of the filters. The '1 0.8' box sets th resonance of the filter at 80% - mainly because resonant filter sweeps are a classic sound, but you can change the value if you want - although going to close to '1' will cause the filters to self-oscillate, which isn't good in this type of application (unless you want a siren effect!).

The percussive envelope is also used to drive a VCA that envelopes the output of the series of filters. A DC-blocking filter prevents any problems with very low frequencies, and the final output goes to the two main stereo outputs of the OWL pedal: called 'Out1' and 'out2'.

Conclusion

Let's go back to the beginning of this blog, and review the progress. We started by implementing a simple guitar expression/volume pedal, and we ended with a 4-step sequencer driving two detuned sawtooth 'VCOs', into a resonant 'VCF' with an AD envelope and a sine wave LFO driving the cutoff frequency, followed by a 'VCA' driven by an AD envelope. All in a tiny pedal box, and there isn't very much code - there are just 57 of those little Gen object boxes at the op level, and the 'Tap Tempo' adds a few more.

For me, the hardest bit was figuring out how to compile the finished code and get it into the OWL pedal, which involves going to the Rebel Technology site and using a web interface. Once you've got the hang of it, that isn't difficult either - and Rebel Technology have lots of video tutorials on YouTube so you can see what to do.

So what was the best bit? Actually, figuring out how to do all of the timing by using phasor-based sawtooth waveforms was my favourite activity. Putting those extra 'out n' objects into the Gen patch and then looking at the waveforms in the outer Max patch was just like probing a circuit with an oscilloscope. Most amazing of all - working at 48 kHz wasn't anywhere near as scary as I expected!

I hope that you have been inspired to consider looking at programming an OWL. There is a lot of information on the Rebel Technology web-site, and the forum is full of people who can help. Have fun!

Links

Things mentioned in this blog posting:

Cycling '74 Gen

Mod Devices MOD Duo

Rebel Technology OWL Pedal

Rebel Technology OWL Modular

SynthFest UK

Native Instruments Reaktor

Flintpope

Compelling problems - making things happen in novels

Hello World!

And finally!

If you have got this far down the page, then you  might be interested in the previous blog posting on the OWL pedal - How to add a footswitch input!



Buy me a coffeeBuy me a coffee




Thursday, 26 April 2018

Adding a footswitch input to the OWL Pedal

The OWL pedal from Rebel Technology is a guitar stomp box with a difference - you can program the micro controller inside it to run any of over 200 'patches', ranging from the delays and flanging that you would expect, to unusual devices like sound generators and step sequencers, and more...

The OWL pedal has stereo input and output jacks, as well as another quarter inch jack for an expression pedal, and this can be used to control many of the patches. There is also a small push-button on the top of the pedal that can be used to change patches, or as an extra input for things like tap tempo (particularly useful for sequencer patches, or for setting delay time). So far, pretty near a perfect solution for anyone who wants a programmable pedal.



But there was a minor niggle for me - that illuminated push-button on the top, right in the middle of the 'eyes' of the OWL - normally bright green, as shown in the photo above. Now it works very well, and is really useful for functions like tap tempo. In fact, it is so useful that I wanted to use it a lot and program it into my own patches (written in Gen, but that's another story). But it isn't really suited to live stage use because it is a small button on top of the pedal, and that would mean stooping down low and fiddling about down on the floor...

Actually, I can't complain, because the OWL pedal is published as Open Source Hardware under the GNU GPL, and the General Public Licence means that you are guaranteed to be able to share and modify the design, as long as you publish your modifications under the same licence. It's kind of the opposite of copyright, and so often gets called 'copyleft'. So if you go to the Rebel Technology web-site and so some searching, you will find the circuit diagrams, a bill of materials, PCB layouts and more - just about everything you might need to know about the design. So instead of complaining about the lack of a footswitch input, I added one!

Here's what I did.

The circuit diagram shows that the footswitch just pulls one of the micro controller input pins low when you press it, so all I needed to do was convert a footswitch so that it would do the same. Now there are two different types of footswitch commonly available: one type is a 'Normally Closed' switch, and is found in Roland footswitches, for example; the other type is a 'Normally Open' switch, and this is typically found in (for example) Yamaha footswitches. Now I happened to have a spare Normally Closed (NC) footswitch, so I built my circuit for this type.

Just connecting my NC footswitch across the existing push-button wouldn't work, because that switch  is Normally Open (NO). So I needed a simple invert circuit, and you can make this using a single transistor. Looking inside the OWL pedal, there's a space that looks like it was made for adding an extra jack socket, and there is room for a tiny circuit board as well, so a single transistor circuit sounded ideal. Hence the circuit looks like this:


The footswitch is that lonely switch on the left hand side, and it is open at the moment. The convention is that switches are almost always shown in the 'open' position, so you have to imagine that this is normally closed, and when you press down on the footswitch, then the switch will open. The input circuit has a capacitor to ground to slug any sharp edges, followed by a protection diode that stops negative voltages killing the transistor or the micro controller. And finally there is the transistor, which just acts as a switch. When the base (the input on the left) is at the right voltage then the transistor turns on and current flows through the 10K Ohm resistor, which pulls the PE2 output down towards ground. When the base voltage is below that voltage then the transistor turns off, no current flows, and the 10K Ohm resistor pulls the PE2 voltage back up towards the 3.3 volt positive rail. So when the transistor input is high then PE2 is low, and when the input is low, then PE2 is high. This means that we have a simple inverter circuit where the transistor is just behaving like a switch. Best of all, it now matches the operation of the push-button in the Owl pedal, and so all we need to do is build the circuit, add it to the existing hardware, and we are done!

So here's the gap and a spare jack socket:



Let's open up the OWL pedal:



And let's look more closely at that gap by the two input jack sockets...


I reckon that I can fit another socket and a tiny circuit board in there... First, let's disassemble the OWL pedal...






We now need to drill a hole for the extra jack socket...


Then build the circuit on a piece of generic PCB mounted on the jack socket itself...


And then put it inside the pedal...


And connect the three output wires (shown on the right-hand side of the circuit diagram above) to the main digital board in the OWL (orange is 3.3 volts, black is ground, and purple is the PE2 connection):


Here's a diagram based on the Rebel Technology material:


And here's a view of the PCB with the pins marked again:


Finally, we put it all back together again:


...And there's now an extra socket, ready and waiting to be used for tap tempo and anything else that a patch programs it to do.

More information:

There's more background information, sketches, code and other material at my Github repository for this project. 

WARNING: 

As with any hardware project, you should only attempt this type of modification to an OWL pedal if you know what you are doing and are happy to carry out this sort of hardware hacking. I accept no responsibility for you messing up an OWL pedal. What you do with that pedal is up to you, and is your responsibility. 



Buy me a coffeeBuy me a coffee




Tuesday, 24 April 2018

Irregular timing in a MaxForLive LFO...

Previously I have described the design of ProbablyLFO, my 'alternative' LFO for Ableton Live, built using MaxForLive. Since the first release, I have gradually added extra timing sources, and until now, these have all used the MIDI input so that the LFO timing was driven by MIDI notes in the clip. "Genious" was how one user described the use of MIDI note events to drive an LFO...

But recent experiments with Max's 'random' and 'metro' objects have resulted in a new timing mode that extends the functionality of ProbablyLFO in another direction. I have added a timing source that uses the 'Free' mode asynchronous oscillator but uses that to drive a noise generator that clocks the LFO probability grid. The result is an LFO that doesn't output the waveform at a regular rate, but it kind of jerks along across the grid. By altering the 'Smooth' control you can calm it down or make it more jagged, which aren't the kind of words that you normally see used to describe an LFO...


As with all the other timing sources, there is an indicator 'light' that shows when that timing source is generating a clock. The rate of the 'Noise' timing is the same as the 'Free' mode, which wasn't easy to achieve - I had to make two 'metro' objects running at different rates in order to keep the rate the same, and I have to admit that I cheated and set the parameters experimentally, rather than doing the maths. Entropy and probability ain't my strong points. 

So what does this give you in terms of control? Well, conventional LFOs output a waveform where each cycle takes the same time, and the shape of that waveform tends to stay the same - so a sine wave always has the same shape, a sawtooth is always a sawtooth... By using random noise to time the movement across a grid that controls the waveform, ProbablyLFO lets you have waveforms that can vary per cycle, and that have an average rate rather than exactly the same time for every cycle. Depending on what the random noise does, some cycles might be short, while others might be longer, and the progress across the grid can vary within the cycle. 

Let's look at the output of an unsmoothed sawtooth from ProbablyLFO with 'Free' timing:


So the sawtooth is the same each cycle, and each cycle takes the same time.

And now, the output with the same unsmoothed sawtooth with 'Noise' timing (several examples):






As you can see, cycles vary in their length, and the ramp isn't a nice straight line any longer because the progress across the grid is driven by random timing. The only thing that is the same is the average rate - over a long period of time, the same number of cycles will hap[pen as in the first sawtooth example.

( Note that this is using a fixed waveform in the grid. ProbablyLFO's grid allows you to set the probability of different outputs, and this isn't being used here - this is just the 'Noise' timing. ) 

Musically, this gives you an LFO where the parameter you are controlling does not change repeatedly with exactly the same timing and waveform. Instead you get a much more variable timing and output - less metronomically predictable...

Downloading MIDI ProbablyLFO 0v06

You can download MIDI ProbablyLFO 0v06 from MaxForLive.com 

Here are the instructions for what to do with the .amxd file that you download from MaxForLive.com:

https://synthesizerwriter.blogspot.co.uk/2017/12/where-do-i-put-downloaded-amxd.html



Buy me a coffeeBuy me a coffee




Wednesday, 31 January 2018

Constraint-driven modification grids in asynchronous drum timing generator


The latest update to ProbablyGEN adds constraints to the grids, so that you can now control where beats can be placed (when editing manually) or where beats will be modified automatically using the 'every so many bars/seconds' auto modification system. The new grids are more intuitive and look sparser because of the 'missing' unavailable (locked) cells, and the previous preset 'Generative' pattern creation has been replaced by a completely flexible user controlled technique using the constraints. The previous 'Generative' functionality is now superseded and will be removed in a future version.

Constraints

The grids in previous versions were not constrained in any way, and so you could put white 'active' cells anywhere in the grid. If you leave the grids in 'Edit' mode, and never set any constraints, then this version will behave in exactly the same way as the previous versions.

But if you select 'Lock' mode, then the whole grid will change to show the 'constraints' and will be filled with white cells the first time that you go into 'Lock' mode.

 A white cell indicates an unconstrained cell. If you remove the white then the cell becomes 'constrained', (unavailable, locked...) and it will not be available (or visible) in the grid.

If you click or drag in the grid, then the cells will no longer show white, and the cells will no longer be available or visible. You will see the effect when you change the mode back to 'Edit' - all of the cells that were not left as white will have vanished, and you will not be able to put a white cell in them - and neither will the automatic modification options: Gen or Rnd.

The first thing to try is to remove all of the cells beyond the current length: 16 in the example shown on the right.

Here are constraints similar to the ones used in the 'Gen' generative functionality from previous versions. The lowest track (the 'Bass' drum track) just has four vertical bars on the beat, whilst the next track up (the 'Snare' drum track) has off-beat vertical bars, with extra time spreading for two of the off-beats. The top track (the 'Hi-hat' drum track) has busy 8th note vertical bars followed by a final block at the end of the bar.

Remember that these white cells are just setting the constraints - they are not related to the probability controls that are present in 'Edit' mode.

Constrained patterns

You can see the result of setting the constraints grid when you go back into 'Edit' mode - the previous all-white cells now go back to the usual dark colour, and you can now manually add white cells wherever you want in the cells that are visible. All of the other cells are now 'locked' and aren't visible.


 The way to think about the use of the white cells in the constraints is that when you go into Lock mode, you want to have white cells wherever you want to be able to put white cells when you are in Edit mode.
 The per-track 'Change' controls allow you to set the effect of the 'Rnd' auto modification function. If Change is set to 0, then the random changes to the grid will (over time) not change the number of white cells. This isn't exact, and so you may not always get exactly the same number of white cells  present in the grids.







If you set Change to a positive number, then the amount of change each time the automatic modification happens will reflect the setting, and so for the maximum value of +20, then up to 20 of the cells might be changed to (or from) white. The three previous screenshots show the effect of four values of Change on what is inside the grids. The bottom track changes the least each time, which is okay for a bass drum, whilst the top track has the most changes each time. If you set Change to +20, then there will be a lot of changes to the white cells (and the grid may fill up over time), whilst if you set Change to -20, then there will be a lot of changes every time, and the grid may well empty over time.

The automatic modifications functionality has also changed slightly - you can now select '1' bar as the time interval, which means that you can now have a new random pattern every bar, if you want. Previously, the shortest value was 2 bars.

Applications

The constraints system is well worth spending some time learning. It allows you to have very precise control over the way that beats are generated, and can also speed up entering frequently used patterns like the bass, snare and hi-hat examples shown above.

Constraints allow you to disable the lowest 'dark' row of the grids by removing the white cells in that row when in 'Lock' mode. This means that you can no longer have a way of setting a single drum event with 50% probability - you can put two white cells in the grid above the lowest 'dark' row and they will happen with 50% probability.


The 'Unlock' button...

The lowest button for each track is the 'Unlock' button. This serves exactly the same purpose as the 'Clear' button at the highest position in the track layout, except that it works on the constraints. If you press this button then all of the constraints will be removed for that track, and when you select the 'Lock' mode, then the constraints grid will have white cells everywhere. There is no way to undo pressing this button, so be careful!

There is no way to undo the 'Clear' button either - it clears all the white cells in an ordinary 'Edit' grid.


The probability grids

As a recap, here's how the probability grids work in ProbablyGEN. Watch out for the lower dark bar!

Highest velocity happens 100% of the time.




Highest velocity happens 50% of the time. Upper middle velocities happen 50% of the time.



The Upper and Lower middle velocities each happen 50% of the time.



The Upper middle, Lower middle, and Lowest velocities each happen 33% of the time.


The Highest velocity happens 50% of the time. The Lower middle velocity happens 50% of the time.


The Highest, Upper middle, Lower middle, and Lowest velocities each happen 25% of the time.


The Highest velocity happens 50% of the time. No note event at all is generated for 50% of the time.


The Upper middle and Lower middle velocities happen 66% of the time. No note event at all is generated for 34% of the time.


The Highest, Upper middle, Lower middle, and Lowest velocities each happen 20% of the time. No note event at all is generated for 20% of the time.




Downloading ProbablyGEN 0.05

You can download ProbablyGEN 0.05 for free from MaxForLive.com.

Here are the instructions for what to do with the .amxd file that you download from MaxForLive.com:

https://synthesizerwriter.blogspot.co.uk/2017/12/where-do-i-put-downloaded-amxd.html

Updates:


Original blog: version 0.02: Complex timing generator for Max For Live in Ableton Live

Update: version 0.04: Asynchronous timing generator for Max For Live in ...



Buy me a coffeeBuy me a coffee




Monday, 22 January 2018

AES@NAMM: Residuals Using Simple Separation

AES@NAMM 2018 Pro-Sound Symposium in Anaheim, California

My presentation: Thursday the 25th in Hilton Huntingdon A Level 4, 11am, 45 minutes, 

repeated Sunday the 28th in Hilton Huntingdon A Level 4, 11am, 45 minutes


Normally I just post personal research results in this blog (e.g. the MIDI Interfaces investigation), but when I’m presenting an academic paper at a real event, then this blog seems like a good place to gather all of the related information into one place...

For more years than I really want to think about, I have been looking into ways to use samples as the raw material for synthesis. Having spent my formative years during the rise of S&S (Sample and Synthesis (processing)), and with the E-mu Morpheus as one of my all-time favourite synths (or more correctly, sample replay devices with synthesiser-style post processing - and in the case of the Morpheus (and a few other favoured E-mu devices), that wonderful morphing Z-Plane filter!), then my aim has been to see just how far samples can be exploited in a synthesis context.

Research on 'Using samples for synthesis'...


The results of lots of thinking about how samples work, and how to make the most of them, particularly in a practical way. This is the topic of a paper that I’m presenting at the AES@NAMM 2018 Pro-Sound Symposium in Anaheim, California, on Thursday the 25th in Huntingdon A Level 4. I’m on at 11am for 45 minutes, and there’s a lot to try and pack into the time…

Supporting material (posted here as it becomes available…)


Demo video. First, here’s the 'teaser' ‘demonstration’ video that shows some of the results - using a single sample of an aluminium can (‘tin can’ is much shorter and easier to type, even though the metal is not tin!). This does not go into the theory or practice in much depth.

AES@NAMM. Here’s a link to the AES@NAMM web-site.

AES@NAMM Pro-Sound Symposium. This is a link to the event itself.

The AES@NAMM Schedule. Who is speaking when and where...

'Residuals Using Simple Separation'  The link to the presentation schedule - it’s an AES ‘Engineering Brief’. 


'Residuals Using Simple Separation' Powerpoint. Here’s a link to the slides from the presentation, where I talk about some of the background theory (there's more in the paper), and do some demonstrations. I’m going to post some more detailed audio demonstrations on SoundCloud and Youtube later too.

Now available... Here’s a link where you can download the Ableton Live Instrument Rack device that I used to do the demos in the video and the presentation. You will need to prepare two samples (or more) using the RUSS filters (below) and then drag^drop them into the two instances of Sampler inside the Rack. There’s lots of scope for a more intelligent front-end to doing this form of ‘synthesis using samples’. 

Now available... I have now partly tidied up the Nyqvist code for the sample processing routines that I used inside Audacity, the link is at the end of this paragraphl. They are released using a GPL licence. There are also a lot of possibilities to make the required sample processing smarter and more automated, and I hope to see some cool stuff released that makes the most of the creative possibilities. Filters etc are here...

I’m considering writing an M4L ‘assist ‘plug-in’, but I’m sure that a better coder than myself is going to beat me to it with something really cool and sophisticated.


I’m working on a ‘user manual’ for the techniques that are described in the paper and presentation, and I’m more than happy to talk to sample library creators about how they can use the concepts to enhance the flexibility and usability of their samples. 

Enjoy!




Buy me a coffeeBuy me a coffee




Saturday, 13 January 2018

Asynchronous timing generator for Max For Live in Ableton Live

Previously, I introduced ProbablyGEN, a Max For Live device that produces MIDI note events on three channels - with quite a lot of control over the timing of each channel. Essentially, instead of being tied to a single timing source, the three channels provide independent timing, and I provided default mappings to drum sounds because that seemed like a good way for people to start to explore the polyrhythms that are produced.


The feedback that I got suggested that quite a few people were using ProbablyGEN as a generative polyrhythmic drum machine pattern creator utility, and so I have now taken the comments and added extra functionality to make it easier to use ProbablyGEN in this way.

Additional asynchronicity


ProbablyGEN version 0.04 adds a fourth source of timing, but this time it works across the channels, and allows any channel grid to be filled randomly, or filled using a generative algorithm. As with the channel timing, this 'Rnd/Gen' functionality can be clocked using a free-running asynchronous clock (the 'Free' mode), or synchronised to the Bar count from Ableton Live's transport (the 'Sync' mode). Synchronising to Bars is slightly different to the 'Divide' control used in the channel timing - it quantises to discrete bars, and so a new grid pattern is only produced when the bar ends. In contrast, the Free mode is just a free-running clock, and so the new grid patterns can happen at any time - and the display shows the time between grid changes and shows a vertical 'count' indicator that shows when a new grid will be created (when the bar reaches the top).


 Looking at each part of the new Rnd/Gen control section in detail:



Common controls

The mode switch at the top of the common control section allows one of the two modes to be chosen:

Free - the Rnd/Gen clock is completely asynchronous (not tied to Live's transport at all). The 'Speed' control sets the time between a new grid being generated (shown in seconds). The bar on the left hand side shows the progress towards the next new grid - when it reaches the top then  new grid is generated (and the bar then drops down to the bottom).

Sync - the Rnd/Gen clock generates a new grid after the set number of bars, and so is tied to Live's transport. The 'Bars' control sets the number of bars between new grids being generated - in this case, the control is set to 9 bars. The number on the left hand side is the bar count, currently showing 3, so in 6 bars' time, the grid will be reset. 

The 'Fix/Auto' button controls if the automatic Rnd/Gen controls are active. When in 'Fix' mode, the grids are not affected. Selecting 'Auto' will activate the automatic Rnd/Gen effect on the grids (using the Per-channel selections described next...)


Per-channel controls

The 'Clear' button works as in previous versions - it clears the grid on that channel.

Each channel now has channel-specific 'Gen' and 'Rnd' buttons. These are always active - regardless of the 'Fix/Auto' button setting.

If you click on the 'Gen' control then a generative algorithm will produce a drum pattern for that channel. Each channel has a different algorithm: the top channel is designed for hi-hats, the middle for snares, and the bottom channel for kicks. Each time you click on the 'Gen' button, a new different pattern will be randomly generated.

If you click on the 'Rnd' button, then two things happen: first, some random cells in the grid will be cleared, and then, some random cells will be set to white. The 'Rnd' button thus modifies any pattern in the grid - it does not replace it (unless you press the 'Rnd' button a lot of times!). So you can use the 'Rnd' button to modify any grid - even a grid produced by the 'Gen' button.



'Auto' mode


When the 'Fix/Auto' button is set to 'Auto' then the timing controls can affect the grids. There are six selection boxes, three for each channel. When an 'X' is lit up, then the button on the right hand side of the sector will be activated when the timing clock generates a 'Rnd/Gen' event. 

In the case shown on the left, the top channel will have a new grid generated, the middle channel grid will be modified with random cells, and the bottom channel will generate a new kick drum pattern, and then randomly modify that pattern. ('Gen' always happens before 'Rnd'...)

If none of the selectors has an 'X' in it, then the grids will not be affected, and the state of the 'Fix/Auto' button does not matter.









Downloading ProbablyGEN 0.04

You can download ProbablyGEN 0.04 for free from MaxForLive.com.

Here are the instructions for what to do with the .amxd file that you download from MaxForLive.com:

https://synthesizerwriter.blogspot.co.uk/2017/12/where-do-i-put-downloaded-amxd.html

Updates:


Original blog: version 0.02: Complex timing generator for Max For Live in Ableton Live

Update: version 0.05: Constraint-driven modification grids in asynchronous drum timing generator




Buy me a coffeeBuy me a coffee