Mateusz Wójcik / Mbed 2 deprecated SISK

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

VS1053 Class Reference

VS1053 Class Reference

Class VS1053. More...

#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:
mosiSPI Master Out, Slave In pin to vs1053b.
misoSPI Master In, Slave Out pin to vs1053b.
sckSPI Clock pin to vs1053b.
csPin to vs1053b control chip select.
rstPin to vs1053b reset.
dreqPin to vs1053b data request.
dcsPin to vs1053b data chip select.
bufferArray to cache audio data.
buffer_sizeLength 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:
sData for the buffer.
lengthSize 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:
cData 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:
aInfoReturn 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   )

Get the volume.

Returns:
Return the volume in dB.

Definition at line 373 of file /VS1053.cpp.

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   )

Reset the vs1053b.

(hardware reset)

Definition at line 107 of file /VS1053.cpp.

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:
balanceDifference in dB.

Definition at line 378 of file /VS1053.cpp.

void setBassAmplitude ( int  amplitude = DEFAULT_BASS_AMPLITUDE )

Set the bass amplitude.

Parameters:
amplitudeAmplitude 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:
frequencyFrequenzy 20, 30, .. 150Hz.

Definition at line 446 of file /VS1053.cpp.

void setPlaySpeed ( unsigned short  speed )

Set the speed of a playback.

Parameters:
speedSpeed 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:
amplitudeAmplitude -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:
frequencyFrequenzy 1000, 2000, .. 15000Hz.

Definition at line 406 of file /VS1053.cpp.

void setVolume ( float  volume = DEFAULT_VOLUME )

Set the volume.

Parameters:
volumeVolume -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.