Cabbage Logo
Back to Cabbage Site

One cycle oscillators

Is there an oscillator that will only generate one cycle when triggered by midi keyboard rather then continuously

Or is there a way to do this with regular oscillator

oscil1 should do the trick.

The limitation of oscil1 is that it only runs at k-rate. If you need an audio rate output you do this:

giSine ftgen 0,0,4096,10,1

instr 1
iCPS  =       440
aPhs  linseg  0, 1/iCPS, 1
aSig  tablei  aPhs, giSine, 1
      outs    aSig, aSig
endin

How could I implement this in an envelope for a filter cutoff
aSig moogladder aSig1, kcutoff+aPhs, kres
Doesn’t seem to work :thinking:
Would
kcutoff chnget “cutoff” + aPhs
Be closer

The above code is me trying to modulate the filter cutoff from where the cutoff is set so a modulating envelope rather than continuous modulation

In the example I gave, it was the variable aSig that represented what I think you want to be the envelope value. Here is another snippet that reads an envelope shape from a function table but is also scaled by a user-control on channel "CF". However, in this context, there’s really no reason why you shouldn’t use any of the envelope generating opcodes linseg, linsegr, expseg, expsegr, transeg, transegr, cosseg, cossegr.
Note that the envelope is normalised (0 to 1) whereas the other variable in the multiplication (kCF) represents the maximum frequency of the filter cutoff, so should be a control in the range of something like 50 - 15000 (and with a ‘skew’ of 0.5). You always need to be sure that your filter cutoff can’t exceed sr/2.

instr 1
; envelope shape
iEnv  ftgen 0, 0, 4097, 16, 0, 128, 4, 1, 4096-128, -6, 0
aPhs  linseg  0, 5, 1       ; phase pointer
aEnv  tablei  aPhs, iEnv, 1 ; read the envelope shape
kCF   chnget  "CF"          ; represents the maximum filter frequency (Hz.)
aSig  vco2    0.5, 220
aSig  butlp   aSig, aEnv * kCF
      outs    aSig, aSig
endin