//-------------------------------------------------------------- void testApp::setup(){ ofSoundStreamSetup(2, 0, this, 44100, 256, 4); // create a new oscillator which we'll use for the actual audio signal // create a sine wave we'll use for some vibrato float frequency = 440; Generator tone = SawtoothWave().freq(frequency); // Generator tone = Noise(); // Generator tone = SquareWave().freq(frequency); // Generator tone = TriangleWave().freq(frequency); // Generator tone = RectWave().freq(frequency); tone = LPF12().input(tone).Q(100).cutoff(frequency*2 + SineWave().freq(3) * 1.5 * frequency); ControlGenerator envelopeTrigger = synth.addParameter("trigger"); Generator env = ADSR().attack(0.001).decay(0.5).sustain(0).release(0).trigger(envelopeTrigger).legato(true); Generator output = tone * env; // set the synth's final output generator synth.setOutputGen( output ); }
//-------------------------------------------------------------- void ofApp::setup(){ //makes audio go out of openframeworks ofSoundStreamSetup(2,0,this,44100,256,4); //these will be the nods and we name them. ControlGenerator midiNote= synth.addParameter("midiNumber"); //convert a midi note to a frequincy ControlGenerator noteFreq = ControlMidiToFreq().input(midiNote); Generator tone = SawtoothWave().freq(noteFreq); //create a tone tone= LPF12().input(tone).Q(2).cutoff((noteFreq*2) +SineWave().freq(3) *0.5* noteFreq); //trigger ControlGenerator envelopeTrigger = synth.addParameter("trigger"); Generator toneWithEnvelope = tone * ADSR().attack(0.01).decay(1.5).sustain(0).release(0).trigger(envelopeTrigger).legato(true); Generator toneWithDelay= StereoDelay(0.5,.7).input(toneWithEnvelope).wetLevel(0.1).feedback(0.2); synth.setOutputGen(toneWithDelay); // arduino bit ard.connect("COM4", 57600); ofAddListener(ard.EInitialized, this, &ofApp::setupArd); }
void lineOsc::setup(int _gridResolutionX, int _gridResolutionY, int _size, ofPoint _center) { gridResolutionX = _gridResolutionX; gridResolutionY = _gridResolutionY; size = _size; center = _center; vector<ofColor> palette; palette.push_back(ofColor(156, 205, 201)); palette.push_back(ofColor(248, 177, 113)); palette.push_back(ofColor(233, 158, 137)); palette.push_back(ofColor(214, 115, 109)); palette.push_back(ofColor(243, 220, 189)); palette.push_back(ofColor(192, 49, 55)); int xSpacing = size / gridResolutionX; int ySpacing = size / gridResolutionY; for(int x = 0; x <= gridResolutionX; x++) { lineObj lo; lo.start.set(center.x - size / 2, x * xSpacing + (center.x - size / 2)); lo.end.set(center.x + size / 2, x * xSpacing + (center.x - size / 2)); lo.position = lo.start; lo.fillColor.set(palette[(int) ofRandom(palette.size())]); lo.frequency = ofRandom(MIN_FREQUENCY, MAX_FREQUENCY) + ofRandom(200); lo.playing = false; lo.playCounter = PLAY_DURATION; lineObjs.push_back(lo); } for(int y = 0; y <= gridResolutionY; y++) { lineObj lo; lo.start.set(y * ySpacing + (center.y - size / 2) + 0.5, center.y - size / 2); lo.end.set(y * ySpacing + (center.y - size / 2) + 0.5, center.y + size / 2); lo.position = lo.start; lo.fillColor.set(palette[(int) ofRandom(palette.size())]); lo.frequency = ofRandom(MIN_FREQUENCY, MAX_FREQUENCY); lo.playing = false; lo.playCounter = PLAY_DURATION; lineObjs.push_back(lo); } ControlGenerator midiNote = synth.addParameter("midiNumber"); ControlGenerator noteFreq = ControlMidiToFreq().input(midiNote); Generator tone = SawtoothWave().freq( noteFreq ); tone = LPF12().input(tone).Q(10).cutoff(noteFreq * 2); ControlGenerator envelopeTrigger = synth.addParameter("trigger"); Generator toneWithEnvelope = 0.05 * tone * ADSR().attack(0.02).decay(0.2).sustain(0).release(0).trigger(envelopeTrigger);//.legato(true); synth.setOutputGen( toneWithEnvelope ); stringColor.set(150, 150, 150); }