Processing and supercollider buffer problem
in
Programming Questions
•
2 years ago
I am just starting to use supercollider and processing with p5_sc library and I am having trouble creating multiple buffers. I want to play several sound samples using different buffers but I can only create 1 buffer which must be named "playbuf_1"
My porcessing code is:
import oscP5.*;
import netP5.*;
import supercollider.*;
Buffer buffer;
void setup ()
{
Buffer buffer = new Buffer(2);
buffer.read("C:\\Voices/voice1s.wav");
Synth synth = new Synth("playbuf_1");
synth.set("bufnum", buffer.index);
synth.create();
}
void mousePressed()
{
buffer.free(this, "freed");
}
My supercollider code is:
SynthDef(\playbuf_1, { |bufnum = 0, outbus = 0, amp = 0.5, loop = 0, rate = 1.0|
var data;
data = PlayBuf.ar(2, bufnum, BufRateScale.kr(bufnum) * rate, 0, 0, loop);
FreeSelfWhenDone.kr(data);
Out.ar(outbus, data * amp);
}).store;
This code works fine - my sample plays.
The strange thing is when I rename the buffer in both SC and Processing to anything else (e.g. playbuf_2) the
buffer will not play in SC. I get an error post saying:
*** ERROR: SynthDef playbuf_2 not found
FAILURE /s_new SynthDef not found
FAILURE /n_set Node not found
Why is this?
If I want to use multiple samples I assume I will need more than the one buffer. How can I rename the buffer to have multiples samples playing?
Any help appreciated.
My porcessing code is:
import oscP5.*;
import netP5.*;
import supercollider.*;
Buffer buffer;
void setup ()
{
Buffer buffer = new Buffer(2);
buffer.read("C:\\Voices/voice1s.wav");
Synth synth = new Synth("playbuf_1");
synth.set("bufnum", buffer.index);
synth.create();
}
void mousePressed()
{
buffer.free(this, "freed");
}
My supercollider code is:
SynthDef(\playbuf_1, { |bufnum = 0, outbus = 0, amp = 0.5, loop = 0, rate = 1.0|
var data;
data = PlayBuf.ar(2, bufnum, BufRateScale.kr(bufnum) * rate, 0, 0, loop);
FreeSelfWhenDone.kr(data);
Out.ar(outbus, data * amp);
}).store;
This code works fine - my sample plays.
The strange thing is when I rename the buffer in both SC and Processing to anything else (e.g. playbuf_2) the
buffer will not play in SC. I get an error post saying:
*** ERROR: SynthDef playbuf_2 not found
FAILURE /s_new SynthDef not found
FAILURE /n_set Node not found
Why is this?
If I want to use multiple samples I assume I will need more than the one buffer. How can I rename the buffer to have multiples samples playing?
Any help appreciated.
1