VEX IQ Python API
Public Member Functions | List of all members
vex.BrainSound Class Reference

Public Member Functions

def __init__ (self)
 
def play (self, note, octave=3, duration=0.5, timeUnits=TimeUnits.SEC)
 Play a musical note on the speaker. More...
 
def play_raw (self, note, duration=0.5, timeUnits=TimeUnits.SEC)
 Play a musical note on the speaker. More...
 
def play_wave (self, waveType, waitForCompletion=True)
 play the wave sample More...
 
def play_melody (self, melody)
 Play a melody form a string in a quasi musical alphabet notiation (cdefgab) More...
 
def set_sound_effect (self, effect)
 set the sound effect type for subsequent notes played More...
 
def set_volume (self, volume)
 set the sound volume [1-4] More...
 
def stop (self)
 Stop playing music. More...
 

Constructor & Destructor Documentation

◆ __init__()

def vex.BrainSound.__init__ (   self)

Member Function Documentation

◆ play()

def vex.BrainSound.play (   self,
  note,
  octave = 3,
  duration = 0.5,
  timeUnits = TimeUnits.SEC 
)

Play a musical note on the speaker.

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

◆ play_raw()

def vex.BrainSound.play_raw (   self,
  note,
  duration = 0.5,
  timeUnits = 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
timeUnitsof time for the duration. Default sec.

◆ play_wave()

def vex.BrainSound.play_wave (   self,
  waveType,
  waitForCompletion = True 
)

play the wave sample

Parameters
waveTypetype of the wave sample sound to play [0..15]
waitForCompletionwait for the sample to finish playing

◆ play_melody()

def vex.BrainSound.play_melody (   self,
  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)

◆ set_sound_effect()

def vex.BrainSound.set_sound_effect (   self,
  effect 
)

set the sound effect type for subsequent notes played

Parameters
effecteffect type [0..15]

◆ set_volume()

def vex.BrainSound.set_volume (   self,
  volume 
)

set the sound volume [1-4]

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

◆ stop()

def vex.BrainSound.stop (   self)

Stop playing music.