> Well, it would appear that something is still amiss with dynamic instr's.
Figured out what this is -- basically, the envelope
code you borrowed from elpelele's piano instr:
// k-rate -- note envelope
localtime = localtime + 1 / k_rate;
if (segment == 1) {
if (localtime < 0.010000) {
kamp = kline (0, 0.010000, scale);
}
else {
segment = 2;
}
}
if (segment == 2) {
kamp = scale;
if (localtime > 5.000000) {
segment = 4;
turnoff;
}
}
if (released && segment < 3) {
if (MIDIctrl[64] > 15) {
segment = 3;
extend (5.000000 - localtime);
}
else {
segment = 4;
localtime = 0;
extend (0.100000);
}
}
if (segment == 3) {
if (MIDIctrl[64] <= 15) {
segment = 4;
localtime = 0;
}
else {
kamp = scale;
if (localtime >= 5.000000) {
turnoff;
}
}
}
if (segment == 4) {
kamp = var_kline(scale, 0.100000, 0);
if (localtime >= 0.100000) {
turnoff;
}
}
at least when used for SASL triggering (Eric designed
it for MIDI triggering, thus the MIDIctrl[] ...), seems
to almost never call turnoff in practice.
Eventually the static memory
space sfront allocates gets filled up, and it starts
executing the "grim reaper" code that kills off notes
in progress. Practically all of the notes that get
killed are piano notes long since sounded out,
so it sounds OK for a while --
eventually, though, fate intervenes and the
frac_perpetual and frac_points's get killed in progress,
and that's why you get the weird effects you got, with
notes going away.
On the bright side, things didn't core dump ...
Here's a very unmusical, but effective, replacement
for instr piano that fixes the problem:
// k-rate -- note envelope
if (itime > 3.0)
{
turnoff;
}
// a-rate
samp = scale * loscil(pno [ t ], cps, b, l);
output (samp * (1 - (pitch / 100)), samp * pitch / 100);
Note the i-pass code stays the same, this replaces the
k-rate and a-rate code. In addition, you'll want to
add a turnoff statement to the end of frac_perpetual too
(after the i-rate if statement), or else these will
stick around forever too, using up memory space also.
Try this, and see if it performs as you'd expect it to.
Of course you'll want to write a nice envelope generator
to replace the one I deleted for piano -- right now the
notes click as you would expect them to with a boxcar
envelope. Send along your replacement envelope and I'll
use it in the next sfront release to replace the original
code ...
In the long run, sfront at least needs a combination of
more sophisticated checks to add obligatory turnoffs
(like the one I suggested for frac_perpetual -- a
computer can figure out that an instr with only an
i-pass doesn't need to live very long :-), and a
more sophisticated memory manager -- but for now,
programmers who push dynamic instruments and also
control driver created instruments will have to
remember to practice "good turnoff hygiene" ...
--jl
-------------------------------------------------------------------------
John Lazzaro -- Research Specialist -- CS Division -- EECS -- UC Berkeley
lazzaro [at] cs [dot] berkeley [dot] edu www.cs.berkeley.edu/~lazzaro
-------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Mon Jan 28 2002 - 12:03:53 EST