Skip to content

Pop/Crack sound at the end #4

Description

@fraimondo

I don't know if this is still in active development, but I will leave it here anyway.

I'm currently trying to use an arduino/genuino zero to play wav files from the SD card. I followed the example from the "Arduino Zero Simple audio player". I found to problems:

  1. Power/Line/Background noise is very high.
  2. Crack/pop sound at the end.

I managed to solve 1 by following the steps in this guide. The more you advance in the guide, the better the noise reduction.

The problem comes with 2. The pop or crack sound at the end might be due to a library issue. So far my tests point out at the DAC having a value different than 0 up to the moment the end function is called. Getting through the code, I can see that the interruptions are enabled when the file starts playing, but if there's no more file to read, then the interruptions keep working until the end function is called. In that interim, the interruption function keeps writing the last buffer read from the file.

Also, as another question: isn't the interruption handler missing the last sample in the buffer each time?

if (__SampleIndex < __NumberOfSamples - 1) {
    analogWrite(A0, __WavSamples[__SampleIndex++]);
}  else {
    __SampleIndex = 0;
}

Since it's a <, it could never be __NumberOfSamples - 1, meaning that the last position in the buffer is never read. Also, in the else case, nothing is written to A0, so the buffer starts from scratch, but a sample is skipped. Of course skipping a sample at that frequency is nothing, it just took me some time to understand how it works.

There are many ways of solving this issue, and since it's blocking my project a bit, I will tacle this issue soon. I'm creating this issue in order to get the opinion from the original coders in case I'm missing something here.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions