Did you add s.record before s.waitForBoot? That would be the first explanation for not saving any file. Otherwise, Recorder doesn’t ignore silence, so a silent file would be saved.
However, s.record
has a delay, which you can avoid by calling s.prepareForRecord
first. From Server.record helpfile:
If you have not called prepareForRecord first (see above) then it will be invoked for you (but that adds a slight delay before recording starts for real).
So, to put it all together, you also have to know that s.prepareForRecord creates a SynthDef and allocates a buffer for Recorder. To make sure all this is done in due time before starting recording and playing, I would use s.bind and s.sync:
s.waitForBoot {
s.bind{
SynthDef(\grains) { |out, freq=440, pan=0|
Out.ar(out, GrainSin.ar(2, Impulse.kr(10), 0.1, freq, pan, -1));
}.send;
s.prepareForRecord();
s.sync; // wait for all defs to be ready, and rec buffers allocated
s.record();
Synth(\grains);
}
};
Note: I took the freedom to not use your messaging style, as it’s not really needed in this example, and I think it’s better to rely on language abstractions when you can. Anyway, it also works with your syntax:
s.waitForBoot({
s.bind{
var message;
s.prepareForRecord();
s.sync;
s.record();
x = Synth.basicNew(\grains, s);
message = x.newMsg(s, \addToTail);
SynthDef(\grains, { |out, freq=440, pan=0|
Out.ar(out, GrainSin.ar(2, Impulse.kr(10), 0.1, freq, pan, -1));
}).send(s, message);
}
});