When I use the ArduboyTones library and try to play sounds in high frequencies, the sound turns very low. And I cannot see why. On the other hand, ArduboyPlayTunes seems to work very well.
Any help will be appreciated.
Thanks
When I use the ArduboyTones library and try to play sounds in high frequencies, the sound turns very low. And I cannot see why. On the other hand, ArduboyPlayTunes seems to work very well.
Any help will be appreciated.
Thanks
Got any code to demonstrate the problem?
As stated in the Readme, the maximum frequency supported by ArduboyTones is 32767 Hz. What frequencies are you trying to play?
The maximum audible tone to the human ear is 20kHz so it should cover all the frequencys needed with 30kHz
I am trying to play sounds with frequencies under 32767 Hz - specifically the notes included in the library(NOTE_C0 ~ NOTE_B9).
This is my code:
// Sequencer
// Siwoo Kim
#include <Arduboy2.h>
#include <ArduboyTones.h>
Arduboy2 arduboy;
ArduboyTones sound(arduboy.audio.enabled);
const uint8_t scoresize = 10;
uint8_t notes[71] = {
NOTE_REST,NOTE_C0,NOTE_D0,NOTE_E0,NOTE_F0,NOTE_G0,NOTE_A0,NOTE_B0,
NOTE_C1,NOTE_D1,NOTE_E1,NOTE_F1,NOTE_G1,NOTE_A1,NOTE_B1,
NOTE_C2,NOTE_D2,NOTE_E2,NOTE_F2,NOTE_G2,NOTE_A2,NOTE_B2,
NOTE_C3,NOTE_D3,NOTE_E3,NOTE_F3,NOTE_G3,NOTE_A3,NOTE_B3,
NOTE_C4,NOTE_D4,NOTE_E4,NOTE_F4,NOTE_G4,NOTE_A4,NOTE_B4,
NOTE_C5,NOTE_D5,NOTE_E5,NOTE_F5,NOTE_G5,NOTE_A5,NOTE_B5,
NOTE_C6,NOTE_D6,NOTE_E6,NOTE_F6,NOTE_G6,NOTE_A6,NOTE_B6,
NOTE_C7,NOTE_D7,NOTE_E7,NOTE_F7,NOTE_G7,NOTE_A7,NOTE_B7,
NOTE_C8,NOTE_D8,NOTE_E8,NOTE_F8,NOTE_G8,NOTE_A8,NOTE_B8,
NOTE_C9,NOTE_D9,NOTE_E9,NOTE_F9,NOTE_G9,NOTE_A9,NOTE_B9
};
uint8_t score[scoresize];
void setup() {
// Initialization
arduboy.begin();
// Turn on audio
arduboy.audio.on();
}
void loop() {
// Clear screen
arduboy.clear();
for(uint8_t n=0;n<71;n++) {
sound.tone(notes[n]);
delay(1000);
}
// Display
arduboy.display();
}
Your array is of type uint8_t
which are 8 bits long. ArduboyTones expects 16 bit values (unsigned int
or uint16_t
)
Change your array to
uint16_t notes[71] = {
Thanks! It worked
Now off to making a program…