Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
VS1053 Class Reference
#include <VS1053.h>
Public Member Functions | |
| VS1053 (PinName mosiPin, PinName misoPin, PinName sckPin, PinName csPin, PinName bsyncPin, PinName dreqPin, PinName rstPin, uint32_t spiFrequency=1000000) | |
| Constructor of class VS1053. | |
| ~VS1053 () | |
| Destructor of class VS1053. | |
| void | hardwareReset () |
| Make a hardware reset by hitting VS1053's RESET pin. | |
| void | sendDataByte (uint8_t data) |
| Send a data byte to VS1053. | |
| size_t | sendDataBlock (uint8_t *data, size_t length) |
| Send a data block specified as a pointer to VS1053. | |
| void | clockUp () |
| Change VS1053's PLL setting for speedup. | |
| bool | sendCancel () |
| Send cancel request to VS1053. | |
| bool | stop () |
| Attempt a termination of playing. | |
| VS1053 (PinName mosi, PinName miso, PinName sck, PinName cs, PinName rst, PinName dreq, PinName dcs, char *buffer, int buffer_size) | |
| Create a vs1053b object. | |
| void | reset (void) |
| Reset the vs1053b. | |
| void | terminateStream (void) |
| Stop the playback if the song is completed. | |
| bool | initialize (void) |
| Initialize the vs1053b device. | |
| void | setVolume (float volume=DEFAULT_VOLUME) |
| Set the volume. | |
| float | getVolume () |
| Get the volume. | |
| void | setBalance (float balance=DEFAULT_BALANCE_DIFERENCE_LEFT_RIGHT) |
| Set the balance - volume difference between left-right. | |
| float | getBalance () |
| Get the balance - volume difference between left-right. | |
| int | getTrebleFrequency (void) |
| Get the treble frequency limit. | |
| void | setTrebleFrequency (int frequency=DEFAULT_TREBLE_FREQUENCY) |
| Set the treble frequency limit. | |
| int | getTrebleAmplitude (void) |
| Get the treble amplitude. | |
| void | setTrebleAmplitude (int amplitude=DEFAULT_TREBLE_AMPLITUDE) |
| Set the treble amplitude. | |
| int | getBassFrequency (void) |
| Get the bass frequency limit. | |
| void | setBassFrequency (int frequency=DEFAULT_BASS_FREQUENCY) |
| Set the bass frequency limit. | |
| int | getBassAmplitude (void) |
| Get the bass amplitude. | |
| void | setBassAmplitude (int amplitude=DEFAULT_BASS_AMPLITUDE) |
| Set the bass amplitude. | |
| void | setPlaySpeed (unsigned short speed) |
| Set the speed of a playback. | |
| bool | bufferSetByte (char c) |
| Copy a byte into the audio data buffer. | |
| bool | bufferPutStream (const char *s, unsigned int length) |
| Copy a array of bytes into the audio data buffer. | |
| unsigned int | bufferFree (void) |
| Get the free space of the audio data buffer. | |
| unsigned int | bufferCount (void) |
| Get the busy space of the audio data buffer. | |
| unsigned int | bufferLength (void) |
| Complete length of the audio buffer. | |
| void | play (void) |
| Start playing audio from buffer. | |
| void | pause (void) |
| Interrupt the playback. | |
| void | stop (void) |
| Stop the playback in the middle of a song. | |
| void | getAudioInfo (AudioInfo *aInfo) |
| Get information about played audio stream. | |
Detailed Description
Class VS1053.
Class for VS1053 - Ogg Vorbis / MP3 / AAC / WMA / FLAC / MIDI Audio Codec Chip.
Drives VLSI's mp3/midi codec chip.
Datasheet, see http://www.vlsi.fi/fileadmin/datasheets/vlsi/vs1053.pdf
This code based on: mbeduino_MP3_Shield_MP3Player http://mbed.org/users/xshige/programs/mbeduino_MP3_Shield_MP3Player/lgcx63 2010-10-16
For the use of this class, a file "defines.h" must be created. It controls debug output and vs1053 patches.
defines.h:
#ifndef _DEFINES_H #define _DEFINES_H // ---------------------------------------------------------------------------- // debug output // ---------------------------------------------------------------------------- // optional #define DEBUG #ifdef DEBUG # define DEBUGOUT(x,y...) printf(x, ##y); #else # define DEBUGOUT(x,y...) #endif // ---------------------------------------------------------------------------- // VLSI VS1053b library, patch, apps // ---------------------------------------------------------------------------- // optional, ONLY ONE //#define VS1053_PATCH_1_4_FLAC //#define VS1053_PATCH_1_5 #define VS1053_PATCH_1_5_FLAC //#define VS1053_SPECANA //#define VS1053B_PCM_RECORDER_0_9 #endif //_DEFINES_H *
For a complete sample, see http://mbed.org/users/christi_s/programs/Lib_VS1053b
Definition at line 11 of file VS1053.h.
Constructor & Destructor Documentation
| VS1053 | ( | PinName | mosiPin, |
| PinName | misoPin, | ||
| PinName | sckPin, | ||
| PinName | csPin, | ||
| PinName | bsyncPin, | ||
| PinName | dreqPin, | ||
| PinName | rstPin, | ||
| uint32_t | spiFrequency = 1000000 |
||
| ) |
Constructor of class VS1053.
Definition at line 11 of file VS1053.cpp.
| ~VS1053 | ( | ) |
Destructor of class VS1053.
Definition at line 31 of file VS1053.cpp.
| VS1053 | ( | PinName | mosi, |
| PinName | miso, | ||
| PinName | sck, | ||
| PinName | cs, | ||
| PinName | rst, | ||
| PinName | dreq, | ||
| PinName | dcs, | ||
| char * | buffer, | ||
| int | buffer_size | ||
| ) |
Create a vs1053b object.
- Parameters:
-
mosi SPI Master Out, Slave In pin to vs1053b. miso SPI Master In, Slave Out pin to vs1053b. sck SPI Clock pin to vs1053b. cs Pin to vs1053b control chip select. rst Pin to vs1053b reset. dreq Pin to vs1053b data request. dcs Pin to vs1053b data chip select. buffer Array to cache audio data. buffer_size Length of the array.
Definition at line 49 of file /VS1053.cpp.
Member Function Documentation
| unsigned int bufferCount | ( | void | ) |
Get the busy space of the audio data buffer.
- Returns:
- Space 0 .. BUFFER_SIZE - 1.
Definition at line 562 of file /VS1053.cpp.
| unsigned int bufferFree | ( | void | ) |
Get the free space of the audio data buffer.
- Returns:
- Space 0 .. BUFFER_SIZE - 1.
Definition at line 549 of file /VS1053.cpp.
| unsigned int bufferLength | ( | void | ) |
Complete length of the audio buffer.
- Returns:
- Buffer length.
Definition at line 499 of file /VS1053.cpp.
| bool bufferPutStream | ( | const char * | s, |
| unsigned int | length | ||
| ) |
Copy a array of bytes into the audio data buffer.
- Parameters:
-
s Data for the buffer. length Size of data array.
- Returns:
- TRUE on success; FALSE on failure, s isn't copied in the buffer.
Definition at line 532 of file /VS1053.cpp.
| bool bufferSetByte | ( | char | c ) |
Copy a byte into the audio data buffer.
- Parameters:
-
c Data for the buffer.
- Returns:
- TRUE on success; FALSE on failure, c isn't copied in the buffer.
Definition at line 518 of file /VS1053.cpp.
| void clockUp | ( | ) |
Change VS1053's PLL setting for speedup.
Definition at line 71 of file VS1053.cpp.
| void getAudioInfo | ( | AudioInfo * | aInfo ) |
Get information about played audio stream.
- Parameters:
-
aInfo Return value for the informations.
Definition at line 674 of file /VS1053.cpp.
| float getBalance | ( | void | ) |
Get the balance - volume difference between left-right.
- Returns:
- Difference in dB.
Definition at line 385 of file /VS1053.cpp.
| int getBassAmplitude | ( | void | ) |
Get the bass amplitude.
- Returns:
- Amplitude 0 .. 15dB (in 1dB steps); 0 = off.
Definition at line 462 of file /VS1053.cpp.
| int getBassFrequency | ( | void | ) |
Get the bass frequency limit.
- Returns:
- Frequenzy 20, 30, .. 150Hz.
Definition at line 441 of file /VS1053.cpp.
| int getTrebleAmplitude | ( | void | ) |
Get the treble amplitude.
- Returns:
- Amplitude -8 .. 7dB (in 1.5dB steps); 0 = off.
Definition at line 422 of file /VS1053.cpp.
| int getTrebleFrequency | ( | void | ) |
Get the treble frequency limit.
- Returns:
- Frequenzy 1000, 2000 .. 15000Hz.
Definition at line 400 of file /VS1053.cpp.
| float getVolume | ( | void | ) |
| void hardwareReset | ( | ) |
Make a hardware reset by hitting VS1053's RESET pin.
Definition at line 35 of file VS1053.cpp.
| bool initialize | ( | void | ) |
Initialize the vs1053b device.
- Returns:
- TRUE on success, FALSE on failure.
Definition at line 315 of file /VS1053.cpp.
| void pause | ( | void | ) |
Interrupt the playback.
Definition at line 612 of file /VS1053.cpp.
| void play | ( | void | ) |
Start playing audio from buffer.
Definition at line 606 of file /VS1053.cpp.
| void reset | ( | void | ) |
| bool sendCancel | ( | ) |
Send cancel request to VS1053.
- Returns:
- Zero at failure, non-zero at success.
Definition at line 80 of file VS1053.cpp.
| size_t sendDataBlock | ( | uint8_t * | data, |
| size_t | length | ||
| ) |
Send a data block specified as a pointer to VS1053.
- Returns:
- Data length successfully sent.
Definition at line 53 of file VS1053.cpp.
| void sendDataByte | ( | uint8_t | data ) |
Send a data byte to VS1053.
Definition at line 43 of file VS1053.cpp.
| void setBalance | ( | float | balance = DEFAULT_BALANCE_DIFERENCE_LEFT_RIGHT ) |
Set the balance - volume difference between left-right.
- Parameters:
-
balance Difference in dB.
Definition at line 378 of file /VS1053.cpp.
| void setBassAmplitude | ( | int | amplitude = DEFAULT_BASS_AMPLITUDE ) |
Set the bass amplitude.
- Parameters:
-
amplitude Amplitude 0 .. 15dB (in 1dB steps); 0 = off.
Definition at line 467 of file /VS1053.cpp.
| void setBassFrequency | ( | int | frequency = DEFAULT_BASS_FREQUENCY ) |
Set the bass frequency limit.
- Parameters:
-
frequency Frequenzy 20, 30, .. 150Hz.
Definition at line 446 of file /VS1053.cpp.
| void setPlaySpeed | ( | unsigned short | speed ) |
Set the speed of a playback.
- Parameters:
-
speed Speed 0, 1, .. (0, 1 normal speed). Speeds greater 2 are not recommended, buffer must be filled quickly enough.
Definition at line 239 of file /VS1053.cpp.
| void setTrebleAmplitude | ( | int | amplitude = DEFAULT_TREBLE_AMPLITUDE ) |
Set the treble amplitude.
- Parameters:
-
amplitude Amplitude -8 .. 7dB (in 1.5dB steps); 0 = off.
Definition at line 427 of file /VS1053.cpp.
| void setTrebleFrequency | ( | int | frequency = DEFAULT_TREBLE_FREQUENCY ) |
Set the treble frequency limit.
- Parameters:
-
frequency Frequenzy 1000, 2000, .. 15000Hz.
Definition at line 406 of file /VS1053.cpp.
| void setVolume | ( | float | volume = DEFAULT_VOLUME ) |
Set the volume.
- Parameters:
-
volume Volume -0.5dB, -1.0dB, .. -64.0dB.
Definition at line 363 of file /VS1053.cpp.
| void stop | ( | void | ) |
Attempt a termination of playing.
Please call this repeatedly during data stream tramsission until it successes.
- Returns:
- Zero at failure, non-zero at success.
Definition at line 97 of file VS1053.cpp.
| void stop | ( | void | ) |
Stop the playback in the middle of a song.
After this call, you can now send the next audio file to buffer.
| void terminateStream | ( | void | ) |
Stop the playback if the song is completed.
You must call this function for default playback.
Definition at line 245 of file /VS1053.cpp.
Generated on Sun Jul 17 2022 15:50:54 by
1.7.2