/*******************************************/ /* Master Class for Drum Synthesizer */ /* by Perry R. Cook, 1995-96 */ /* This instrument contains a bunch of */ /* RawWvIn objects (Non-Interpolating, */ /* 1 shot players), run through a bunch */ /* of one-pole filters. You can specify */ /* the maximum Polyphony (maximum number */ /* of simultaneous voices) in a #define */ /* in the .h file. */ /*******************************************/ #include "DrumSynt.h" #include char waveNames[DRUM_NUMWAVES][16] = { "bass.raw", "snar.raw", "tomlow.raw", "tommid.raw", "tomhi.raw", "hat.raw", "ride.raw", "crash.raw", "cowbell.raw", "tamb.raw" }; DrumSynt :: DrumSynt() : Object() { int i; /* char temp[64]; */ /* for (i=0;ifinish(); */ /* waves[i]->normalize(0.2); */ /* } */ for (i=0;iclear(); /* then */ tempWv = waves[0]; tempFilt = filters[0]; for (i=0;inormalize(0.2); filters[numSounding-1]->setPole(0.999 - (vel / 32.0)); filters[numSounding-1]->setGain(vel / 128.0); } else { waves[notDone]->reset(); filters[notDone]->setPole(0.999 - (vel / 32.0)); filters[notDone]->setGain(vel / 128.0); } printf("Number Sounding = %i\n",numSounding); for (i=0;ilastOut(); if (waves[i]->informTick() == 1) { printf("Wave %i %i down here\n",i,sounding[i]); delete waves[i]; tempFilt = filters[i]; for (j=i;jclear(); sounding[j] = -1; numSounding -= 1; if (numSounding == 0) notDone = 0; i -= 1; } i++; } return output; } /************** Test Main Program *********************/ #include "miditabl.h" #include "RawWvOut.h" #include "Reverb.h" #include "Noise.h" int main() { long i,j; DrumSynt instrument; RawWvOut output("test.snd"); Reverb reverb(2137); Noise noise; for (j=0;j<100;j++) { i = (int) (fabs(noise.tick()) * DRUM_NUMWAVES); instrument.noteOn(i,127); for (i=0;i<2000;i++) output.tick(reverb.tick(instrument.tick())); } for (i=0;i<22000;i++) output.tick(reverb.tick(instrument.tick())); }