Why does this work?!?
Steve Scrambled wrote:
Okay, I give up.
Yesterday I constructed the attached patch in order to be able to trigger a sequence with a keypress and stop the sequence with a second keypress, and it works fine. But as far as I can tell it shouldn't. I've drawn diagrams and made out truth tables and as far as I can tell the Logicinv1 should only output a low logic signal and not flip between high and low. The patch is a JK flip-flop or a pair of NOR gates with each having the output of the other as one of its inputs, with a NOT gate (logic inverter) before the input of one of the NOR gates. A S&H is used to route the output of the NOR gate without an inverted input back into the input of the system when a key is pressed.
Now, the Logicinv2 module should flip between low and high, which it does, so it can be used to alternatively trigger/silence a sequence. But the Logicinv1 should not flip and it does. In fact if you use both Logicinv outputs to trigger different sequences the patch will alternately trigger one and then the other at each keypress which is useful. BUT IT SHOULDN'T WORK.
Am I missing something here? If someone could explain to me VERY SLOWLY why this works I would be grateful. I suppose I should just be satisfied that it does work but I really like to know what is happening and why.
Chet Singer wrote:
Beats me. I didn't figure it out, but maybe the NM isn't executing the modules in the order you think. That kind of variability can make feedback-based logic functions like this unpredictable.
But there's an easier way to do it. Patch the output of a sample/hold to a logic inverter, and patch the output of the logic inverter to the sample/hold's input. Trigger the sample/hold with the keyboard gate. Instant divide-by-two flip-flop. Whether it's initially on or initially off depends on whether you take the output from the inverter's input or output.
Rob Hordijk wrote:
The way the RS-flipflop works together with the S&H, which can be considered to be a D-flipflip without reset input, and the inverter makes the RS-flipflop simply work as an inverter and can be skipped completely as Chet says. The S&H and an inverter make a perfect toggle flipflop. When tapping the output from the S&H output it even works perfectly as an octave divider in the audio range.
The simplest solution for your problem is to use a clockdivider module set to divide-by-two. On patchload the output is low, so only until the first keypress its output will become high.
Added an example of using a S&H and an inverter module for audio range octave division.
James Clark wrote:
Not quite perfectly, as the sample input does not take audio rate signals, so you will get some aliasing.
You could use the cross-fade module to do sub-octave division, by using an overdriven oscillator (or just a square wave osc) as the control input to the cross-fader. I am attaching a mod to Rob's popping patch which illustrates this. I'm at work, away from my Nord, so I don't know if it sounds better or not.
Maybe we should ask Clavia for an audio-rate sample-hold? Shouldn't be too hard to make. There may be some trickiness in keeping latencies down.
Steve Scrambled wrote:
That's me though: never 2 modules where 7 will do! LOL. It's still got me stumped though. Hmmmm, perhaps the answer is as you say- maybe its its due to processing delays in the logic modules.
Rob and Chet's S&H/inverter combination is a far more elegant solution to my problem than my own effort. On the octave divider I would expect the aliasing to be minimal since the control and logic signals run at 24kHz, and the fundamental and major harmonics of the sub-octave should lie below 12kHz and hence escape aliasing. No?
Scott Juskiw wrote:
Excellent idea. I'd like the option of using the high sample rate for _any_ module. Clavia have unfortunately assumed that we would only use "audio" modules in the audio path. There are far too many instances of great patches that use logic modules or other low sample rate modules in the audio path and therefore end up sounding very lo-fi with lots of aliasing when they needn't sound that way.
James Clark wrote:
The fundamental will escape aliasing along with some of the harmonics, but not the rest. You will hear the difference. A little bit of aliasing goes a long way! You could (should!) lowpass filter the audio-rate signal before feeding it into a logic or control input, but the filter must have a steep cutoff (48 dB at least). This will reduce the aliasing noise, but will add delay, which could cause some peculiar behaviour in your circuit (since there is feedback present).
But no matter what you do, it will make a sound (perhaps imperceptible) and somebody somewhere will thinks its cool!
Rob Hordijk wrote:
In fact, the red output from the S&H doesn't sound very aliased, to my ears more or less the same as a squarewave from a normal oscillator up to around 1kHz, although the yellow output from the inverted module does sound pretty aliased. When the frequency gets higher the distortion sounds more like jitter than aliasing (logical, as levels are always min or max, but the rising and falling flanks jitter in time a bit). A slave squarewave oscillator does sound better over 1 kHz, which might be caused by the fact that the squarewave module has an inbuilt anti-aliasing filter.
There is some controverse between the red input and output and the yellow clock signal. If the yellow clock works at 24 kHz then the in- and output normally would be blue, so why red suggesting a 96kHz sample rate? So I suspect the module working at 96kHz but the yellow colour referring to a yellow signal level, which would also be more in accordance with the DSP consumption of the module. S&H must be about the simplest operation one can have a DSP to do. Still sampling audio at an audiorate does sound pretty aliased in cases, probably its amplified by odd frequency beating.
In the test patch the difference between the S&H divider and a clock divider or square LFO at audio frequency can be distinctly heard.
My conclusion is that the S&H/Inverter suboctave divider is very useable.
But how do I get your solution to actually divide the frequency? Without some latching action somewhere? It doesn't do much dividing over here.
I think in your line of thought you supposed a non-linear function would do the job of dividing as it can do the job of frequency multiplying, like the wavewrapper can do. But as far as I remember a non-linear function that works only on the level and not on the phase position cannot divide frequencies. But the combination of a wavewrapper in front of the overdrive, which drives your very fast switch does produce very nice bell-like overtones.
Steve Harris wrote:
Squarewave audio oscilators are normally bandlimited, rather than true squares.