Dear users and developers,
While trying to shorten the following code example in VDiskIn (as well as in DiskIn),
// cue and play right away
(
SynthDef("help-VDiskin", { |out, bufnum = 0|
Out.ar(out, VDiskIn.ar(1, bufnum, MouseX.kr(0.5, 2.0)));
}).add;
)
(
/* Code 1 */
x = Synth.basicNew("help-VDiskin");
m = { arg buf; x.addToHeadMsg(nil, [\bufnum, buf])};
b = Buffer.cueSoundFile(s,Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff",0,1, completionMessage: m);
)
x.free; b.close; b.free; // clean up
I drafted the following two codes:
/* Code 2*/
Buffer.cueSoundFile(s, Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff", 0, 1, completionMessage: { |buffer| fork{ { VDiskIn.ar(buffer.numChannels, buffer.bufnum, BufRateScale.kr(buffer.bufnum)) }.play } } )
/* Code 3*/
Buffer.cueSoundFile(s, Platform.resourceDir +/+ "sounds/a11wlk01-44_1.aiff", 0, 1, completionMessage: { |buffer| { VDiskIn.ar(buffer.numChannels, buffer.bufnum, BufRateScale.kr(buffer.bufnum)) }.play; } )
Code 2 returns the following strings in the Post window when evaluating it after recompiling sclang:
β Buffer(6, 32768, 1, 48000.0, nil)
Code 2 returns the following strings in the Post window each time when evaluating it after the first evaluation:
β Buffer(7, 32768, 1, 48000.0, nil)
File ββ could not be opened: System error : No such file or directory.
The same phenomenon occurs with Code 3.
Moreover, evaluating Code 2 returns sometimes the following error:
pitch ratio is greater than max allowed (see VDiskIn help)
Repeating the evaluation of Code 2 after evaluating Code 1 produces sounds, but evaluating Code 3 brings the error above again when evaluating Code 2. Therefore, to allow evaluating Code 2 to make sounds, I must reevaluate Code 1.
I cannot understand why this oddity happen.
Could someone explain the reason?
Could any revision of Code 2 or Code 3 produce sound?
What I do not understand at all is the influence of evaluating Code 3 and Code 2:
- Evaluating Code 3 interrupts evaluating Code 2.
- Evaluating Code 1 allows evaluating Code 2 to produce sound.
And⦠sadly, I seem to misunderstand something on completionMessage, but I cannot find what I misunderstand.
I am attaching a video related to this phenomenon:
Best regards,