12 #define USE_TEST_MAIN // use the main() function in test_support.h
34 logMsg(
"playing a panning sine...");
44 Osc lfoY(0.2, 1, 0, 0);
48 logMsg(
"playing N-channel panning sine...");
67 logMsg(
"playing mix of 4 sines...");
78 vox1.setFrequency(env1);
80 vox2.setFrequency(env2);
88 logMsg(
"playing mix of panning sins...");
100 float scale = 3.0f / (float) num;
102 for (
int i = 0; i < num; i++) {
105 vox->setFrequency(*env);
106 vox->setScale(scale);
111 logMsg(
"playing mix of %d panning sins...", num);
124 for (
unsigned i = 0; i < 50; i++) {
128 Osc * vox =
new Osc(110.0, 0.01);
129 vox->setFrequency(* freq);
133 logMsg(
"playing mix of panning sines...");
149 AR a_env(2, 0.6, 1.0);
153 logMsg(
"playing swapped sin...");
160 #ifdef USE_CONVOLVER_OLD
162 void testConvolver() {
163 JSoundFile fi(CGestalt::dataFolder(),
"rim3_L.aiff");
170 logMsg(
"playing sound file...");
173 logMsg(
"sound file player done.\n");
175 Convolver cv(CGestalt::dataFolder(),
"Quadraverb_large_L.aiff");
177 logMsg(
"playing convolver...");
183 logMsg(
"convolver done.\n");
186 #define IRLEN (44100 * 4) // 4 sec. IR
188 void testConvolver2() {
190 AR env(0.05, 0.0001, 0.049);
193 logMsg(
"playing noise burst...");
199 buf.allocateBuffers();
200 float * samp = buf.buffer(0);
201 for (
unsigned i = 0; i < IRLEN; i += 5000)
202 samp[i] = 1 / (1 + (sqrt(i) / 5000));
206 logMsg(
"playing convolver...");
211 logMsg(
"convolver done.\n");
214 void testConvolver3() {
216 AR env(0.05, 0.0001, 0.049);
219 logMsg(
"playing noise burst...");
223 Convolver cv(CGestalt::dataFolder(),
"3.3s_LargeCathedral_mono.aiff");
225 logMsg(
"playing convolver...");
232 logMsg(
"convolver done.\n");
248 SoundFile sndfile(CGestalt::dataFolder() +
"splash_mono.aiff");
252 strcpy(folder, CGestalt::dataFolder().c_str());
253 strcat(folder,
"IRCAM_HRTF/512_DB/HRTF_1047.dat");
254 HRTFDatabase::Reload(folder);
255 HRTFDatabase::Database()->dump();
264 logMsg(
"playing HRTF-spatialized rotating sound source (horizontal plane)...");
267 for (
int i = 0; i < 30; i++) {
268 source.
setPosition(
's', (
float) (i * 24), 0.0f, 2.0f);
282 SoundFile sndfile(CGestalt::dataFolder() +
"guanno_mono.aiff");
291 logMsg(
"playing HRTF-spatialized rotating sound source (vertical plane)...");
293 for (
int i = 30; i > 6; i--) {
308 SoundFile sndfile(CGestalt::dataFolder() +
"triangle_mono.aiff");
309 sndfile.openForRead(
true);
319 logMsg(
"playing HRTF-spatialized rotating sound source (medial plane)...");
321 for (
int i = 30; i > 6; i--) {
322 source.
setPosition(
's', 0.0f, (
float) (i * 15), 2.0f);
335 SoundFile sndfile(CGestalt::dataFolder() +
"triangle_mono.aiff");
344 logMsg(
"playing Ambisonic-spatialized rotating sound source (horizontal plane)...");
346 for (
int i = 0; i < 30; i++) {
347 source.
setPosition(
's', (
float) (i * 24), 0.0f, 2.0f);
360 SoundFile sndfile(CGestalt::dataFolder() +
"Piano_A5_mf_mono.aiff");
369 logMsg(
"playing simply spatialized rotating sound source...");
373 for (
int i = 0; i < 30; i++) {
375 source.
setPosition(
's', (
float) (i * 24.0f), 0.0f, (2.0f + (i * 0.15f)));
388 SoundFile sndfile(CGestalt::dataFolder() +
"triangle_mono.aiff");
389 sndfile.openForRead(
true);
399 logMsg(
"playing VBAP-spatialized rotating sound source (horizontal plane)...");
401 for (
int i = 0; i < 30; i++) {
402 source.
setPosition(
's', (
float) (i * 24), 0.0f, 2.0f);
417 #define IR_FILE "/Content/Code/CSL/CSL_Data/7.0s_Cathedral C.aiff"
422 0.000115321, 3.6737e-05, 4.1587e-05, 4.60227e-05, 4.98864e-05, 5.29159e-05, 5.49895e-05, 5.58942e-05, 5.55457e-05,
423 5.36663e-05, 5.01198e-05, 4.46702e-05, 3.75496e-05, 2.84695e-05, 1.72398e-05, 4.32139e-06, -1.05814e-05, -2.70865e-05,
424 -4.5164e-05, -6.44729e-05, -8.47828e-05, -0.000105662, -0.0001268, -0.00014773, -0.000168014, -0.000187043, -0.000204465,
425 -0.00021964, -0.000232086, -0.000241318, -0.000246827, -0.000248233, -0.000245146, -0.000237276, -0.000224392, -0.0002064,
426 -0.000183281, -0.000155108, -0.000122088, -8.45941e-05, -4.30158e-05, 2.01944e-06, 4.98645e-05, 9.97062e-05, 0.000150644,
427 0.000201698, 0.000251824, 0.000299918, 0.000344833, 0.000385437, 0.000420621, 0.000449288, 0.000470436, 0.000483164,
428 0.000486657, 0.000480307, 0.000463611, 0.000436301, 0.00039829, 0.000349742, 0.000291022, 0.000222748, 0.000145778,
429 6.12089e-05, -2.96601e-05, -0.000125284, -0.000223972, -0.000323836, -0.000422867, -0.000518974, -0.000609991, -0.000693752,
430 -0.000768108, -0.000831012, -0.000880526, -0.000914892, -0.000932579, -0.000932317, -0.00091314, -0.000874445, -0.000815971,
431 -0.000737887, -0.000640763, -0.000525601, -0.000393824, -0.000247279, -8.82151e-05, 8.07491e-05, 0.000256652, 0.000436239,
432 0.000616023, 0.000792325, 0.000961359, 0.00111931, 0.0012624, 0.00138695, 0.00148951, 0.00156691, 0.00161633, 0.0016354,
433 0.00162226, 0.00157561, 0.00149478, 0.00137979, 0.00123132, 0.00105081, 0.000840386, 0.000602914, 0.000341936, 6.16378e-05,
434 -0.000233194, -0.000537263, -0.000844827, -0.00114981, -0.0014459, -0.00172668, -0.00198573, -0.00221678, -0.00241383,
435 -0.00257131, -0.00268415, -0.00274799, -0.00275922, -0.00271515, -0.00261406, -0.00245529, -0.00223935, -0.00196787,
436 -0.00164369, -0.00127085, -0.000854537, -0.000401045, 8.22805e-05, 0.000587166, 0.00110451, 0.00162453, 0.00213693,
437 0.00263108, 0.00309619, 0.00352153, 0.00389664, 0.0042115, 0.00445684, 0.00462426, 0.00470647, 0.00469748, 0.00459276,
438 0.00438943, 0.00408636, 0.00368426, 0.00318581, 0.00259565, 0.00192042, 0.00116873, 0.000351074, -0.000520217, -0.00143115,
439 -0.00236624, -0.00330864, -0.00424048, -0.00514303, -0.00599699, -0.00678285, -0.00748112, -0.00807269, -0.00853916,
440 -0.00886316, -0.00902861, -0.00902113, -0.00882822, -0.00843959, -0.00784736, -0.00704628, -0.00603386, -0.00481056,
441 -0.0033798, -0.00174805, 7.5225e-05, 0.00207758, 0.00424374, 0.0065557, 0.00899298, 0.0115328, 0.0141505, 0.0168196,
442 0.0195123, 0.0222, 0.0248534, 0.0274431, 0.0299398, 0.032315, 0.0345414, 0.0365927, 0.0384449, 0.040076, 0.0414664,
443 0.0425994, 0.0434614, 0.044042, 0.044334, 0.044334, 0.044042, 0.0434614, 0.0425994, 0.0414664, 0.040076, 0.0384449,
444 0.0365927, 0.0345414, 0.032315, 0.0299398, 0.0274431, 0.0248534, 0.0222, 0.0195123, 0.0168196, 0.0141505, 0.0115328,
445 0.00899298, 0.0065557, 0.00424374, 0.00207758, 7.5225e-05, -0.00174805, -0.0033798, -0.00481056, -0.00603386, -0.00704628,
446 -0.00784736, -0.00843959, -0.00882822, -0.00902113, -0.00902861, -0.00886316, -0.00853916, -0.00807269, -0.00748112,
447 -0.00678285, -0.00599699, -0.00514303, -0.00424048, -0.00330864, -0.00236624, -0.00143115, -0.000520217, 0.000351074,
448 0.00116873, 0.00192042, 0.00259565, 0.00318581, 0.00368426, 0.00408636, 0.00438943, 0.00459276, 0.00469748, 0.00470647,
449 0.00462426, 0.00445684, 0.0042115, 0.00389664, 0.00352153, 0.00309619, 0.00263108, 0.00213693, 0.00162453, 0.00110451,
450 0.000587166, 8.22805e-05, -0.000401045, -0.000854537, -0.00127085, -0.00164369, -0.00196787, -0.00223935, -0.00245529,
451 -0.00261406, -0.00271515, -0.00275922, -0.00274799, -0.00268415, -0.00257131, -0.00241383, -0.00221678, -0.00198573,
452 -0.00172668, -0.0014459, -0.00114981, -0.000844827, -0.000537263, -0.000233194, 6.16378e-05, 0.000341936, 0.000602914,
453 0.000840386, 0.00105081, 0.00123132, 0.00137979, 0.00149478, 0.00157561, 0.00162226, 0.0016354, 0.00161633, 0.00156691,
454 0.00148951, 0.00138695, 0.0012624, 0.00111931, 0.000961359, 0.000792325, 0.000616023, 0.000436239, 0.000256652, 8.07491e-05,
455 -8.82151e-05, -0.000247279, -0.000393824, -0.000525601, -0.000640763, -0.000737887, -0.000815971, -0.000874445, -0.00091314,
456 -0.000932317, -0.000932579, -0.000914892, -0.000880526, -0.000831012, -0.000768108, -0.000693752, -0.000609991, -0.000518974,
457 -0.000422867, -0.000323836, -0.000223972, -0.000125284, -2.96601e-05, 6.12089e-05, 0.000145778, 0.000222748, 0.000291022,
458 0.000349742, 0.00039829, 0.000436301, 0.000463611, 0.000480307, 0.000486657, 0.000483164, 0.000470436, 0.000449288,
459 0.000420621, 0.000385437, 0.000344833, 0.000299918, 0.000251824, 0.000201698, 0.000150644, 9.97062e-05, 4.98645e-05,
460 2.01944e-06, -4.30158e-05, -8.45941e-05, -0.000122088, -0.000155108, -0.000183281, -0.0002064, -0.000224392, -0.000237276,
461 -0.000245146, -0.000248233, -0.000246827, -0.000241318, -0.000232086, -0.00021964, -0.000204465, -0.000187043, -0.000168014,
462 -0.00014773, -0.0001268, -0.000105662, -8.47828e-05, -6.44729e-05, -4.5164e-05, -2.70865e-05, -1.05814e-05, 4.32139e-06,
463 1.72398e-05, 2.84695e-05, 3.75496e-05, 4.46702e-05, 5.01198e-05, 5.36663e-05, 5.55457e-05, 5.58942e-05, 5.49895e-05,
464 5.29159e-05, 4.98864e-05, 4.60227e-05, 4.1587e-05, 3.6737e-05, 0.000115321
467 #define USE_SND_FILES
471 JSoundFile * sndfile1 = JSoundFile::openSndfile(
string(CGestalt::dataFolder() +
"rim3_L.aiff"));
472 JSoundFile * sndfile2 = JSoundFile::openSndfile(
string(CGestalt::dataFolder() +
"rim3_L.aiff"));
473 #ifdef USE_SND_FILES // read IR from a file - long reverb tail
476 #else // use a block of data (above) as the IR - narrow BP filter
477 Convolver2 conv1(*sndfile1, test_IR, 400, CGestalt::blockSize() * 2,
true);
478 Convolver2 conv2(*sndfile2, test_IR, 400, CGestalt::blockSize() * 2,
true);
480 Joiner join(conv1, conv2);
482 logMsg(
"playing convolved sound source...");
484 for (
int i = 0; i < 1000; i++) {
500 char * pos = strrchr(fname,
'.');
506 if (strcmp(pos,
"wav") == 0) {
507 JSoundFile * inFile = JSoundFile::openSndfile(
string(fname));
508 unsigned frames = inFile->
duration();
517 FILE * inF = fopen(fname,
"rb");
518 fseek(inF, 0L, SEEK_END);
519 unsigned sz = (unsigned) ftell(inF);
521 if (strcmp(pos,
"ir") == 0) {
525 int got = sscanf(lin,
"%d %d", & len, & rat);
532 unsigned d0 = (unsigned) ftell(inF);
533 fread(bfr,
sizeof(
float), len, inF);
538 if (strcmp(pos,
"bin") == 0) {
539 unsigned len = sz /
sizeof(float);
542 fread(bfr,
sizeof(
float), len, inF);
557 Joiner join(noise1, noise2);
562 logMsg(
"playing convolved sound source...");
570 logMsg(
"done: RMS = %g", rms);
576 data =
load_filter_data(
"/Content/Code/RoCoCo/App/RoCoCo/Source/IR_data/akg_k240s_44.wav", len);
578 data =
load_filter_data(
"/Content/Code/RoCoCo/App/RoCoCo/Source/IR_data/BD_DT880_44.wav", len);
580 data =
load_filter_data(
"/Content/Code/RoCoCo/App/RoCoCo/Source/IR_data/bp250_44.wav", len);
582 data =
load_filter_data(
"/Content/Code/RoCoCo/App/RoCoCo/Source/IR_data/bp250b_44.wav", len);
584 data =
load_filter_data(
"/Content/Code/RoCoCo/App/RoCoCo/Source/IR_data/bp1500_44.wav", len);
586 data =
load_filter_data(
"/Content/Code/RoCoCo/App/RoCoCo/Source/IR_data/bp1500b_44.wav", len);
597 #endif // CSL_WINDOWS
623 "Stereo panner",
testPan,
"Demonstrate the stero panner",
625 "Mixer",
testSineMixer,
"Mixer with 4 sine inputs (slow sum-of-sines)",
626 "Panning mixer",
testPanMix,
"Play a panning stereo mixer",
627 "Bigger panning mixer",
testBigPanMix,
"Test a mixer with many inputs",
628 #ifdef USE_CONVOLVER_OLD
629 "Test convolver", testConvolver,
"Test a convolver",
630 "Test convolver 2", testConvolver2,
"Test a convolver",
631 "Test convolver 3", testConvolver3,
"Test a convolver",
633 "Osc bank",
testOscBank,
"Mix a bank of oscillators",
634 "Channel-mapped IO",
testCMapIO,
"Demonstrate channel-mapped IO",
639 "Ambisonics",
test_Ambi_horiz,
"Test the Ambisonic-based spatial panner",
640 "Simple",
test_SimpleP,
"Test the simple spatial panner",
sample * SampleBuffer
1-channel buffer data type, vector of (sample)
InOut class copies the IO port's input buffer to the output buffer, possibly with channel remap and s...
void logMsg(const char *format,...)
These are the public logging messages.
void testOscBank()
Make a bank or 50 sines with random walk panners and glissandi.
void testPanMix()
Pan and mix 2 sines.
Simple panning/filtering spatializer.
void testSineMixer()
Test mixer – really slow additive synthesis.
void test_Binaural_vertMedian()
Repeat a short test file moving in circles around the vertical plane at AZ = 0 (median plane between ...
void test_Ambi_horiz()
Spatializer with Ambisonics.
void addSource(SpatialSource &s)
Add a sound souce to the list of inputs to be processed.
#define IR_FILE
NEW (1905) Convolver.
unsigned duration() const
number of frames in the sound file
void test_convolution_files()
virtual void trigger()
reset to start
Vector Base Amplitude Panning.
White noise – equal power per frequency.
void test_convolution_file(float *data, unsigned len)
void test_Binaural_horiz()
Spatializer with HRTF.
struct used for the JUCE pop-up menu of tests (see the test files)
void testPan()
Pan a sine to stereo.
void testN2MPan()
Pan a sine to "N" channels.
void testBigPanMix()
Pan and mix many sines.
#define CSL_NAME_LEN
default string length
float fRandM(float minV, float maxV)
min - max (min/max)
Temp Spatial Sound Source.
float sample
(could be changed to int, or double)
The Convolver is a CSL Effect.
float rms(unsigned chan, unsigned from, unsigned to)
Buffer Sample Processing (optional). One could also easily add Buffer operators, such as (Buffer + Bu...
virtual SampleBuffer buffer(unsigned bufNum)
Buffer mWavetable
the stored wave form
void test_VBAP_horiz()
Spatializer with VBAP.
unsigned mOffset
used for capture offset
void runTest(UnitGenerator &vox, double dur)
#define CSL_WORD_LEN
default short string length
virtual void capture_off()
end output capture
float * load_filter_data(char *fname, unsigned &siz)
void test_SimpleP()
Spatializer with simple panners & filters and/or reverb.
RandEnvelope envelope class – makes random control signals using a single line segment.
bool mDidIAllocateBuffers
who allocated my data buffers?
void setRoot(UnitGenerator &root)
set/clear my graph root generator
Buffer – the multi-channel sample buffer class (passed around between generators and IO guys)...
void testCMapIO()
swap sound channels with a ChannelMappedBuffer InOut Constructor: InOut(input, inChan, outChan, [ch-1 ... ch-outChan]);
The Convolver2 is a CSL Effect.
Mixer – The n-input m-channel mixer class.
void test_Binaural_vertAxial()
Repeat a short test file moving in circles around the vertical plane at AZ = CSL_PIHALF (axial plane ...
virtual void setPosition(CPoint pos)
Set the sound source position in cartesian coordinates.
Joiner class – a multiplexer for multi-channel signals.
AR = 3-segment attack/release envelope class.
The CSL mono-to-stereo L/R panner class.
void addInput(UnitGenerator &inp)
void setScale(UnitGenerator &scale)
set the receiver's scale member to a UGen or a float
virtual void capture_on(float dur)
test the IO's graph
void dump()
pretty-print the receiver
Container class that simplifies the spatial audio interface. This layer hides most of the inner-worki...
virtual Buffer * get_capture()
answer the capture buffer
#define SAFE_MALLOC(ptr, type, len)
Useful Macros.
Pink noise – equal power per octave.
Base class of CSL exceptions (written upper-case). Has a string message.