sclang: Fading a pattern with Pdef has issues
jkbd opened this issue · 7 comments
I'm running scsynth
version 3.11.2 on Arch Linux and the Quarks.gui
tells, the latest version of SuperDirt is installed.
I tried the sclang-dirt.scd hack, but unfortunately I managed to crash something.
A minimal example to reproduce. Everything set up, so this plays the bass drum sample as expected:
(type:\dirt, orbit:0, s: \bd).play;
Let's play a pattern:
(
Pdef(\x,
Pbind(
\type, \dirt,
\s, \bd,
\n, Pseq([1, 0, 0, 0], inf), // four on the floor
\dur, 0.5
)
).play
)
If I set a fadeTime
for the Pdef
...
Pdef(\x).fadeTime=8
...then it will crash as soon as a new pattern is evaluated:
(
Pdef(\x,
Pbind(
\type, \dirt,
\s, \hh, // hi-hats
\dur, 0.25
)
).play
)
The error is ERROR: Message 'dbamp' not understood.
but the rest of the dump does not give me a clue what is going on. And Pdef(\x)
will only play SuperDirt again, after I restarted both interpreter and server.
Can somebody please help?
Thanks! Quick fix:
Event.addEventType(\dirt, {
var keys, values;
var dirt = ~dirt ? SuperDirt.default;
if(dirt.isNil) {
Error("dirt event: no dirt instance found.\n\n// You could try:\nSuperDirt.default = ~dirt;").throw;
};
~delta = ~delta ?? { ~stretch.value * ~dur.value };
~amp = ~amp.value;
~latency = ~latency ?? { dirt.server.latency };
if(~n.isArray) {
keys = currentEnvironment.keys.asArray;
values = keys.collect(_.envirGet).flop;
values.do { |each|
var e = Event(parent: currentEnvironment);
keys.do { |key, i| e.put(key, each.at(i)) };
dirt.orbits.wrapAt(e[\orbit] ? 0).value(e)
}
} {
dirt.orbits.wrapAt(~orbit ? 0).value(currentEnvironment)
}
});
I'll add it to the next release.
This fixes the crash. But it does not sound right. While fading, I hear poppy transients instead of a smooth cross-fade. After the fadeTime
passed, the new pattern plays normal.
Pdef(\x) will only play SuperDirt again, after I restarted both interpreter and server.
This is another unrelated problem, I noticed. And it may be me doing wrong.
I played using a TempoClock, like
t = TempoClock.new;
(
Pdef(\x,
Pbind(
\note, Pseq([1, 2, 3], inf),
\dur, 0.5
)
).play(t)
)
After CmdPeriod.run
, the clock is gone.
Pdef(\x).play(t); // -> ERROR: clock is not running.
t = TempoClock.new;
Pdef(\x).play(t); // no error, no sound
Somehow, without the Pdef
the last line produces sound again:
Pbind(\note, Pseq([1, 2, 3], inf), \dur, 0.5).play(t)
CmdPeriod.run
t = TempoClock.new
Pbind(\note, Pseq([1, 2, 3], inf), \dur, 0.5).play(t)
Any suggestions? Should I create an issue at SuperCollider?
For the clock I can use t = TempoClock.new.permanent_(true)
and it will survive CmdPeriod.run
. Then I can play the Pdef(\x)
again without errors. Awesome!
Probably you got me wrong. I apologize for discussing two problems in one issue. But the fading between the two patterns, as in the top example, still sounds wrong and the issue is not solved. What is solved, is that your patch and the correct usage of TempoClock keeps SuperCollider from crashing and and the Pdef
from silently slipping in some unfunctional state.
I recorded the output of SuperCollider of the top example (with your patch applied). The second pattern was evaluated roughly at the fifth beat with .fadeTime = 8
. This is the waveform visualized:
I would expect the Hi-Hat to move in gradually and the Bass Drum to fade-out.
Thanks! Maybe something else different in our libraries. Can you check with the freshly released version? I can't reproduce this behaviour anymore with the new version.