SoundData Object¶
SoundData is a class that allows provide more information about the audio data that you want to play or that is recorded from the robot.
Attributes¶
Data: Unsigned char array (0-255) containing the audio information.
Channels: number of data channels.
Sample rate: the number of samples taken per second.
Sample format: for raw, information about bytes configuration (see Constants).
Coding format: data format (MP3,WAV,PCM). PCM is used for raw.
Constants¶
Raw format (PCM) allowed:
Sample format by width (Used for PCM format)¶
With the number of bytes used to represent a sample, it’s possible obtain the data format among the most common (SAMPLE_U8, SAMPLE_S16LE, SAMPLE_S24LE, SAMPLE_S32LE)
Example¶
sample_format = SAMPLE_FORMAT_BY_WIDTH[2] # ( 2 bytes means 16 bits Signed little endian format )
Sample width by format (Used for PCM format)¶
With the format, it is possible to obtain the number of bits used to represent a sample
Example¶
sample_width = SAMPLE_WIDTH_BY_FORMAT[SAMPLE_S32LE] #( return 4 )
Class functions¶
clearData()¶
Clear stored values.
getSampleWidth()¶
int
Returns the sample width based on the format.