void SoundTask::task() { while(true) { Tone tone; if(xQueueReceive(_tones, &tone, portMAX_DELAY) == pdTRUE) { tone.play(); } } }
void setup(void) { tone1.begin(13); tone2.begin(12); pinMode(2, INPUT); pinMode(3, INPUT); Serial.begin(9600); }
void set(std::string a, Tone b, Tone c, Tone d) { Tone zero; zero.set("x", 0.00); name = a; tone1 = b; tone2 = c; tone3 = d; tone4 = zero; }
void audio_callback(void* udata, Uint8* instream, int len) { Sint16* stream = (Sint16*)instream; Sint16* p = stream; while (len > 0) { *p++ = int(3000 * TONE.fetch_left()); *p++ = int(3000 * TONE.fetch_right()); len -= 4; } TONE.sanitize(); }
void playSection(int notes[],int bassNote,int repeat,int length){ // play notes for(int j=0;j<repeat;j++){ if(bassNote != 13){ tone2.play(bass[bassNote],(length - 1 * 300)); // TODO: calculate how long to play bass } for(int i=0;i<=length-1;i++){ tone1.play(notes[i]); delay(300); tone1.stop(); } tone2.stop(); } }
bool needsEffectRender(bool flashing) { bool rectEffective = !rect->isEmpty(); bool colorToneEffective = color->hasEffect() || tone->hasEffect() || flashing; return (rectEffective && colorToneEffective && isOnScreen); }
void rawGenerator::in(Tone a) { double x = 0, y = 0, z = 0; const double increment1 = (a.getFrequency() / SAMPLE_RATE); cout << "Creating a mix of: " << a.getFrequency() << endl; cout << "Creating a mix of: " << increment1 << endl; cout << "Samples: " << SAMPLES << endl; cout << "Sample rate: " << SAMPLE_RATE << endl; for (unsigned i = 0; i < SAMPLES; i++) { waveOut[i] = (sin(x * TWO_PI)) * AMPLITUDE; x += increment1; } }
//********************************************************************************************************* void beep() { #ifdef _USE_ARDUINO_TONE tone(SPEAKER_PIN2, NOTE_C8, 200); #else // beep after reset; noiseMaker.play(NOTE_C8, 200); #endif }
//********************************************************************************************************* void setupSpeaker() { // REM: should exploit the 2 sound levels, by driving both speaker pins; pinMode(SPEAKER_PIN1, OUTPUT); digitalWrite(SPEAKER_PIN1, LOW); pinMode(SPEAKER_PIN2, OUTPUT); #ifndef _USE_ARDUINO_TONE noiseMaker.begin(SPEAKER_PIN2); #endif }
void loop(){ buttonState = digitalRead(buttonPin); if (buttonState == LOW){ for(i = 0; i < 7; i = i + 1){ mytone.play(songTones[i], 1000); delay(1000); } } else { //HERE I GO AGAIN RECORD MODE mytone.stop(); //silence for(i = 0; i < 7; i = i + 1){ int inVar = analogRead(0); //read the varible resistor for a value // map the input to a frequency range between 200 and 2000 Hz int note = map(inVar, 0, 1023, 220, 2000); songTones[i] = note; //set value mytone.play(note, 1000);//play value, duration small // mytone.stop(); //silence delay(1000); } //end tone? }//end if/else }//endloop
void loop() { note_raw = analogRead(NOTE_PIN); beat_raw = analogRead(BEAT_PIN); // note = dist2note[distance(note_raw)]; // if (beat_raw > BEAT_TH) { // if (note != last_note) { // last_note = note; // tn.play(notes[note]); // } // } else { // tn.stop() // } for (int i = 0; i < 89; i++) { tn.play(all_notes[i]); if (DELAY) { delay(DELAY); } } }
void rawGenerator::in(Chord a, Tone b) { double x = 0, y = 0, z = 0, w = 0, v = 0; const double increment1 = (a.tone1.getFrequency() / SAMPLE_RATE); const double increment2 = (a.tone2.getFrequency() / SAMPLE_RATE); const double increment3 = (a.tone3.getFrequency() / SAMPLE_RATE); const double increment4 = (a.tone4.getFrequency() / SAMPLE_RATE); const double increment5 = (b.getFrequency() / SAMPLE_RATE); cout << "Creating a mix of: " << a.name << endl; for (unsigned i = 0; i < SAMPLES; i++) { waveOut[i] = (sin(x * TWO_PI) + sin(y * TWO_PI) + sin(z * TWO_PI) + sin(w * TWO_PI) + sin(v * TWO_PI)) * AMPLITUDE; x += increment1; y += increment2; z += increment3; v += increment4; w += increment5; } }
void setup() { Serial.begin(9600); init_note_distances(); tn.begin(11); }
void setup() { Serial.begin(9600); tone.begin(12); }
void loop() { for (int i; i < 12; i++) { tone.play(note[i]); delay(1000); } }
void setup(){ pinMode(buttonPin, INPUT); mytone.begin(8); //output sound on pin 8 }
void redrawBaseTex() { if (nullOrDisposed(windowskin)) return; if (base.tex.tex == TEX::ID(0)) return; FBO::bind(base.tex.fbo); /* Clear texture */ glState.clearColor.pushSet(Vec4()); FBO::clear(); glState.clearColor.pop(); glState.viewport.pushSet(IntRect(0, 0, base.tex.width, base.tex.height)); glState.blend.pushSet(false); ShaderBase *shader; if (backOpacity < 255 || tone->hasEffect()) { PlaneShader &planeShader = shState->shaders().plane; planeShader.bind(); planeShader.setColor(Vec4()); planeShader.setFlash(Vec4()); planeShader.setTone(tone->norm); planeShader.setOpacity(backOpacity.norm); shader = &planeShader; } else { shader = &shState->shaders().simple; shader->bind(); } windowskin->bindTex(*shader); TEX::setSmooth(true); shader->setTranslation(Vec2i()); shader->applyViewportProj(); /* Draw stretched layer */ base.vert.draw(0, 1); glState.blend.set(true); glState.blendMode.pushSet(BlendKeepDestAlpha); /* Draw tiled layer */ base.vert.draw(1, base.bgTileQuads); glState.blendMode.set(BlendNormal); /* If we used plane shader before, switch to simple */ if (shader != &shState->shaders().simple) { shader = &shState->shaders().simple; shader->bind(); shader->setTranslation(Vec2i()); shader->applyViewportProj(); windowskin->bindTex(*shader); } base.vert.draw(1+base.bgTileQuads, base.borderQuads); TEX::setSmooth(false); glState.blendMode.pop(); glState.blend.pop(); glState.viewport.pop(); }