nathanRamaNoodles / Noodle-Synth

A User-friendly Arduino/Teensy Library to play RTTL/MIDI with infinite polyphonic notes; it has full control over volume, pitch, and music. No shields needed(Just a speaker).
https://create.arduino.cc/projecthub/nathan_ramanathan/play-music-without-delay-40e51b
MIT License
138 stars 14 forks source link

Arduino Uno - volume problems #21

Closed dwjbosman closed 4 years ago

dwjbosman commented 4 years ago

I can't seem to set the volume on Arduino Uno. Whatever value I set it to there is no sound output. If I leave it unchanged the sound is fine (but too loud :) )

// 2 channel polyphony  
MusicWithoutDelay buzzer(song);
MusicWithoutDelay buzzer2(song2);

void setup() {

 // buzzer2.setVolume(75); // doesn't work
 // buzzer2.setVolume(100); // doesn't work

  buzzer.begin(CHB, TRIANGLE, ENVELOPE0, 0);   //CHB means pin 3 on Arduino UNO, CHA means pin 11
  buzzer2.begin(CHB,SAW, ENVELOPE0, 0);
}

void loop() {
  buzzer.update();
  buzzer2.update();
  .....
}
nathanRamaNoodles commented 4 years ago

Try putting setVolume inside the loop() after each buzzer's update().

dwjbosman commented 4 years ago

That worked!