setBPM(bpm:int)
Sets the BPM (beats per minute) of the following notes. The default is 120.
setBPM(240)
note(C_NOTE_C, C_DURATION_1_2)
delay(1000)
setBPM(120)
note(C_NOTE_C, C_DURATION_1_2)
delay(1000)
setOctave(octave:byte)
Sets the octave of the following notes.
setOctave(C_OCTAVE_C5)
note(C_NOTE_E, C_DURATION_1_4)
delay(500)
setOctave(C_OCTAVE_C6)
note(C_NOTE_E, C_DURATION_1_4)
delay(500)
Available octaves:
C_OCTAVE_C3
C_OCTAVE_C4
C_OCTAVE_C5
C_OCTAVE_C6
C_OCTAVE_C7
C_OCTAVE_C8
setWaveform(waveform:byte)
Sets the waveform of the following tones. The default is the sine (C_WAVEFORM_SINE).
setWaveform(C_WAVEFORM_SAWTOOTH)
Available waveforms:
C_WAVEFORM_SQUARE
C_WAVEFORM_SAWTOOTH
C_WAVEFORM_TRIANGLE
C_WAVEFORM_SINE
C_WAVEFORM_RANDOM
soundEffect(soundid:int)
Experimental
Plays an internal sound with the soundid. Either a number between 0 and 4 can be specified, or one of the following constants:
SOUND_STARTUP
SOUND_BLUB
SOUND_CRASH
SOUND_LEVEL
SOUND_LOSE
stopSong()
Stops a currently playing song. No effect if no song is played.
playSong(true)
delay(1000)
stopSong()
resumeSong()
Resumes a paused song. No effect if no song was paused.
playSong(true)
delay(1000)
pauseSong()
delay(1000)
resumeSong()
pauseSong()
Pauses a currently playing song. No effect if no song is played.
A paused song can be resumed with either resumeSong() or playSong(…).
playSong(true)
delay(1000)
pauseSong()
playSong(autorepeat:bool)
Plays the previously created song. If autorepeat is set the song plays indefinitely.
beginSong()
note(C_NOTE_A, C_DURATION_1_4)
note(C_NOTE_B, C_DURATION_1_4)
note(C_NOTE_C, C_DURATION_1_2)
endSong()
playSong(false) # autorepeat = false
delay(2000)
playSong(true) # autorepeat = true
endSong()
Ends the song. All tone() and note() functions after this are played and no longer stored as a song.
beginSong()
note(C_NOTE_A, C_DURATION_1_4)
note(C_NOTE_B, C_DURATION_1_4)
note(C_NOTE_C, C_DURATION_1_2)
endSong()
playSong(false)
noteAdvanced(note:byte, durFactor:float, octave:byte, articulation:float)
Plays a note for the given tone duration factor, octave and articulation.
noteAdvanced(C_NOTE_A, C_DURATION_1_4, C_OCTAVE_C5, C_ARTICULATION_STACCATO)
Available notes:
C_NOTE_REST # 0 Hz
C_NOTE_C # 131 Hz
C_NOTE_CS # 139 Hz
C_NOTE_D # 147 Hz
C_NOTE_DS # 156 Hz
C_NOTE_E # 165 Hz
C_NOTE_F # 175 Hz
C_NOTE_FS # 185 Hz
C_NOTE_G # 196 Hz
C_NOTE_GS # 208 Hz
C_NOTE_A # 220 Hz
C_NOTE_AS # 233 Hz
C_NOTE_B # 247 Hz
Available tone duration factors:
C_DURATION_1_1 # 4.0
C_DURATION_1_2 # 2.0
C_DURATION_1_4 # 1.0
C_DURATION_1_8 # 0.5
C_DURATION_1_16 # 0.25
C_DURATION_1_32 # 0.125
Available octaves:
C_OCTAVE_C3
C_OCTAVE_C4
C_OCTAVE_C5
C_OCTAVE_C6
C_OCTAVE_C7
C_OCTAVE_C8
Available articulations:
C_ARTICULATION_STANDARD
C_ARTICULATION_STACCATO
C_ARTICULATION_STACCATISSIMO
C_ARTICULATION_TENUTO
C_ARTICULATION_MARCATO
C_ARTICULATION_LEGATO
note(note:byte, durFactor:long)
Plays a note for the given tone duration factor.
note(C_NOTE_A, C_DURATION_1_4)
Available notes:
C_NOTE_REST # 0 Hz
C_NOTE_C # 131 Hz
C_NOTE_CS # 139 Hz
C_NOTE_D # 147 Hz
C_NOTE_DS # 156 Hz
C_NOTE_E # 165 Hz
C_NOTE_F # 175 Hz
C_NOTE_FS # 185 Hz
C_NOTE_G # 196 Hz
C_NOTE_GS # 208 Hz
C_NOTE_A # 220 Hz
C_NOTE_AS # 233 Hz
C_NOTE_B # 247 Hz
Available tone duration factors:
C_DURATION_1_1 # 4.0
C_DURATION_1_2 # 2.0
C_DURATION_1_4 # 1.0
C_DURATION_1_8 # 0.5
C_DURATION_1_16 # 0.25
C_DURATION_1_32 # 0.125
beginSong()
Setups a new song. All tone() and note() functions after this are not played but stored as a song.
beginSong()
note(C_NOTE_A, C_DURATION_1_4)
note(C_NOTE_B, C_DURATION_1_4)
note(C_NOTE_C, C_DURATION_1_2)
endSong()
playSong(false)
noTone()
Turns off the sound output.
tone(440, 0)
delay(1000)
noTone()
tone(frequency:int,duration:long)
Plays a tone with the frequency “frequency” and the duration “duration” in milliseconds.
tone(440,1000)