11 #define USE_TEST_MAIN // use the main() function in test_support.h
25 logMsg(
"playing quiet white noise...");
27 logMsg(
"quiet white noise done.");
32 logMsg(
"playing quiet pink noise with seed...");
34 logMsg(
"quiet pink noise with seed done.");
45 logMsg(
"playing plucked string...");
55 unsigned numStrings = 64;
60 for (
int i = 0; i < numStrings; i++) {
62 plk->
setScale(40.0 / (
float) numStrings);
63 strings.push_back(plk);
69 logMsg(
"playing 64-string chorus...");
84 float posX = (pos1 > 0)
85 ? ((0.0f - ((pos1 + 1.0f) / (
float)numN)))
86 : ((1.0f - pos1) / (float)numN);
87 float dela =
fRandM(0.08, 0.25);
88 logMsg(
"n: %d p: %d/%d \tx: %5.2f/%5.2f \td:%5.2f", numN, pit1, pitX, pos1, posX, dela);
90 for (
int i = 0; i < numN; i++) {
96 ((
Panner *)pans[cnt])->setPosition(pos1);
103 if (cnt == numStrings)
110 for (
int i = 0; i < numStrings; i++) {
122 SoundFile sfile(CGestalt::dataFolder() +
"MKG1a1b.aiff");
132 logMsg(
"Playing sound file...");
140 SoundFile sfile(CGestalt::dataFolder() +
"piano-tones.aiff");
148 logMsg(
"Playing sound file...");
154 #ifdef USE_MP3 // uses libsndfile for now
158 void testMP3FilePlayer() {
159 MP3File sfile(CGestalt::dataFolder(),
"Piano_B4_096.mp3",
true);
162 logMsg(
"Playing sound file...");
173 SoundFile * sfile =
new SoundFile(CGestalt::dataFolder() +
"whistle_mono.aiff");
176 logMsg(
"playing sound file...");
179 for (
int i = 0; i < 4; i++) {
180 sfile->setRate(rate);
195 ADSR adsr(3.0, 1, 1, 0.7, 1);
197 logMsg(
"Playing WaveShaper 1");
202 ADSR ads2(3.0, 1, 1, 0.7, 1);
204 logMsg(
"Playing WaveShaper 2");
209 ADSR ads3(3.0, 1, 1, 0.7, 1);
211 logMsg(
"Playing WaveShaper 3");
225 logMsg(
"Playing simple fm instrument...");
227 float m_freq = 160.0;
228 float * dPtr = & dur;
229 float * fPtr = & m_freq;
247 logMsg(
"Playing 3 SOS instruments...");
268 logMsg(
"Playing fancy fm instrument...");
270 float * dPtr = & dur;
272 float * fPtr = & freq;
287 logMsg(
"Playing sound file instrument...");
296 SoundFile * sfile =
new SoundFile(CGestalt::dataFolder() + nam);
297 snds.push_back(sfile);
307 unsigned numSounds = 64;
312 for (
int i = 0; i < numSounds / 4; i++) {
321 logMsg(
"playing sound file forest...");
326 int base = which * numSounds / 4;
328 SoundFile * snd = ((SoundFile *)snds[base]);
329 int startp =
iRandV(snd->duration());
330 float dela =
fRandM(0.05, 0.15);
331 int dur = (int)(
fRandM(dela, dela * 4.0f) * (float)CGestalt::frameRate());
333 logMsg(
"n: %d s: %d fr: %d \tdu: %d", numN, which, startp, dur);
335 for (
int i = 0; i < numN; i++) {
336 snd = ((SoundFile *)snds[which + numN]);
337 snd->setStart(startp);
338 snd->setStop(startp + dur);
348 for (
int i = 0; i < numSounds; i++) {
364 SoundFile sndFile(CGestalt::dataFolder() +
"MKG1a1b.aiff");
367 cloud.
mSamples = sndFile.mWavetable.buffer(0);
383 logMsg(
"playing Granular cloud.");
402 logMsg(
"playing IFFT...");
416 MulOp mul1(vox1, env1);
421 MulOp mul2(vox2, env2);
423 AddOp add(mul1, mul2);
425 logMsg(
"playing IFFT crossfade...");
427 logMsg(
"IFFT crossfade done.");
453 "Noise tests",
testNoises,
"Test noise generators",
454 "Plucked string",
testString,
"Waves of string arpeggii, stereo with reverb",
459 "MP3 Snd file player", testMP3FilePlayer,
"Play an MP3 file",
462 "Sample file bank",
testSndFileBank,
"Play a large sample bank from sound files",
465 "SumOfSines instrument",
testSOSInstrument,
"Demonstrate the SumOfSines instrument",
467 "WaveShaping synthesis",
testWaveShaper,
"Play 2 wave-shaper notes with envelopes",
468 "IFFT synthesis",
test_ifft,
"Make a sound with IFFT synthesis",
471 "Soundfile granulation",
testGrainCloud,
"Random sound file granulation example",
void logMsg(const char *format,...)
These are the public logging messages.
float * mSamples
sample buffer pointer
float mWidthBase
stereo width
virtual void trigger()
reset internal time to restart envelope
float mDurationBase
grain duration base
void setParameter(unsigned selector, int argc, void **argv, const char *types)
Plug functions.
virtual void setParameter(unsigned selector, int argc, void **argv, const char *types)
Plug functions.
float mVolumeBase
amplitude scale
float mOffsetRange
offset range
void testSOSInstrument()
Test SOS instrument - play 3 different timbres.
void testMonoFilePlayer()
Test the sound file player - mono, stereo input files.
float keyToFreq(unsigned midiKey)
MIDI Conversions.
void startThreads()
method to start-up the create/reap threads
void addSndtoBank(const char *nam, UGenVector &snds, UGenVector &pans, Mixer &mix)
WaveShaper – Wave-shaping oscillator class.
GrainPlayer – low-level granular synthesis generator, uses a list of current grains.
void playMIDI(float dur, int chan, int key, int vel)
White noise – equal power per frequency.
void setBinMagPhase(int binNumber, float mag, float phase)
void testStringChorus()
Test a chorus of strings – this demo plays an endless loop of string arpeggii. For each arpeggio...
struct used for the JUCE pop-up menu of tests (see the test files)
float mOffsetBase
starting index offset base
void testStereoFilePlayer()
A linearly interpolated segment – this has start and end values, and a duration (in seconds)...
bool coin()
Answer true or false.
void testSndFileInstrument()
Test SoundFile instrument.
void trigger()
reset internal buffers to re-pluck the string.
float mEnvelopeRange
envelope range
float fRandM(float minV, float maxV)
min - max (min/max)
#define set_duration_f
Instrument.h – The CSL pluggable instrument class. See the copyright notice and acknowledgment of au...
float mWidthRange
stereo width
void setRoomSize(float size)
ADSR = 4-segment attack/decay/sustain/release envelope class.
int iRandV(int val)
Integer rands.
void testNoises()
Noise tests, WhiteNoise & PinkNoise - using Scalable to protect our ears.
void testWaveShaper()
Test the WaveShaper.
std::vector< UnitGenerator * > UGenVector
float mRateBase
grain rate base
int iRandM(int minV, int maxV)
min - max (min/max)
float mDensityBase
grain density base
void runTest(UnitGenerator &vox, double dur)
float mEnvelopeBase
envelope base: 0 = perc, 0.5 = triangle, 1 = reverse perc
void test_vector_ifft()
do vector cross-fade the long way
MulOp – A BinaryOp that multiplies two UnitGenerators or fixed constants together, sample-by-sample.
FancyFMInstrument - FM with vibrato (with AR-envelope), attack chiff (filtered noise with AR-envelope...
unsigned numSamples
of samples in buffer
float fRandZ(void)
A variety of useful random-number functions.
float mVolumeRange
amplitude range
void setRoot(UnitGenerator &root)
set/clear my graph root generator
Mixer – The n-input m-channel mixer class.
float mDensityRange
grain density range
void testString()
Plucked string simulation.
Sound file player instrument.
float mRateRange
rate random range
The CSL mono-to-stereo L/R panner class.
GrainCloud – routine for playing clouds under GUI control. This could be called a cloud or a stream...
float mDurationRange
grain duration range
void testFancyFMInstrument()
void addInput(UnitGenerator &inp)
void testFMInstrument()
Test basic FM instrument.
float fRand1(void)
-1 - 1 (one)
bool isPlaying
whether I'm on or off
void setScale(UnitGenerator &scale)
set the receiver's scale member to a UGen or a float
AddOp – A BinaryOp that adds two UnitGenerators or fixed constants together.
void testSoundFileTranspose()
Test the sound file player with rate shift.
KarplusString – string model class.
Pink noise – equal power per octave.