I have a Hallowing M0 Express board and I'm working with Library -> Adafruit Arcada Library -> full_board_test -> hallowingm0_arcadatest
There is a test play_tune as below
Code: Select all
void play_tune(const uint8_t *audio, uint32_t audio_length) {
uint32_t t;
uint32_t prior, usec = 1000000L / SAMPLE_RATE;
for (uint32_t i=0; i<audio_length; i++) {
while((t = micros()) - prior < usec);
analogWrite(A0, (uint16_t)audio[i] / 8);
prior = t;
}
}
I tried to remove " / 8 " and the sound is not played properly, it played a noise sound.
As I know, the audio samples in audio.h is an unsigned 8 bit raw data.
Thank you and best regards,
Manh