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
linenrin the instrument! Apparentlylinenr,turnoff, andactivedon't play at all nice together. As far as I can tell, theturnoffdecrements the active count, but thelinenrdoes 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
maxallocblocks new instances from playing. So I'll just try how your code works withmadsrormxadsrwhich have the final release phase similar tolinenr...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)+1gkcntmidinotemonoglidein init icnt
/* Turn instrument off if there's a new instance */
if (icnt < gkcntmidinotemonoglidein) then
turnoff
endifivelscale, iminafttch, imaxafttch, iportatime xinknote init 0
kvel init 0
kafttch init 0
kptchbnd init 0midinoteonkey 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^kptchbndxout 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.