// Example3.cpp // MIDI-controlled synthesizer using // control & audio rates // VL, 2001 #include #include #include int main(int argc, char** argv){ int i; float dur = 30.f; // dur in secs float sr = DEF_SR; // sampling rate int vecsize = 100; // DSP vector size float kr = sr/vecsize; // control rate short cur_note = 0; // current note float cur_amp = 0.f; // table objects NoteTable ptable; HarmTable table1(1024,20,SAW); // midi input SndMidiIn midi; // control-rate objects MidiIn note(&midi,NOTE_MESSAGE,1,1,kr); Lookup conversion(&ptable,0,¬e,WRAP_AROUND,RAW_VALUE,1,kr); Bend pitch(&conversion, &midi, 10.f, 1, 1, kr); Interp amp(0.f, cur_amp, .05f, 0.f, 1, kr); // audio-rate objects Oscil oscil(&table1, 0.f, 0.f, &pitch, &, vecsize, sr); SndRTIO output(1, SND_OUTPUT, 128, 10, SHORTSAM,0, vecsize, sr); output.SetOutput(1, &oscil); for(i=0; i