Adafruit VS1053 Arduino Library
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Adafruit_VS1053_FilePlayer Class Reference

File player for the Adafruit VS1053. More...

#include <Adafruit_VS1053.h>

Inheritance diagram for Adafruit_VS1053_FilePlayer:
Adafruit_VS1053

Public Member Functions

 Adafruit_VS1053_FilePlayer (int8_t mosi, int8_t miso, int8_t clk, int8_t rst, int8_t cs, int8_t dcs, int8_t dreq, int8_t cardCS)
 Software SPI constructor. Uses Software SPI, so you must specify all SPI pins. More...
 
 Adafruit_VS1053_FilePlayer (int8_t rst, int8_t cs, int8_t dcs, int8_t dreq, int8_t cardCS)
 Hardware SPI constructor. Uses Hardware SPI and assumes the default SPI pins. More...
 
 Adafruit_VS1053_FilePlayer (int8_t cs, int8_t dcs, int8_t dreq, int8_t cardCS)
 Hardware SPI constructor. Uses Hardware SPI and assumes the default SPI pins. More...
 
boolean begin (void)
 Initialize communication and reset the chip. More...
 
boolean useInterrupt (uint8_t type)
 Specifies the argument to use for interrupt-driven playback. More...
 
void feedBuffer (void)
 Feeds the buffer. Reads mp3 file data from the SD card and file and puts it into the buffer that the decoder reads from to play a file.
 
unsigned long mp3_ID3Jumper (File mp3)
 Checks for an ID3 tag at the beginning of the file. More...
 
boolean startPlayingFile (const char *trackname)
 Begin playing the specified file from the SD card using interrupt-drive playback. More...
 
boolean playFullFile (const char *trackname)
 Play the complete file. This function will not return until the playback is complete. More...
 
void stopPlaying (void)
 Stop playback.
 
boolean paused (void)
 If playback is paused. More...
 
boolean stopped (void)
 If playback is stopped. More...
 
void pausePlaying (boolean pause)
 Pause playback. More...
 
void playbackLoop (boolean loopState)
 Set state for playback looping. More...
 
boolean playbackLooped ()
 Retrieve playback loop state. More...
 
uint16_t getPlaySpeed ()
 Determine current playback speed. More...
 
void setPlaySpeed (uint16_t speed)
 Set playback speed. More...
 
- Public Member Functions inherited from Adafruit_VS1053
 Adafruit_VS1053 (int8_t mosi, int8_t miso, int8_t clk, int8_t rst, int8_t cs, int8_t dcs, int8_t dreq)
 Software SPI constructor - must specify all pins. More...
 
 Adafruit_VS1053 (int8_t rst, int8_t cs, int8_t dcs, int8_t dreq)
 Hardware SPI constructor - assumes hardware SPI pins. More...
 
uint8_t begin (void)
 Initialize communication and (hard) reset the chip. More...
 
void reset (void)
 Performs a hard reset of the chip.
 
void softReset (void)
 Attempts a soft reset of the chip.
 
uint16_t sciRead (uint8_t addr)
 Reads from the specified register on the chip. More...
 
void sciWrite (uint8_t addr, uint16_t data)
 Writes to the specified register on the chip. More...
 
void sineTest (uint8_t n, uint16_t ms)
 Generate a sine-wave test signal. More...
 
uint16_t decodeTime (void)
 Reads the DECODETIME register from the chip. More...
 
void setVolume (uint8_t left, uint8_t right)
 Set the output volume for the chip. More...
 
void dumpRegs (void)
 Prints the contents of the MODE, STATUS, CLOCKF and VOLUME registers.
 
void playData (uint8_t *buffer, uint8_t buffsiz)
 Decode and play the contents of the supplied buffer. More...
 
boolean readyForData (void)
 Test if ready for more data. More...
 
void applyPatch (const uint16_t *patch, uint16_t patchsize)
 Apply a code patch. More...
 
uint16_t loadPlugin (char *fn)
 Load the specified plug-in. More...
 
void GPIO_digitalWrite (uint8_t i, uint8_t val)
 Write to a GPIO pin. More...
 
void GPIO_digitalWrite (uint8_t i)
 Write to all 8 GPIO pins at once. More...
 
uint16_t GPIO_digitalRead (void)
 Read all 8 GPIO pins at once. More...
 
boolean GPIO_digitalRead (uint8_t i)
 Read a single GPIO pin. More...
 
void GPIO_pinMode (uint8_t i, uint8_t dir)
 Set the Pin Mode (INPUT/OUTPUT) for a GPIO pin. More...
 
boolean prepareRecordOgg (char *plugin)
 Initialize chip for OGG recording. More...
 
void startRecordOgg (boolean mic)
 Start recording. More...
 
void stopRecordOgg (void)
 Stop the recording.
 
uint16_t recordedWordsWaiting (void)
 Returns the number of words recorded. More...
 
uint16_t recordedReadWord (void)
 Reads the next word from the buffer of recorded words. More...
 

Static Public Member Functions

static boolean isMP3File (const char *fileName)
 Checks if the inputted filename is an mp3. More...
 

Public Attributes

File currentTrack
 File that is currently playing.
 
volatile boolean playingMusic
 Whether or not music is playing.
 
- Public Attributes inherited from Adafruit_VS1053
uint8_t mp3buffer [VS1053_DATABUFFERLEN]
 

Additional Inherited Members

- Protected Attributes inherited from Adafruit_VS1053
uint8_t _dreq
 Data request pin.
 
boolean usingInterrupts = false
 True if using interrupts.
 

Detailed Description

File player for the Adafruit VS1053.

Constructor & Destructor Documentation

◆ Adafruit_VS1053_FilePlayer() [1/3]

Adafruit_VS1053_FilePlayer::Adafruit_VS1053_FilePlayer ( int8_t  mosi,
int8_t  miso,
int8_t  clk,
int8_t  rst,
int8_t  cs,
int8_t  dcs,
int8_t  dreq,
int8_t  cardCS 
)

Software SPI constructor. Uses Software SPI, so you must specify all SPI pins.

Parameters
mosiMOSI (Microcontroller Out Serial In) pin
misoMISO (Microcontroller In Serial Out) pin
clkClock pin
rstReset pin
csSCI Chip Select pin
dcsSDI Chip Select pin
dreqData Request pin
cardCSCS pin for the SD card on the SPI bus

◆ Adafruit_VS1053_FilePlayer() [2/3]

Adafruit_VS1053_FilePlayer::Adafruit_VS1053_FilePlayer ( int8_t  rst,
int8_t  cs,
int8_t  dcs,
int8_t  dreq,
int8_t  cardCS 
)

Hardware SPI constructor. Uses Hardware SPI and assumes the default SPI pins.

Parameters
rstReset pin
csSCI Chip Select pin
dcsSDI Chip Select pin
dreqData Request pin
cardCSCS pin for the SD card on the SPI bus

◆ Adafruit_VS1053_FilePlayer() [3/3]

Adafruit_VS1053_FilePlayer::Adafruit_VS1053_FilePlayer ( int8_t  cs,
int8_t  dcs,
int8_t  dreq,
int8_t  cardCS 
)

Hardware SPI constructor. Uses Hardware SPI and assumes the default SPI pins.

Parameters
csSCI Chip Select pin
dcsSDI Chip Select pin
dreqData Request pin
cardCSCS pin for the SD card on the SPI bus

Member Function Documentation

◆ begin()

boolean Adafruit_VS1053_FilePlayer::begin ( void  )

Initialize communication and reset the chip.

Returns
Returns true if a VS1053 is found

◆ useInterrupt()

boolean Adafruit_VS1053_FilePlayer::useInterrupt ( uint8_t  type)

Specifies the argument to use for interrupt-driven playback.

Parameters
typeinterrupt to use. Valid arguments are VS1053_FILEPLAYER_TIMER0_INT and VS1053_FILEPLAYER_PIN_INT
Returns
Returs true/false for success/failure

◆ isMP3File()

boolean Adafruit_VS1053_FilePlayer::isMP3File ( const char *  fileName)
static

Checks if the inputted filename is an mp3.

Parameters
fileNameFile to check
Returns
Returns true or false

◆ mp3_ID3Jumper()

unsigned long Adafruit_VS1053_FilePlayer::mp3_ID3Jumper ( File  mp3)

Checks for an ID3 tag at the beginning of the file.

Parameters
mp3File to read
Returns
returns the seek position within the file where the mp3 data starts

◆ startPlayingFile()

boolean Adafruit_VS1053_FilePlayer::startPlayingFile ( const char *  trackname)

Begin playing the specified file from the SD card using interrupt-drive playback.

Parameters
*tracknameFile to play
Returns
Returns true when file starts playing

◆ playFullFile()

boolean Adafruit_VS1053_FilePlayer::playFullFile ( const char *  trackname)

Play the complete file. This function will not return until the playback is complete.

Parameters
*tracknameFile to play
Returns
Returns true when file starts playing

◆ paused()

boolean Adafruit_VS1053_FilePlayer::paused ( void  )

If playback is paused.

Returns
Returns true if playback is paused

◆ stopped()

boolean Adafruit_VS1053_FilePlayer::stopped ( void  )

If playback is stopped.

Returns
Returns true if playback is stopped

◆ pausePlaying()

void Adafruit_VS1053_FilePlayer::pausePlaying ( boolean  pause)

Pause playback.

Parameters
pausewhether or not to pause playback

◆ playbackLoop()

void Adafruit_VS1053_FilePlayer::playbackLoop ( boolean  loopState)

Set state for playback looping.

Parameters
loopStateSets playback loop state (Note: Only use with startPlayingFile, if used with playFullFile no subsequent code in the sketch executes)

◆ playbackLooped()

boolean Adafruit_VS1053_FilePlayer::playbackLooped ( )

Retrieve playback loop state.

Returns
Returns true when looped playback is enabled

◆ getPlaySpeed()

uint16_t Adafruit_VS1053_FilePlayer::getPlaySpeed ( )

Determine current playback speed.

Returns
Returns playback speed, i.e. 1 for 1x, 2 for 2x, 3 for 3x

◆ setPlaySpeed()

void Adafruit_VS1053_FilePlayer::setPlaySpeed ( uint16_t  speed)

Set playback speed.

Parameters
speedSet playback speed, i.e. 1 for 1x, 2 for 2x, 3 for 3x

The documentation for this class was generated from the following files: