RecordWav Class

RecordWav Class

Description
A class used for control and recording of .wav file format audio data.

Syntax
class RecordWav

Members

Public Constructors 
RecordWav::RecordWavConstructs and initializes a RecordWav class object.
Public Methods 
RecordWav::openFileOpen a .wav audio file for recording.
RecordWav::closeFileClose a previously opened audio file.
RecordWav::fileOpenedCheck if a .wav file is already opened.
RecordWav::setSampleRateSet the recording sample rate of the .wav file.
RecordWav::setChannelCountSet the number of audio channels in the .wav file.
RecordWav::setBitDepthSet the bit depth of each sample in the .wav file.
RecordWav::getLengthMillisGet the current length of the recorded .wav file in milliseconds.
RecordWav::millisToBytesConvert a playback duration from milliseconds to bytes.
RecordWav::bytesToMillisConvert a playback duration from bytes to milliseconds.
RecordWav::writeAudioDataWrite audio data to the .wav file.

RecordWav::RecordWav

Description
Constructs a RecordWav class object.

Syntax
void RecordWav(void);

Parameters
NA

Returns
NA

Example Code
Example: RecordWavFile
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/AudioCodec/examples/RecordWavFile/RecordWavFile.ino)

Notes and Warnings
“RecordWav.h” must be included to use the class function.

RecordWav::openFile

Description
Open a .wav audio file for recording.

Syntax
void openFile(const char* absFilepath);

Parameters
absFilepath: The absolute filepath of the .wav file that to be opened.

Returns
NA

Example Code
Example: RecordWavFile
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/AudioCodec/examples/RecordWavFile/RecordWavFile.ino)

Notes and Warnings
“RecordWav.h” must be included to use the class function.

RecordWav::closeFile

Description
Close a previously opened audio file.

Syntax
void closeFile(void);

Parameters
NA

Returns
NA

Example Code
Example: RecordWavFile
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/AudioCodec/examples/RecordWavFile/RecordWavFile.ino)

Notes and Warnings
After recording is complete, any open.wav files should be closed; otherwise, recorded audio data may be lost.
“RecordWav.h” must be included to use the class function.

RecordWav::fileOpened

Description
Check if a .wav file is already opened.

Syntax
bool fileOpened(void);

Parameters
NA

Returns
This function returns true if a .wav file is already open, false otherwise.

Example Code
Example: RecordWavFile
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/AudioCodec/examples/RecordWavFile/RecordWavFile.ino)

Notes and Warnings
“RecordWav.h” must be included to use the class function.

RecordWav::setSampleRate

Description
Set the recording sample rate of the .wav file.

Syntax
void setSampleRate(uint32_t sampleRate);

Parameters
sampleRate: recording sample rate.

Returns
NA

Example Code
Example: RecordWavFile
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/AudioCodec/examples/RecordWavFile/RecordWavFile.ino)

Notes and Warnings
“RecordWav.h” must be included to use the class function.

RecordWav::setChannelCount

Description
Set the number of recording audio channels in the .wav file.

Syntax
void setChannelCount(uint16_t channelCount);

Parameters
channelCount: number of recording audio channels.

Returns
NA

Example Code
NA

Notes and Warnings
“RecordWav.h” must be included to use the class function.

RecordWav::setBitDepth

Description
Set the recording bit depth of each sample in the .wav file.

Syntax
void setBitDepth(uint16_t bitDepth);

Parameters
bitDepth: number of bits per sample.

Returns
NA

Example Code
NA

Notes and Warnings
“RecordWav.h” must be included to use the class function.

RecordWav::getLengthMillis

Description
Get the current length of the recorded .wav file in milliseconds.

Syntax
uint32_t getLengthMillis(void);

Parameters
NA

Returns
This function returns the current length of the recorded .wav file in milliseconds.

Example Code
NA

Notes and Warnings
“RecordWav.h” must be included to use the class function.

RecordWav::millisToBytes

Description
Convert a playback duration from milliseconds to bytes.

Syntax
uint32_t millisToBytes(uint32_t ms);

Parameters
ms: playback duration in milliseconds.

Returns
This function returns the number of bytes that is equivalent to the input playback duration in ms, converted using the current sample rate, number of channels and bit depth.

Example Code
NA

Notes and Warnings
“RecordWav.h” must be included to use the class function.

RecordWav::bytesToMillis

Description
Convert a playback duration from bytes to milliseconds.

Syntax
uint32_t bytesToMillis(uint32_t bytes);

Parameters
bytes: playback duration in number of bytes.

Returns
This function returns the time duration in milliseconds that is equivalent to the input number of bytes, converted using the current sample rate, number of channels and bit depth.

Example Code
NA

Notes and Warnings
“RecordWav.h” must be included to use the class function.

RecordWav::writeAudioData

Description
Write audio data to the .wav file.

Syntax
uint32_t writeAudioData(int8_t* src, uint32_t len);
uint32_t writeAudioData(int16_t* src, uint32_t len);

Parameters
src: pointer to array containing data to write to .wav file.
len: number of audio samples to write to .wav file.

Returns
The function returns number of audio samples written to the .wav file.

Example Code
Example: RecordWavFile
(https://github.com/ambiot/ambd_arduino/blob/dev/Arduino_package/hardware/libraries/AudioCodec/examples/RecordWavFile/RecordWavFile.ino)

Notes and Warnings
“RecordWav.h” must be included to use the class function.

Copyrights ©瑞晟微电子(苏州)有限公司 2021. All rights reserved. 使用條款
請先確認已安裝QQ通訊軟體