Discussion:
Please help me identify why the server hangs when I run this code
Matt Smith
2014-09-18 11:29:58 UTC
Permalink
Hi there,

I have written the following code which produces a drone that should last
four minutes (due to the DoneAction on the LFGauss).

({
var freq, note1, beatchange, note2, note3, sig, env;
freq = (LFGauss.kr(240, 0.8, 0, 0, 2) * 55) + 55;
beatchange= SinOsc.kr(0.01, 0, 0.8, 0) + LFSaw.kr(1, 0.25, 0.2, 0);
note1 = Mix.ar(SinOsc.ar([freq, freq + (beatchange * 5), freq * 3, freq *
5, freq * 7, freq * 9]));
note2 = Mix.ar(Pulse.ar(Vibrato.kr(freq), 0.5), Pulse.ar(Vibrato.kr(freq *
3/2), 0.5),
Pulse.ar(Vibrato.kr(freq * 2), 0.5));
env = Env.perc(0.1, 0.3, 1, -4);
note3 = EnvGen.ar(env, Dust2.ar(0.25, 1, 0)) * Saw.ar(Vibrato.ar((freq * 2
* 2/3)), 0.4, 0).distort;
sig = Mix.ar(note1, note2, note3);
Pan2.ar(FreeVerb.ar(sig, 0.5, 0.8, 0.3, 1, 0))
}.play
)
Matt Smith
2014-09-18 11:36:01 UTC
Permalink
Apologies - managed to send the email before finishing it.

I have written the following code which produces a drone that should last
four minutes (due to the DoneAction on the LFGauss).

({
var freq, note1, beatchange, note2, note3, sig, env;
freq = (LFGauss.kr(240, 0.8, 0, 0, 2) * 55) + 55;
beatchange= SinOsc.kr(0.01, 0, 0.8, 0) + LFSaw.kr(1, 0.25, 0.2, 0);
note1 = Mix.ar(SinOsc.ar([freq, freq + (beatchange * 5), freq * 3, freq *
5, freq * 7, freq * 9]));
note2 = Mix.ar(Pulse.ar(Vibrato.kr(freq), 0.5), Pulse.ar(Vibrato.kr(freq *
3/2), 0.5),
Pulse.ar(Vibrato.kr(freq * 2), 0.5));
env = Env.perc(0.1, 0.3, 1, -4);
note3 = EnvGen.ar(env, Dust2.ar(0.25, 1, 0)) * Saw.ar(Vibrato.ar((freq * 2
* 2/3)), 0.4, 0).distort;
sig = Mix.ar(note1, note2, note3);
Pan2.ar(FreeVerb.ar(sig, 0.5, 0.8, 0.3, 1, 0))
}.play
)

The code works but at some variable point during the run (before 4 minutes)
the audio stops abruptly. I then cannot run any further code without using
Server.killAll and booting the server again. I don't think it's an issue
with system resources as I have 6 processor cores and 8Gig of Ram available
and I'm not running anything else.

Could this be an issue with the code I've written or do I need to change
something in the server setup?

Cheers,

Matt
felix
2014-09-18 12:06:46 UTC
Permalink
its probably a NaN coming from the math inside the reverb

reverbs are prone to getting these. once a NaN is in there, every math
operation it gets mixed with also gets screwed up. because you can't do
math with something that is not a number.

thus the whole mix is suddenly dead.

this will block them from propagating any further:

good = BinaryOpUGen('==', CheckBadValues.kr(in, 0, 0), 0);
in = in * good;

you still need to restart that synth though.
Post by Matt Smith
Apologies - managed to send the email before finishing it.
I have written the following code which produces a drone that should last
four minutes (due to the DoneAction on the LFGauss).
({
var freq, note1, beatchange, note2, note3, sig, env;
freq = (LFGauss.kr(240, 0.8, 0, 0, 2) * 55) + 55;
beatchange= SinOsc.kr(0.01, 0, 0.8, 0) + LFSaw.kr(1, 0.25, 0.2, 0);
note1 = Mix.ar(SinOsc.ar([freq, freq + (beatchange * 5), freq * 3, freq *
5, freq * 7, freq * 9]));
note2 = Mix.ar(Pulse.ar(Vibrato.kr(freq), 0.5), Pulse.ar(Vibrato.kr(freq *
3/2), 0.5),
Pulse.ar(Vibrato.kr(freq * 2), 0.5));
env = Env.perc(0.1, 0.3, 1, -4);
note3 = EnvGen.ar(env, Dust2.ar(0.25, 1, 0)) * Saw.ar(Vibrato.ar((freq * 2
* 2/3)), 0.4, 0).distort;
sig = Mix.ar(note1, note2, note3);
Pan2.ar(FreeVerb.ar(sig, 0.5, 0.8, 0.3, 1, 0))
}.play
)
The code works but at some variable point during the run (before 4
minutes) the audio stops abruptly. I then cannot run any further code
without using Server.killAll and booting the server again. I don't think
it's an issue with system resources as I have 6 processor cores and 8Gig of
Ram available and I'm not running anything else.
Could this be an issue with the code I've written or do I need to change
something in the server setup?
Cheers,
Matt
--
..
http://soundcloud.com/crucialfelix
http://github.com/crucialfelix
.
Matt Smith
2014-09-18 13:06:11 UTC
Permalink
Thanks Felix,

I tried just taking out the reverb in the first instance. I have also taken
out the LFGauss and replaced it with a simple Sine wave, I have also done
the same with the vibrato to try and simplify things. I'm still getting the
problem though. Is there any kind of log that would have more info on the
server crash? I tried googling for it but couldn't spot anything.

Cheers,

Matt
Post by felix
its probably a NaN coming from the math inside the reverb
reverbs are prone to getting these. once a NaN is in there, every math
operation it gets mixed with also gets screwed up. because you can't do
math with something that is not a number.
thus the whole mix is suddenly dead.
good = BinaryOpUGen('==', CheckBadValues.kr(in, 0, 0), 0);
in = in * good;
you still need to restart that synth though.
Post by Matt Smith
Apologies - managed to send the email before finishing it.
I have written the following code which produces a drone that should last
four minutes (due to the DoneAction on the LFGauss).
({
var freq, note1, beatchange, note2, note3, sig, env;
freq = (LFGauss.kr(240, 0.8, 0, 0, 2) * 55) + 55;
beatchange= SinOsc.kr(0.01, 0, 0.8, 0) + LFSaw.kr(1, 0.25, 0.2, 0);
note1 = Mix.ar(SinOsc.ar([freq, freq + (beatchange * 5), freq * 3, freq *
5, freq * 7, freq * 9]));
note2 = Mix.ar(Pulse.ar(Vibrato.kr(freq), 0.5), Pulse.ar(Vibrato.kr(freq
* 3/2), 0.5),
Pulse.ar(Vibrato.kr(freq * 2), 0.5));
env = Env.perc(0.1, 0.3, 1, -4);
note3 = EnvGen.ar(env, Dust2.ar(0.25, 1, 0)) * Saw.ar(Vibrato.ar((freq *
2 * 2/3)), 0.4, 0).distort;
sig = Mix.ar(note1, note2, note3);
Pan2.ar(FreeVerb.ar(sig, 0.5, 0.8, 0.3, 1, 0))
}.play
)
The code works but at some variable point during the run (before 4
minutes) the audio stops abruptly. I then cannot run any further code
without using Server.killAll and booting the server again. I don't think
it's an issue with system resources as I have 6 processor cores and 8Gig of
Ram available and I'm not running anything else.
Could this be an issue with the code I've written or do I need to change
something in the server setup?
Cheers,
Matt
--
..
http://soundcloud.com/crucialfelix
http://github.com/crucialfelix
.
Eli Fieldsteel
2014-09-18 14:59:18 UTC
Permalink
Tried this code, the server hung for me as well. Then I made three minor
changes:

- one instance of Vibrato.ar, changed to Vibrato.kr (for consistency)
- changed Dust2.ar to Dust.ar (why bother with negative impulses?)
- scaled the overall output down to a nominal level (multiplied Pan2.ar by
0.4)

After making these changes I was able to make it to the end of the gaussian
shape with the server still running (twice, in fact). This seems to work and
I think it's because (looking at the Vibrato help file) an audio rate
Vibrato must have an audio rate UGen as its frequency input, NOT a constant
or k-rate UGen. Here is the new code:

(
{
var freq, note1, beatchange, note2, note3, sig, env;
freq = (LFGauss.kr(240, 0.8, 0, 0, 2) * 55) + 55;
beatchange= SinOsc.kr(0.01, 0, 0.8, 0) + LFSaw.kr(1, 0.25, 0.2, 0);
note1 = Mix.ar(SinOsc.ar([freq, freq + (beatchange * 5), freq * 3, freq *
5, freq * 7, freq * 9]));
note2 = Mix.ar(Pulse.ar(Vibrato.kr(freq), 0.5), Pulse.ar(Vibrato.kr(freq *
3/2), 0.5),
Pulse.ar(Vibrato.kr(freq * 2), 0.5));
env = Env.perc(0.1, 0.3, 1, -4);
note3 = EnvGen.ar(env, Dust.ar(0.25, 1, 0)) * Saw.ar(Vibrato.kr((freq * 2 *
2/3)), 0.4, 0).distort;
sig = Mix.ar(note1, note2, note3);
Pan2.ar(FreeVerb.ar(sig, 0.5, 0.8, 0.3, 1, 0)) * 0.4
}.play
)

Eli



--
View this message in context: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/Please-help-me-identify-why-the-server-hangs-when-I-run-this-code-tp7613448p7613451.html
Sent from the SuperCollider Users New (Use this!!!!) mailing list archive at Nabble.com.

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
felix
2014-09-18 15:01:08 UTC
Permalink
the server didn't crash. if it did crash then you wouldn't have been able
to do kill all and reboot it.

if its still happening without the reverb then you can eliminate that as
the problem.

anyway, eli seems to have found it.
Post by Matt Smith
Thanks Felix,
I tried just taking out the reverb in the first instance. I have also
taken out the LFGauss and replaced it with a simple Sine wave, I have also
done the same with the vibrato to try and simplify things. I'm still
getting the problem though. Is there any kind of log that would have more
info on the server crash? I tried googling for it but couldn't spot
anything.
Cheers,
Matt
Post by felix
its probably a NaN coming from the math inside the reverb
reverbs are prone to getting these. once a NaN is in there, every math
operation it gets mixed with also gets screwed up. because you can't do
math with something that is not a number.
thus the whole mix is suddenly dead.
good = BinaryOpUGen('==', CheckBadValues.kr(in, 0, 0), 0);
in = in * good;
you still need to restart that synth though.
Post by Matt Smith
Apologies - managed to send the email before finishing it.
I have written the following code which produces a drone that should
last four minutes (due to the DoneAction on the LFGauss).
({
var freq, note1, beatchange, note2, note3, sig, env;
freq = (LFGauss.kr(240, 0.8, 0, 0, 2) * 55) + 55;
beatchange= SinOsc.kr(0.01, 0, 0.8, 0) + LFSaw.kr(1, 0.25, 0.2, 0);
note1 = Mix.ar(SinOsc.ar([freq, freq + (beatchange * 5), freq * 3, freq
* 5, freq * 7, freq * 9]));
note2 = Mix.ar(Pulse.ar(Vibrato.kr(freq), 0.5), Pulse.ar(Vibrato.kr(freq
* 3/2), 0.5),
Pulse.ar(Vibrato.kr(freq * 2), 0.5));
env = Env.perc(0.1, 0.3, 1, -4);
note3 = EnvGen.ar(env, Dust2.ar(0.25, 1, 0)) * Saw.ar(Vibrato.ar((freq *
2 * 2/3)), 0.4, 0).distort;
sig = Mix.ar(note1, note2, note3);
Pan2.ar(FreeVerb.ar(sig, 0.5, 0.8, 0.3, 1, 0))
}.play
)
The code works but at some variable point during the run (before 4
minutes) the audio stops abruptly. I then cannot run any further code
without using Server.killAll and booting the server again. I don't think
it's an issue with system resources as I have 6 processor cores and 8Gig of
Ram available and I'm not running anything else.
Could this be an issue with the code I've written or do I need to change
something in the server setup?
Cheers,
Matt
--
..
http://soundcloud.com/crucialfelix
http://github.com/crucialfelix
.
--
..
http://soundcloud.com/crucialfelix
http://github.com/crucialfelix
.
Matt Smith
2014-09-18 15:25:49 UTC
Permalink
Thanks Felix and Eli,

I have now run the code through several times without it stopping so
it seems to be fixed. I think the problem must have lain with either
the use of Dust2 or the output level as I had already replaced all the
vibratos with a single sine oscillator and that had not cured the
issue.

Thanks again for the help.

Matt
the server didn't crash. if it did crash then you wouldn't have been able to
do kill all and reboot it.
if its still happening without the reverb then you can eliminate that as the
problem.
anyway, eli seems to have found it.
Post by Matt Smith
Thanks Felix,
I tried just taking out the reverb in the first instance. I have also
taken out the LFGauss and replaced it with a simple Sine wave, I have also
done the same with the vibrato to try and simplify things. I'm still getting
the problem though. Is there any kind of log that would have more info on
the server crash? I tried googling for it but couldn't spot anything.
Cheers,
Matt
Post by felix
its probably a NaN coming from the math inside the reverb
reverbs are prone to getting these. once a NaN is in there, every math
operation it gets mixed with also gets screwed up. because you can't do math
with something that is not a number.
thus the whole mix is suddenly dead.
good = BinaryOpUGen('==', CheckBadValues.kr(in, 0, 0), 0);
in = in * good;
you still need to restart that synth though.
Post by Matt Smith
Apologies - managed to send the email before finishing it.
I have written the following code which produces a drone that should
last four minutes (due to the DoneAction on the LFGauss).
({
var freq, note1, beatchange, note2, note3, sig, env;
freq = (LFGauss.kr(240, 0.8, 0, 0, 2) * 55) + 55;
beatchange= SinOsc.kr(0.01, 0, 0.8, 0) + LFSaw.kr(1, 0.25, 0.2, 0);
note1 = Mix.ar(SinOsc.ar([freq, freq + (beatchange * 5), freq * 3, freq
* 5, freq * 7, freq * 9]));
note2 = Mix.ar(Pulse.ar(Vibrato.kr(freq), 0.5), Pulse.ar(Vibrato.kr(freq
* 3/2), 0.5),
Pulse.ar(Vibrato.kr(freq * 2), 0.5));
env = Env.perc(0.1, 0.3, 1, -4);
note3 = EnvGen.ar(env, Dust2.ar(0.25, 1, 0)) * Saw.ar(Vibrato.ar((freq *
2 * 2/3)), 0.4, 0).distort;
sig = Mix.ar(note1, note2, note3);
Pan2.ar(FreeVerb.ar(sig, 0.5, 0.8, 0.3, 1, 0))
}.play
)
The code works but at some variable point during the run (before 4
minutes) the audio stops abruptly. I then cannot run any further code
without using Server.killAll and booting the server again. I don't think
it's an issue with system resources as I have 6 processor cores and 8Gig of
Ram available and I'm not running anything else.
Could this be an issue with the code I've written or do I need to change
something in the server setup?
Cheers,
Matt
--
..
http://soundcloud.com/crucialfelix
http://github.com/crucialfelix
.
--
..
http://soundcloud.com/crucialfelix
http://github.com/crucialfelix
.
_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Loading...