Developer World
Spresense Arduino Library v3.2.0-77d75a4
AudioClass Class Reference

Audio Library Class Definitions. More...

#include <Audio.h>

Public Types

enum  PlayerId { Player0 , Player1 }
 Audio library allows you to use two players simultaneously. Please set Player ID that player instance id created to use. More...
 
enum  ThroughInput { MicIn , I2sIn , BothIn }
 Input select parameter at baseband through mode. More...
 
enum  ThroughI2sOut { None , Mixer , Mic }
 I2S output select parameter at baseband through mode. More...
 

Public Member Functions

err_t begin (void)
 Initialize the audio library and HW modules. More...
 
err_t begin (AudioAttentionCb attcb)
 Initialize the audio library and HW modules. More...
 
err_t end (void)
 Finalization the audio library and HW modules. More...
 
err_t setPlayerMode (uint8_t device)
 Set Audio Library Mode to Music Player. More...
 
err_t setPlayerMode (uint8_t device, uint32_t player0bufsize, uint32_t player1bufsize)
 Set Audio Library Mode to Music Player. More...
 
err_t setPlayerMode (uint8_t device, uint8_t sp_drv)
 Set Audio Library Mode to Music Player. More...
 
err_t setPlayerMode (uint8_t device, uint8_t sp_drv, uint32_t player0bufsize, uint32_t player1bufsize)
 Set Audio Library Mode to Music Player. More...
 
err_t setRecorderMode (uint8_t input_device)
 Set Audio Library Mode to Sound Recorder. More...
 
err_t setRecorderMode (uint8_t input_device, int32_t input_gain)
 Set Audio Library Mode to Sound Recorder. More...
 
err_t setRecorderMode (uint8_t input_device, int32_t input_gain, uint32_t bufsize)
 Set Audio Library Mode to Sound Recorder. More...
 
err_t setRecorderMode (uint8_t input_device, int32_t input_gain, uint32_t bufsize, bool is_digital)
 Set Audio Library Mode to Sound Recorder. More...
 
err_t setThroughMode (ThroughInput input, ThroughI2sOut i2s_out, bool sp_out, int32_t input_gain, uint8_t sp_drv)
 Set Audio Library Mode to BaseBand Through. More...
 
err_t setReadyMode (void)
 Set Audio Library Mode to Ready. More...
 
err_t initPlayer (PlayerId id, uint8_t codec, uint32_t fs, uint8_t channel)
 Initialize player. More...
 
err_t initPlayer (PlayerId id, uint8_t codec, uint32_t fs, uint8_t bitlen, uint8_t channel)
 Initialize player. More...
 
err_t initPlayer (PlayerId id, uint8_t codec, const char *codec_path, uint32_t fs, uint8_t channel)
 Initialize player. More...
 
err_t initPlayer (PlayerId id, uint8_t codec, const char *codec_path, uint32_t fs, uint8_t bitlen, uint8_t channel)
 Initialize player. More...
 
err_t initRecorder (uint8_t codec, uint32_t fs, uint8_t channel)
 Initialize recorder. More...
 
err_t initRecorder (uint8_t codec, uint32_t fs, uint8_t bitlen, uint8_t channel)
 Initialize recorder. More...
 
err_t initRecorder (uint8_t codec, const char *codec_path, uint32_t fs, uint8_t channel)
 Initialize recorder. More...
 
err_t initRecorder (uint8_t codec, const char *codec_path, uint32_t fs, uint8_t bitlen, uint8_t channel)
 Initialize recorder. More...
 
err_t startPlayer (PlayerId id)
 Start Player. More...
 
err_t startRecorder (void)
 Start Recorder. More...
 
err_t stopPlayer (PlayerId id)
 Stop Player. More...
 
err_t stopPlayer (PlayerId id, uint8_t mode)
 Stop Player (mode specified) More...
 
err_t stopRecorder (void)
 Stop Recorder. More...
 
err_t setBeep (char enable, short volume, short frequency)
 Set Beep Sound. More...
 
err_t setVolume (int volume)
 Set Player Volume. More...
 
err_t setVolume (int master, int player0, int player1)
 Set Player Volume. More...
 
err_t setLRgain (PlayerId id, unsigned char l_gain, unsigned char r_gain)
 Set Player L/R Gain. More...
 
err_t writeFrames (PlayerId id, File &myfile)
 Write Stream Data from a file to FIFO by some frames.(now 5 frames) More...
 
err_t writeFrames (PlayerId id, int fd)
 Write Stream Data from a file to FIFO by some frames.(now 5 frames) More...
 
err_t writeFrames (PlayerId id, uint8_t *data, uint32_t write_size)
 Write Stream Data from buffer. More...
 
err_t writeWavHeader (File &myFile)
 Write WAV Header. More...
 
err_t readFrames (File &myFile)
 Read Stream Data from FIFO to a file by some frames.(now 5 frames) More...
 
err_t closeOutputFile (File &myFile)
 Close Outputfile. More...
 
err_t readFrames (char *p_buffer, uint32_t buffer_size, uint32_t *read_size)
 Read Stream Data from FIFO to a file by some frames.(now 5 frames) More...
 
err_t setRenderingClockMode (AsClkMode mode)
 Set Rendering clock mode. More...
 
int getRecordingSize ()
 Get recording ES size. More...
 

Static Public Member Functions

static AudioClassgetInstance ()
 Get instance of AudioClass for singleton.
 

Detailed Description

Audio Library Class Definitions.

Member Enumeration Documentation

◆ PlayerId

Audio library allows you to use two players simultaneously. Please set Player ID that player instance id created to use.

Enumerator
Player0 

Indicates Player0

Player1 

Indicates Player1

◆ ThroughInput

Input select parameter at baseband through mode.

Enumerator
MicIn 

Use Microphone only.

I2sIn 

Use I2S input only.

BothIn 

Use Microphone and I2S input.

◆ ThroughI2sOut

I2S output select parameter at baseband through mode.

Enumerator
None 

I2S Output is nothing.

Mixer 

I2S Output is Mixer output data.

Mic 

I2S Output is Microphone.

Member Function Documentation

◆ begin() [1/2]

err_t AudioClass::begin ( void  )

Initialize the audio library and HW modules.

This function is called only once when using the Audio library. In this function, initialization of required shared memory management library, initialization of inter-task communication library, Initialize Audio MW, initialize FIFO for ES supply, set callback at error occurrence, etc.

If you call it more than once, an error occurs, but if you call "end ()" you need to call this function again.

◆ begin() [2/2]

err_t AudioClass::begin ( AudioAttentionCb  attcb)

Initialize the audio library and HW modules.

This function can set callback funtion which receive attention notify.

◆ end()

err_t AudioClass::end ( void  )

Finalization the audio library and HW modules.

This function is called when you want to exit the Audio library. In this function, necessary termination processing of the shared memory management library, end processing of the inter-task communication library, end processing of Audio MW, destruction of FIFO for ES supply, clearing of callback setting at error occurrence, etc.

This can only be called once when activated. If you call it before calling "begin ()" or call it more than once, an error occurs.

◆ setPlayerMode() [1/4]

err_t AudioClass::setPlayerMode ( uint8_t  device)

Set Audio Library Mode to Music Player.

This function switches the mode of the Audio library to Music Player. For mode details, follow the state transition chart on the developer guide.

This function cannot be called after transition to "Music Player mode". To return to the original state, please call setReadyMode ().

In this function, setting HW necessary for music playback, and setting ES buffer configuration etc.

Parameters
deviceSelect output device. AS_SETPLAYER_OUTPUTDEVICE_SPHP or AS_SETPLAYER_OUTPUTDEVICE_I2SOUTPUT.

◆ setPlayerMode() [2/4]

err_t AudioClass::setPlayerMode ( uint8_t  device,
uint32_t  player0bufsize,
uint32_t  player1bufsize 
)

Set Audio Library Mode to Music Player.

This API has same function as setPlayerMode(device). But you can set buffer size of players.

Parameters
deviceSelect output device. AS_SETPLAYER_OUTPUTDEVICE_SPHP or AS_SETPLAYER_OUTPUTDEVICE_I2SOUTPUT.
player0bufsizeBuffer size of player 0. Must be n > 0.
player1bufsizeBuffer size of player 1. Must be n > 0.

◆ setPlayerMode() [3/4]

err_t AudioClass::setPlayerMode ( uint8_t  device,
uint8_t  sp_drv 
)

Set Audio Library Mode to Music Player.

This function works as same as "setPlayerMode(uint8_t)", but you are able to set speaker drive mode by parameter "sp_drv". If you would like to set speaker drive mode, use this API instead of setPlayerMode(uint8_t).

Parameters
deviceSelect output device. AS_SETPLAYER_OUTPUTDEVICE_SPHP or AS_SETPLAYER_OUTPUTDEVICE_I2SOUTPUT.
sp_drvSelect audio speaker driver mode. AS_SP_DRV_MODE_LINEOUT or AS_SP_DRV_MODE_1DRIVER or AS_SP_DRV_MODE_2DRIVER or AS_SP_DRV_MODE_4DRIVER

◆ setPlayerMode() [4/4]

err_t AudioClass::setPlayerMode ( uint8_t  device,
uint8_t  sp_drv,
uint32_t  player0bufsize,
uint32_t  player1bufsize 
)

Set Audio Library Mode to Music Player.

This API has same function as setPlayerMode(device, sp_drv). But you can set buffer size of players.

Parameters
deviceSelect output device. AS_SETPLAYER_OUTPUTDEVICE_SPHP or AS_SETPLAYER_OUTPUTDEVICE_I2SOUTPUT.
sp_drvSelect audio speaker driver mode. AS_SP_DRV_MODE_LINEOUT or AS_SP_DRV_MODE_1DRIVER or AS_SP_DRV_MODE_2DRIVER or AS_SP_DRV_MODE_4DRIVER
player0bufsizeBuffer size of player 0. Must be n > 0.
player1bufsizeBuffer size of player 1. Must be n > 0.

◆ setRecorderMode() [1/4]

err_t AudioClass::setRecorderMode ( uint8_t  input_device)

Set Audio Library Mode to Sound Recorder.

This function switches the mode of the Audio library to Sound Recorder. For mode details, follow the state transition chart on the developer guide.

This function cannot be called after transition to "Sound Recorder mode". To return to the original state, please call setReadyMode ().

In this function, setting HW necessary for sound recording, and setting ES buffer configuration etc.

The type of MIC is determined by configuration of sdk. The default is an analog microphone. The value of CXD56_AUDIO_MIC_CHANNEL_SEL can be used to select the analog microphone or digital microphone and assign the microphone channel. Refer to the document for the setting value. If you change the settings, import sdk again.

Recording Mic-gain is 0dB fixed.

Parameters
input_deviceSet AS_SETRECDR_STS_INPUTDEVICE_MIC.

◆ setRecorderMode() [2/4]

err_t AudioClass::setRecorderMode ( uint8_t  input_device,
int32_t  input_gain 
)

Set Audio Library Mode to Sound Recorder.

This function works as same as "setRecorderMode(uint8_t)", but you are able to set Mic-gain by parameter "mic_gain". If you would like to set recording mic-gain, use this API instead of setRecorderMode(uint8_t).

Parameters
input_deviceSet AS_SETRECDR_STS_INPUTDEVICE_MIC.
input_gainInput gain : value range Analog Mic 0:0dB, 5:+0.5dB, ... , 210:+21.0dB (Max is 21dB.) Digital Mic -7850:-78.50dB, ... , -5:-0.05dB, 0:0dB (Max is 0dB.) set #AS_MICGAIN_HOLD is keep setting.

◆ setRecorderMode() [3/4]

err_t AudioClass::setRecorderMode ( uint8_t  input_device,
int32_t  input_gain,
uint32_t  bufsize 
)

Set Audio Library Mode to Sound Recorder.

This function works as same as "setRecorderMode(input_device, input_gain)", But you can set buffer size of recorder.

Parameters
input_deviceSet AS_SETRECDR_STS_INPUTDEVICE_MIC.
input_gainInput gain : value range Analog Mic 0:0dB, 5:+0.5dB, ... , 210:+21.0dB (Max is 21dB.) Digital Mic -7850:-78.50dB, ... , -5:-0.05dB, 0:0dB (Max is 0dB.) set #AS_MICGAIN_HOLD is keep setting.
bufsizeBuffer size of recorder.

◆ setRecorderMode() [4/4]

err_t AudioClass::setRecorderMode ( uint8_t  input_device,
int32_t  input_gain,
uint32_t  bufsize,
bool  is_digital 
)

Set Audio Library Mode to Sound Recorder.

This function works as same as "setRecorderMode(input_device, input_gain, bufsize)", But you can set buffer size of recorder.

Parameters
input_deviceSet AS_SETRECDR_STS_INPUTDEVICE_MIC.
input_gainInput gain : value range Analog Mic 0:0dB, 5:+0.5dB, ... , 210:+21.0dB (Max is 21dB.) Digital Mic -7850:-78.50dB, ... , -5:-0.05dB, 0:0dB (Max is 0dB.) set #AS_MICGAIN_HOLD is keep setting.
bufsizeBuffer size of recorder.
is_digitalSelect mic type. true:Digital, false:Analog.

◆ setThroughMode()

err_t AudioClass::setThroughMode ( ThroughInput  input,
ThroughI2sOut  i2s_out,
bool  sp_out,
int32_t  input_gain,
uint8_t  sp_drv 
)

Set Audio Library Mode to BaseBand Through.

This function switches the mode of the Audio library to the Baseband through state. (For low power, low latency, small memory)

    For mode details, follow the state transition chart on the developer guide.

    You can chose input and I2S output data, but speaker output is always mixer data.
    And, in this mode, output starts as soon as the state changes.

    This function cannot be called after transition to "BaseBand Through mode".
    To return to the original state, please call setReadyMode ().
Parameters
inputSet input source. Use ThroughInput enum type.
i2s_outSet I2S output source. Use ThroughI2sOut enum type.
sp_outsp_out : Use speaker output.
input_gainInput gain : value range Analog Mic 0:0dB, 5:+0.5dB, ... , 210:+21.0dB (Max is 21dB.) Digital Mic -7850:-78.50dB, ... , -5:-0.05dB, 0:0dB (Max is 0dB.) set #AS_MICGAIN_HOLD is keep setting.
sp_drvSelect audio speaker driver mode. AS_SP_DRV_MODE_LINEOUT or AS_SP_DRV_MODE_1DRIVER or AS_SP_DRV_MODE_2DRIVER or AS_SP_DRV_MODE_4DRIVER

◆ setReadyMode()

err_t AudioClass::setReadyMode ( void  )

Set Audio Library Mode to Ready.

This function switches the mode of the Audio library to the initial state. For mode details, follow the state transition chart on the developer guide.

This function cannot be called after transition to "Ready mode". Immediately after boot, it is in Ready mode.

In this function, we will release resources which used in each mode, change HW to the standby state, etc.

◆ initPlayer() [1/4]

err_t AudioClass::initPlayer ( PlayerId  id,
uint8_t  codec,
uint32_t  fs,
uint8_t  channel 
)

Initialize player.

This function initializes and sets Player action. When player do not play music, you can call it as many times as you like.

By this function,

  • Compression codec
  • Sampling rate
  • Number of channels You need to set.

If you would like to set codec binary path and bit length of audio data, You are able to set them by other type of this API. Default values of them are /mnt/sd0/BIN and AS_BITLENGTH_16(16bit).

Parameters
idSelect Player ID.
codecSelect compression code. AS_CODECTYPE_MP3 or AS_CODECTYPE_WAV
fsSet sampling rate. AS_SAMPLINGRATE_XXXXX.
channelSet channnel number. AS_CHANNEL_MONO or AS_CHANNEL_STEREO

◆ initPlayer() [2/4]

err_t AudioClass::initPlayer ( PlayerId  id,
uint8_t  codec,
uint32_t  fs,
uint8_t  bitlen,
uint8_t  channel 
)

Initialize player.

This function initializes and sets Player action. When player do not play music, you can call it as many times as you like.

By this function,

  • Compression codec
  • Sampling rate
  • Number of channels You need to set.

If you would like to set codec binary path and bit length of audio data, You are able to set them by other type of this API. Default values of them are /mnt/sd0/BIN and AS_BITLENGTH_16(16bit).

Parameters
idSelect Player ID.
codecSelect compression code. AS_CODECTYPE_MP3 or AS_CODECTYPE_WAV
fsSet sampling rate. AS_SAMPLINGRATE_XXXXX.
bitlenSet bit length. AS_BITLENGTH_16 or AS_BITLENGTH_24
channelSet channnel number. AS_CHANNEL_MONO or AS_CHANNEL_STEREO

◆ initPlayer() [3/4]

err_t AudioClass::initPlayer ( PlayerId  id,
uint8_t  codec,
const char *  codec_path,
uint32_t  fs,
uint8_t  channel 
)

Initialize player.

This function initializes and sets Player action. When player do not play music, you can call it as many times as you like.

By this function,

  • Compression codec
  • Sampling rate
  • Number of channels You need to set.

If you would like to set codec binary path and bit length of audio data, You are able to set them by other type of this API. Default values of them are /mnt/sd0/BIN and AS_BITLENGTH_16(16bit).

Parameters
idSelect Player ID.
codecSelect compression code. AS_CODECTYPE_MP3 or AS_CODECTYPE_WAV
codec_pathSet DSP Binary path. Maximum length is 24 bytes.
fsSet sampling rate. AS_SAMPLINGRATE_XXXXX.
channelSet channnel number. AS_CHANNEL_MONO or AS_CHANNEL_STEREO

◆ initPlayer() [4/4]

err_t AudioClass::initPlayer ( PlayerId  id,
uint8_t  codec,
const char *  codec_path,
uint32_t  fs,
uint8_t  bitlen,
uint8_t  channel 
)

Initialize player.

This function initializes and sets Player action. When player do not play music, you can call it as many times as you like.

By this function,

  • Compression codec
  • Sampling rate
  • Number of channels You need to set.

If you would like to set codec binary path and bit length of audio data, You are able to set them by other type of this API. Default values of them are /mnt/sd0/BIN and AS_BITLENGTH_16(16bit).

Parameters
idSelect Player ID.
codecSelect compression code. AS_CODECTYPE_MP3 or AS_CODECTYPE_WAV
codec_pathSet DSP Binary path. Maximum length is 24 bytes.
fsSet sampling rate. AS_SAMPLINGRATE_XXXXX.
bitlenSet bit length. AS_BITLENGTH_16 or AS_BITLENGTH_24
channelSet channnel number. AS_CHANNEL_MONO or AS_CHANNEL_STEREO

◆ initRecorder() [1/4]

err_t AudioClass::initRecorder ( uint8_t  codec,
uint32_t  fs,
uint8_t  channel 
)

Initialize recorder.

This function initializes and sets Recorder action. When recorder do not start, you can call it as many times as you like.

By this function,

  • Compression codec
  • Sampling rate
  • Number of channels You need to set.

If you would like to set codec binary path and bit length of audio data, You are able to set them by other type of this API. Default values of them are /mnt/sd0/BIN and AS_BITLENGTH_16(16bit).

Parameters
codecSelect compression code. AS_CODECTYPE_MP3 or AS_CODECTYPE_WAV
fsSet sampling rate. AS_SAMPLINGRATE_XXXXX.
channelSet channnel number. AS_CHANNEL_MONO, AS_CHANNEL_STEREO, AS_CHANNEL_4CH, or etc...

◆ initRecorder() [2/4]

err_t AudioClass::initRecorder ( uint8_t  codec,
uint32_t  fs,
uint8_t  bitlen,
uint8_t  channel 
)

Initialize recorder.

This function initializes and sets Recorder action. When recorder do not start, you can call it as many times as you like.

By this function,

  • Compression codec
  • Sampling rate
  • Number of channels You need to set.

If you would like to set codec binary path and bit length of audio data, You are able to set them by other type of this API. Default values of them are /mnt/sd0/BIN and AS_BITLENGTH_16(16bit).

Parameters
codecSelect compression code. AS_CODECTYPE_MP3 or AS_CODECTYPE_WAV
fsSet sampling rate. AS_SAMPLINGRATE_XXXXX.
bitlenSet bit length. AS_BITLENGTH_16 or AS_BITLENGTH_24
channelSet channnel number. AS_CHANNEL_MONO, AS_CHANNEL_STEREO, AS_CHANNEL_4CH, or etc...

◆ initRecorder() [3/4]

err_t AudioClass::initRecorder ( uint8_t  codec,
const char *  codec_path,
uint32_t  fs,
uint8_t  channel 
)

Initialize recorder.

This function initializes and sets Recorder action. When recorder do not start, you can call it as many times as you like.

By this function,

  • Compression codec
  • Sampling rate
  • Number of channels You need to set.

If you would like to set codec binary path and bit length of audio data, You are able to set them by other type of this API. Default values of them are /mnt/sd0/BIN and AS_BITLENGTH_16(16bit).

Parameters
codecSelect compression code. AS_CODECTYPE_MP3 or AS_CODECTYPE_WAV
codec_pathSet DSP Binary path. Maximum length is 24 bytes.
fsSet sampling rate. AS_SAMPLINGRATE_XXXXX.
channelSet channnel number. AS_CHANNEL_MONO, AS_CHANNEL_STEREO, AS_CHANNEL_4CH, or etc...

◆ initRecorder() [4/4]

err_t AudioClass::initRecorder ( uint8_t  codec,
const char *  codec_path,
uint32_t  fs,
uint8_t  bitlen,
uint8_t  channel 
)

Initialize recorder.

This function initializes and sets Recorder action. When recorder do not start, you can call it as many times as you like.

By this function,

  • Compression codec
  • Sampling rate
  • Number of channels You need to set.

If you would like to set codec binary path and bit length of audio data, You are able to set them by other type of this API. Default values of them are /mnt/sd0/BIN and AS_BITLENGTH_16(16bit).

Parameters
codecSelect compression code. AS_CODECTYPE_MP3 or AS_CODECTYPE_WAV
codec_pathSet DSP Binary path. Maximum length is 24 bytes.
fsSet sampling rate. AS_SAMPLINGRATE_XXXXX.
bitlenSet bit length. AS_BITLENGTH_16 or AS_BITLENGTH_24
channelSet channnel number. AS_CHANNEL_MONO, AS_CHANNEL_STEREO, AS_CHANNEL_4CH, or etc...

◆ startPlayer()

err_t AudioClass::startPlayer ( PlayerId  id)

Start Player.

This function starts Player. Once you call this function, the Player will be in the active state, so you can not call it until you call StopPlayer.

When Player is started, it starts reading the data for the Access Unit[ from the stream data buffer. Therefore, in order to start Player, it is necessary to supply Stream Data to the stream buffer beforehand. Be sure to call writeFrames before startPlay. If you execute without calling * writeFrames, ES_UNDER_FLOW_ERR will be occurs.

Parameters
idSelect Player ID.

◆ startRecorder()

err_t AudioClass::startRecorder ( void  )

Start Recorder.

This function starts Recorder. Once you call this function, the Recorder will be in the active state, so you can not call it until you call StopRecorder. And, in the case of WAV data, it is necessary to create a Wav Header at the beginning of the file, you need to call writeWavHeader function at first.

◆ stopPlayer() [1/2]

err_t AudioClass::stopPlayer ( PlayerId  id)

Stop Player.

This function stops Player. The function can be called only when called startPlayer and changed to the Playing state.

When stop player, it read Stream Data until the last frame, and stops. The next API will not be accepted until the audio output stops completely. (it takes about 100 ms).

Parameters
idSelect Player ID.

◆ stopPlayer() [2/2]

err_t AudioClass::stopPlayer ( PlayerId  id,
uint8_t  mode 
)

Stop Player (mode specified)

This function stops Player with specified mode.

     You can set stop mode. If you would like to stop player immediately,
     set mode to AS_STOPPLAYER_NORMAL. If you don't set mode, player stops
     after all of audio data in buffer is going out.
Parameters
idSelect Player ID.
modeStop mode. AS_STOPPLAYER_NORMAL, AS_STOPPLAYER_ESEND

◆ stopRecorder()

err_t AudioClass::stopRecorder ( void  )

Stop Recorder.

This function stops Recorder. The function can be called only when called startRecorder and changed to the Recording state.

When stop the Recorder, stop the audio capture and write until the last captured audio data. If this function return, the recording process had ended.

◆ setBeep()

err_t AudioClass::setBeep ( char  enable,
short  volume,
short  frequency 
)

Set Beep Sound.

This function sets beep sound. Beep sound On / Off, volume, pitch (frequency) can be configured. It can call on PlayerMode or ReadyMode status.

Parameters
enableSet beep sound On/Off. enable(On) = 1, disable(Off) = 0.
volumeSet beep sound volume. -90(db) - 0(db) can be set. 0db is Maximum amplitude.
frequencySet beep sound. frequency (pitch). Set the frequency value as it is. (example, 1000 is 1kHz sound)

◆ setVolume() [1/2]

err_t AudioClass::setVolume ( int  volume)

Set Player Volume.

This function can set the volume when playing the player. It can be called on PlayerMode.

Parameters
volumeSet the master volume. Range of volume is -1020(-102db) - 120(12db). A value larger than 0 may distort the sound.

◆ setVolume() [2/2]

err_t AudioClass::setVolume ( int  master,
int  player0,
int  player1 
)

Set Player Volume.

This function can set the volume when playing the player. It can be called on PlayerMode.

Parameters
masterSet the master volume. Range of volume is -1020(-102db) - 120(12db). A value larger than 0 may distort the sound.
player0Set the player0 volume. Range of volume is -1020(-102db) - 120(12db). This value is before Mixing.
player1Set the player1 volume. Range of volume is -1020(-102db) - 120(12db). This value is before Mixing.

◆ setLRgain()

err_t AudioClass::setLRgain ( PlayerId  id,
unsigned char  l_gain,
unsigned char  r_gain 
)

Set Player L/R Gain.

This function can set the Left and Right channel gain for Player playback. It can be executed with PlayerMode. If you do not call this, the sound is original.

Parameters
idSelect Player ID.
l_gainSet left gain. 0(%) - 200(%) can be set. 100% is orignal and a value larger than 100 may distort the sound.
r_gainSet right gain. 0(%) - 200(%) can be set. 100% is orignal and a value larger than 100 may distort the sound.

◆ writeFrames() [1/3]

err_t AudioClass::writeFrames ( PlayerId  id,
File myfile 
)

Write Stream Data from a file to FIFO by some frames.(now 5 frames)

APIs for Player Mode

This function writes from the audio file specified by the File class to the Stream data FIFO in the Audio library. It writes for several frames data (now five frames). It can be called on PlayerMode.

This FIFO is cleared when calling StopPlayer or setReadyMode.

During music playback, please call this function periodically. When an error occurs, you should error handling as properly

Parameters
idSelect Player ID.
myfileSpecify an instance of the File class of the audio file.

◆ writeFrames() [2/3]

err_t AudioClass::writeFrames ( PlayerId  id,
int  fd 
)

Write Stream Data from a file to FIFO by some frames.(now 5 frames)

This function writes from the audio file specified by the File class to the Stream data FIFO in the Audio library. It writes for several frames data (now five frames). It can be called on PlayerMode.

This FIFO is cleared when calling StopPlayer or setReadyMode.

During music playback, please call this function periodically. When an error occurs, you should error handling as properly

Parameters
idSelect Player ID.
fdfile pointer of the audio file.

◆ writeFrames() [3/3]

err_t AudioClass::writeFrames ( PlayerId  id,
uint8_t *  data,
uint32_t  write_size 
)

Write Stream Data from buffer.

This function writes from the buffer to the Stream data FIFO in the Audio library. It writes for several frames data (now five frames). It can be called on PlayerMode.

This FIFO is cleared when calling StopPlayer or setReadyMode.

During music playback, please call this function periodically. When an error occurs, you should error handling as properly

Parameters
dataSelect Player ID.
write_sizeBuffer address of the audio data. Size of the audio data.

◆ writeWavHeader()

err_t AudioClass::writeWavHeader ( File myFile)

Write WAV Header.

APIs for Recorder Mode

This function should call when file format is WAV file recording. When codec of InitRecoder is "wav", be sure to call it before StartRecoder. Do not call it if other codecs are selected.

Parameters
myFileSpecify an instance of the File class of the audio file.

◆ readFrames() [1/2]

err_t AudioClass::readFrames ( File myFile)

Read Stream Data from FIFO to a file by some frames.(now 5 frames)

This function reads the generated Stream data from the Stream FIFO into the file specified by the File class. It reads for several frames data (now five frames). It can be called on RecorderMode.

During sound recording, please call this function periodically.

Parameters
myFileSpecify an instance of the File class of the audio file.

◆ closeOutputFile()

err_t AudioClass::closeOutputFile ( File myFile)

Close Outputfile.

This function do closing processing on the file in which stream is written. Be sure to call it after calling StopRecorder. It can be called on RecorderMode.

Parameters
myFileSpecify an instance of the File class of the audio file.

◆ readFrames() [2/2]

err_t AudioClass::readFrames ( char *  p_buffer,
uint32_t  buffer_size,
uint32_t *  read_size 
)

Read Stream Data from FIFO to a file by some frames.(now 5 frames)

This function reads the generated Stream data from the Stream FIFO into the specified buffer area.

This function is for you want to process sounds in applications.

It reads for several frames data (now five frames). It can be called on RecorderMode.

During sound recording, please call this function periodically.

Parameters
p_bufferAddress of buffer area.
buffer_sizeBuffer size.(byte)
read_sizeRead size.(byte)

◆ setRenderingClockMode()

err_t AudioClass::setRenderingClockMode ( AsClkMode  mode)

Set Rendering clock mode.

This function sets the internal data rate mode of rendering to Normal or High Resolution.

The internal data rate Normal indicates "fs = 48 kHz" and High Resolution indicates "fs = 192 kHz".

Please call the function in Ready Mode. Ready Mode is either after calling bigin () or after calling setReadyMode ().

The default when not calling is Normal.

Parameters
modeMode of rendering clock.

◆ getRecordingSize()

int AudioClass::getRecordingSize ( )
inline

Get recording ES size.

This function gets recording elementary stream size.


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