EV3RT C API Reference [English]
An RTOS-based development platform for LEGO Mindstorms EV3.
 All Data Structures Functions Variables Enumerations Enumerator Groups

Definitions of API for controlling speaker. More...

Macros

#define SOUND_MANUAL_STOP   (-1)
 Flag for stopping sound reproduction.
 
#define NOTE_C4   (261.63)
 Frequency of musical note C4.
 
#define NOTE_CS4   (277.18)
 Frequency of musical note C#4.
 
#define NOTE_D4   (293.66)
 Frequency of musical note D4.
 
#define NOTE_DS4   (311.13)
 Frequency of musical note D#4.
 
#define NOTE_E4   (329.63)
 Frequency of musical note E4.
 
#define NOTE_F4   (349.23)
 Frequency of musical note F4.
 
#define NOTE_FS4   (369.99)
 Frequency of musical note F#4.
 
#define NOTE_G4   (392.00)
 Frequency of musical note G4.
 
#define NOTE_GS4   (415.30)
 Frequency of musical note G#4.
 
#define NOTE_A4   (440.00)
 Frequency of musical note A4.
 
#define NOTE_AS4   (466.16)
 Frequency of musical note A#4.
 
#define NOTE_B4   (493.88)
 Frequency of musical note B4.
 
#define NOTE_C5   (523.25)
 Frequency of musical note C5.
 
#define NOTE_CS5   (554.37)
 Frequency of musical note C#5.
 
#define NOTE_D5   (587.33)
 Frequency of musical note D5.
 
#define NOTE_DS5   (622.25)
 Frequency of musical note D#5.
 
#define NOTE_E5   (659.25)
 Frequency of musical note E5.
 
#define NOTE_F5   (698.46)
 Frequency of musical note F5.
 
#define NOTE_FS5   (739.99)
 Frequency of musical note F#5.
 
#define NOTE_G5   (783.99)
 Frequency of musical note G5.
 
#define NOTE_GS5   (830.61)
 Frequency of musical note G#5.
 
#define NOTE_A5   (880.00)
 Frequency of musical note A5.
 
#define NOTE_AS5   (932.33)
 Frequency of musical note A#5.
 
#define NOTE_B5   (987.77)
 Frequency of musical note B5.
 
#define NOTE_C6   (1046.50)
 Frequency of musical note C6.
 
#define NOTE_C6   (1046.50)
 Frequency of musical note C6.
 
#define NOTE_CS6   (1108.73)
 Frequency of musical note C#6.
 
#define NOTE_CS6   (1108.73)
 Frequency of musical note C#6.
 
#define NOTE_D6   (1174.66)
 Frequency of musical note D6.
 
#define NOTE_D6   (1174.66)
 Frequency of musical note D6.
 
#define NOTE_DS6   (1244.51)
 Frequency of musical note D#6.
 
#define NOTE_DS6   (1244.51)
 Frequency of musical note D#6.
 
#define NOTE_E6   (1318.51)
 Frequency of musical note E6.
 
#define NOTE_E6   (1318.51)
 Frequency of musical note E6.
 
#define NOTE_F6   (1396.91)
 Frequency of musical note F6.
 
#define NOTE_F6   (1396.91)
 Frequency of musical note F6.
 
#define NOTE_FS6   (1479.98)
 Frequency of musical note F#6.
 
#define NOTE_FS6   (1479.98)
 Frequency of musical note F#6.
 
#define NOTE_G6   (1567.98)
 Frequency of musical note G6.
 
#define NOTE_G6   (1567.98)
 Frequency of musical note G6.
 
#define NOTE_GS6   (1661.22)
 Frequency of musical note G#6.
 
#define NOTE_GS6   (1661.22)
 Frequency of musical note G#6.
 
#define NOTE_A6   (1760.00)
 Frequency of musical note A6.
 
#define NOTE_A6   (1760.00)
 Frequency of musical note A6.
 
#define NOTE_AS6   (1864.66)
 Frequency of musical note A#6.
 
#define NOTE_AS6   (1864.66)
 Frequency of musical note A#6.
 
#define NOTE_B6   (1975.53)
 Frequency of musical note B6.
 
#define NOTE_B6   (1975.53)
 Frequency of musical note B6.
 

Functions

ER ev3_speaker_set_volume (uint8_t volume)
 Set the volume level of speaker. More...
 
ER ev3_speaker_play_tone (uint16_t frequency, int32_t duration)
 Play a tone. Any sound being played will be stopped by calling this function. More...
 
ER ev3_speaker_play_file (const memfile_t *p_memfile, int32_t duration)
 Play a WAV file stored in memory. Only 8-bit 8kHz mono WAV file is supported by now. Any sound being played will be stopped by calling this function. More...
 
ER ev3_speaker_stop ()
 The sound being played will be stopped by calling this function. More...
 

Detailed Description

Definitions of API for controlling speaker.

Function Documentation

ER ev3_speaker_play_file ( const memfile_t p_memfile,
int32_t  duration 
)

Play a WAV file stored in memory. Only 8-bit 8kHz mono WAV file is supported by now. Any sound being played will be stopped by calling this function.

Parameters
p_memfilePointer of a memory file which holds the content of the WAV file to be played.
durationDuration to play, in milliseconds (ms). If SOUND_MANUAL_STOP is specified,it will keep playing until stopped manually or finished. If 0 is given, it will just stop the sound being played.
Return values
E_OKSuccess. The WAV file is now being played.
E_CTXNot called from task context.
E_PARNot a valid or supported WAV file.
E_NORESFailed to acquire the sound device.
ER ev3_speaker_play_tone ( uint16_t  frequency,
int32_t  duration 
)

Play a tone. Any sound being played will be stopped by calling this function.

Parameters
frequencyFrequency of the note, in Hertz (Hz). Range: 250 - 10000. If a out-of-range value is given, it will be clipped to the minimum or maximum value.
durationDuration to play, in milliseconds (ms). If a negative value is given, it will keep playing until stopped manually. If 0 is given, it will just stop the sound being played.
Return values
E_OKSuccess. The note is now being played.
E_CTXNot called from task context.
E_NORESFailed to acquire the sound device.
ER ev3_speaker_set_volume ( uint8_t  volume)

Set the volume level of speaker.

Parameters
volumeThe percentage of max volume level. Range: 0 to +100. 0 means mute. If an out-of-range value is given, i.e. larger than 100, it will be clipped to 100, the maximum value.
Return values
E_OKSuccess
E_CTXNot called from task context.
E_NORESFailed to acquire the sound device.
ER ev3_speaker_stop ( )

The sound being played will be stopped by calling this function.

Return values
E_OKSuccess
E_CTXNot called from task context.
E_NORESFailed to acquire the sound device.