ban4jp - / VS1053b_mod

Fork of VS1053b by Christian Schmiljun

Embed: (wiki syntax)

« Back to documentation index

VS1053 Class Reference

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:
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 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:
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 549 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 535 of file VS1053.cpp.

void getAudioInfo ( AudioInfo aInfo )

Get information about played audio stream.

Parameters:
aInfoReturn 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   )

Get the volume.

Returns:
Return the volume in dB.

Definition at line 390 of file VS1053.cpp.

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   )

Reset the vs1053b.

(hardware reset)

Definition at line 123 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 395 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 484 of file VS1053.cpp.

void setBassFrequency ( int  frequency = DEFAULT_BASS_FREQUENCY )

Set the bass frequency limit.

Parameters:
frequencyFrequenzy 20, 30, .. 150Hz.

Definition at line 463 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 255 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 444 of file VS1053.cpp.

void setTrebleFrequency ( int  frequency = DEFAULT_TREBLE_FREQUENCY )

Set the treble frequency limit.

Parameters:
frequencyFrequenzy 1000, 2000, .. 15000Hz.

Definition at line 423 of file VS1053.cpp.

void setVolume ( float  volume = DEFAULT_VOLUME )

Set the volume.

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