Voice stealing?

Hello all,

I have been playing around with the maxalloc and cpuprc opcodes to limit instrument allocations, but I would rather have a kind of voice stealing effect or even monophonic play. Is there an easy way to do it, like a particular opcode, or could we use some if ... then turnoff or a counter for that?

Thanks for reading

Seba

One way...

Heh! Interesting question... So of course you started me playing around.

I worked out one solution like this:

gimaxnotes init 1 ;set this to the number of simultaneous notes
....
kflag init 1
kount active 1
if kflag == 0 && kount > gimaxnotes then
turnoff
endif
kflag = 0
... ;then the rest of the instrument

which works -- with one killer gotcha!

You can't use a linenr in the instrument! Apparently linenr, turnoff, and active don't play at all nice together. As far as I can tell, the turnoff decrements the active count, but the linenr does so again when its extended duration terminates! So I end up with active counts of "-2" or something...

Without any envelope, notes aren't that good, but I guess it's a start!

-- Pete --

Interesting, thanks! I

Interesting, thanks!

I forgot to mention that I aim to use MIDI in realtime. That is why I want to limit the voice number but maxalloc blocks new instances from playing. So I'll just try how your code works with madsr or mxadsr which have the final release phase similar to linenr...

I found a piece of code in the Cabel example instrument lead_moog_midinotemonoglidein.cw for monophony with portamento in a classic analog synth style. It writes a user defined opcode:

/* Number of instruments */
gkcntmidinotemonoglidein init 0

/* Midi note input for monosynth with portamento */
opcode MidiNoteMonoGlideIn, kkik, iiii

icnt = i(gkcntmidinotemonoglidein)+1
gkcntmidinotemonoglidein init icnt

/* Turn instrument off if there's a new instance */
if (icnt < gkcntmidinotemonoglidein) then
turnoff
endif

ivelscale, iminafttch, imaxafttch, iportatime xin

knote init 0
kvel init 0
kafttch init 0
kptchbnd init 0

midinoteonkey knote, kvel
midichannelaftertouch kafttch, iminafttch, imaxafttch
midipitchbend kptchbnd
ifrq cpsmidi
ivel ampmidi ivelscale

/* Add portamento to frequency */
kglide expseg giptchmidinotemonoglidein, iportatime, ifrq, 1, ifrq
giptchmidinotemonoglidein = ifrq
kfrq = kglide

/* Add pitchbend (-1 octave to +1 octave) */
kfrq = kfrq * 2^kptchbnd

xout kfrq, knote, ivel, kafttch
endop

I am not sure if this can be used along with the right kvariables, or rewritten a little, but it looks pretty usable.

z pack cheap generic viagra ed pills avanafil cialis uk ed drugs z-pack buy viagra uk generic viagra buy zithromax staxyn viagra online z pak Canadian pharmacy viagra uk pharmacy uk kamagra uk z-pak Canadian pharmacy viagra zpak generic cialis cialis online zpack