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.
Fork of VS1053b by
VS1053 Class Reference
Class for VS1053 - Ogg Vorbis / MP3 / AAC / WMA / FLAC / MIDI Audio Codec Chip. More...
#include <VS1053.h>
Public Member Functions | |
| 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 for VS1053 - Ogg Vorbis / MP3 / AAC / WMA / FLAC / MIDI Audio 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 266 of file VS1053.h.
Constructor & Destructor Documentation
| 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 579 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 566 of file VS1053.cpp.
| unsigned int bufferLength | ( | void | ) |
Complete length of the audio buffer.
- Returns:
- Buffer length.
Definition at line 516 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 549 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 535 of file VS1053.cpp.
| void getAudioInfo | ( | AudioInfo * | aInfo ) |
Get information about played audio stream.
- Parameters:
-
aInfo Return value for the informations.
| float getBalance | ( | void | ) |
Get the balance - volume difference between left-right.
- Returns:
- Difference in dB.
Definition at line 402 of file VS1053.cpp.
| int getBassAmplitude | ( | void | ) |
Get the bass amplitude.
- Returns:
- Amplitude 0 .. 15dB (in 1dB steps); 0 = off.
Definition at line 479 of file VS1053.cpp.
| int getBassFrequency | ( | void | ) |
Get the bass frequency limit.
- Returns:
- Frequenzy 20, 30, .. 150Hz.
Definition at line 458 of file VS1053.cpp.
| int getTrebleAmplitude | ( | void | ) |
Get the treble amplitude.
- Returns:
- Amplitude -8 .. 7dB (in 1.5dB steps); 0 = off.
Definition at line 439 of file VS1053.cpp.
| int getTrebleFrequency | ( | void | ) |
Get the treble frequency limit.
- Returns:
- Frequenzy 1000, 2000 .. 15000Hz.
Definition at line 417 of file VS1053.cpp.
| float getVolume | ( | void | ) |
| bool initialize | ( | void | ) |
Initialize the vs1053b device.
- Returns:
- TRUE on success, FALSE on failure.
Definition at line 331 of file VS1053.cpp.
| void pause | ( | void | ) |
Interrupt the playback.
| void play | ( | void | ) |
Start playing audio from buffer.
| void reset | ( | void | ) |
| 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 395 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 484 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 463 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 255 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 444 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 423 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 380 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 261 of file VS1053.cpp.
Generated on Tue Jul 19 2022 01:19:15 by
1.7.2
