Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard-coded buffer length in play_sd_wav.cpp #412

Open
StephanLuik opened this issue Nov 8, 2021 · 3 comments
Open

Hard-coded buffer length in play_sd_wav.cpp #412

StephanLuik opened this issue Nov 8, 2021 · 3 comments

Comments

@StephanLuik
Copy link

Description

In the update() method of play_sd_wav.cpp, the buffer array size is hard-coded to 512 samples. When using a value other than 128 for AUDIO_BLOCK_SAMPLES, the buffer length is no longer a multiple and for some files it will introduce audible gaps in the playback.

Steps To Reproduce Problem

Change the AUDIO_BLOCK_SAMPLES constant to 160 and play back a simple sine wave file.

Hardware & Software

Teensy 4.1 with pins
Audio Adaptor rev. D
Arduino version 1.8.13
Teensyduino version 1.53
Windows 10 Pro 21H1

Arduino Sketch

Errors or Incorrect Output

@FrankBoesing
Copy link
Contributor

AUDIO_BLOCK_SAMPLES has to be a power of two anyway, for other parts of the library.

@StephanLuik
Copy link
Author

Still, if you change AUDIO_BLOCK_SAMPLES to a power of two, say 256, then the hard coded array size of 512 will fail also. It is never a good idea to use hard-coded constants in source code.

@h4yn0nnym0u5e
Copy link
Contributor

I think this is fixed in PR #448

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants