Closed cogliano closed 1 year ago
Just fixed it. Thanks, I should have seen that.
Thank you for sharing this @cogliano, was trying to figure this out
I wonder how difficult it would be to add the ability to slow down, or to manipulate the audio in a more fluid way (e.g. control the speed with a slider).
I actually just figured this out. If anyone else is curious, you can change the play speed fluidly using sample rate:
void Adafruit_VS1053_FilePlayer::setSampleRate(uint16_t sampleRate) {
noInterrupts();
sciWrite(VS1053_REG_AUDATA, sampleRate);
interrupts();
}
Need to call this after startPlayingFile
which sets the initial sample rate.
You can then run
uint16_t track_info = musicPlayer.sciRead(VS1053_REG_AUDATA);
int rate = (track_info >> 1) * 2;
int stereo = ((track_info << 15) >> 15);
To read the auto-calculated sample rate, before adjusting it to your liking,.
Awesome!!
@ladyada what do you need to be able to merge this one? I can independently test it if you need?
this one looks OK - thanks for reviewing1
This pull request adds the ability to speed-up or fast forward tracks using the built-in feature of the VS1053 chip. Two functions were added:
I have been using it in my own code for a while and thought it would be useful to contribute it to the library.
To test, simply add a statement like "musicPlayer.setPlaySpeed(2);" to the player_simple.ino example prior to the musicPlayer.startPlayingFile() call.