VEX IQ C++ API
Public Member Functions | List of all members
vex::brain::sound Class Reference

Public Member Functions

 sound ()
 
 ~sound ()
 
void play (noteType note, uint8_t octave=3, float duration=0.5, timeUnits units=timeUnits::sec)
 Play a musical note on the speaker. More...
 
void play (uint8_t note, float duration=0.5, timeUnits units=timeUnits::sec)
 Play a musical note on the speaker. More...
 
void playWave (soundType wave, bool waitForCompletion=true)
 play the wave sample More...
 
void playMelody (const char *melody)
 Play a melody form a string in a quasi musical alphabet notiation (cdefgab) More...
 
void setSoundEffect (uint8_t effect)
 set the sound effect type for subsequent notes played More...
 
void setVolume (uint8_t volume)
 set the sound volume [1-4] More...
 
void stop ()
 Stop playing music. More...
 

Constructor & Destructor Documentation

◆ sound()

vex::brain::sound::sound ( )

◆ ~sound()

vex::brain::sound::~sound ( )
inline

Member Function Documentation

◆ play() [1/2]

void vex::brain::sound::play ( noteType  note,
uint8_t  octave = 3,
float  duration = 0.5,
timeUnits  units = timeUnits::sec 
)

Play a musical note on the speaker.

Parameters
notemusical note to play
octaveoctave of the note [1-7], optional
durationtime. 0 to start playing without blocking. Default 0.5
unitsof time for the duration. Default sec.

◆ play() [2/2]

void vex::brain::sound::play ( uint8_t  note,
float  duration = 0.5,
timeUnits  units = timeUnits::sec 
)

Play a musical note on the speaker.

Parameters
notemusical note to play: 0=silence/stop, [1-56] numeric value
durationtime. 0 to start playing without blocking. Default 0.5
unitsof time for the duration. Default sec.

◆ playWave()

void vex::brain::sound::playWave ( soundType  wave,
bool  waitForCompletion = true 
)

play the wave sample

Parameters
wavetype of the wave sample sound to play
waitForCompletionwait for the sample to finish playing

◆ playMelody()

void vex::brain::sound::playMelody ( const char *  melody)

Play a melody form a string in a quasi musical alphabet notiation (cdefgab)

Parameters
melodystring [cdefgab]: musical alphabet for notes, space: pause, +/-: increase/decrease octave of following notes 0-9: set duration of following notes (in 1/8s: 1=eighth note...8 = full note)

◆ setSoundEffect()

void vex::brain::sound::setSoundEffect ( uint8_t  effect)

set the sound effect type for subsequent notes played

Parameters
effecteffect type [0..15]

◆ setVolume()

void vex::brain::sound::setVolume ( uint8_t  volume)

set the sound volume [1-4]

Parameters
volumevalue [1=low...4=high]

◆ stop()

void vex::brain::sound::stop ( )

Stop playing music.