diff --git a/Adafruit_VS1053.cpp b/Adafruit_VS1053.cpp index 386498a..c574384 100644 --- a/Adafruit_VS1053.cpp +++ b/Adafruit_VS1053.cpp @@ -327,6 +327,23 @@ void Adafruit_VS1053_FilePlayer::feedBuffer_noLock(void) { } } +// get current playback speed. 0 or 1 indicates normal speed +uint16_t Adafruit_VS1053_FilePlayer::getPlaySpeed() { + noInterrupts(); + sciWrite(VS1053_SCI_WRAMADDR, VS1053_PARA_PLAYSPEED); + uint16_t speed = sciRead(VS1053_SCI_WRAM); + interrupts(); + return speed; +} + +// set playback speed: 0 or 1 for normal speed, 2 for 2x, 3 for 3x, etc. +void Adafruit_VS1053_FilePlayer::setPlaySpeed(uint16_t speed) { + noInterrupts(); + sciWrite(VS1053_SCI_WRAMADDR, VS1053_PARA_PLAYSPEED); + sciWrite(VS1053_SCI_WRAM, speed); + interrupts(); +} + /***************************************************************/ /* VS1053 'low level' interface */ diff --git a/Adafruit_VS1053.h b/Adafruit_VS1053.h index 331a220..e973ed4 100644 --- a/Adafruit_VS1053.h +++ b/Adafruit_VS1053.h @@ -107,6 +107,10 @@ typedef volatile RwReg PortReg; //!< Type definition/alias used to specify the 0x0E //!< SCI_AICTRL register 2. Used to access the user's application program #define VS1053_SCI_AICTRL3 \ 0x0F //!< SCI_AICTRL register 3. Used to access the user's application program +#define VS1053_SCI_WRAM 0x06 //!< RAM write/read +#define VS1053_SCI_WRAMADDR 0x07 //!< Base address for RAM write/read + +#define VS1053_PARA_PLAYSPEED 0x1E04 //!< 0,1 = normal speed, 2 = 2x, 3 = 3x etc #define VS1053_DATABUFFERLEN 32 //!< Length of the data buffer @@ -399,6 +403,15 @@ class Adafruit_VS1053_FilePlayer : public Adafruit_VS1053 { * @return Returns true when looped playback is enabled */ boolean playbackLooped(); + * @brief Determine current playback speed + * @return Returns playback speed, i.e. 1 for 1x, 2 for 2x, 3 for 3x + */ + uint16_t getPlaySpeed(); + /*! + * @brief Set playback speed + * @param speed Set playback speed, i.e. 1 for 1x, 2 for 2x, 3 for 3x + */ + void setPlaySpeed(uint16_t speed); private: void feedBuffer_noLock(void);