The sound library is capable of playing sounds from the speaker embedded in the Spike hub. It's basic functionalities include playing a sound, stopping sound, and changing the volume of a sound.
ANY=-2DEFAULT=-1WAVEFORM_SINE=1WAVEFORM_SAWTOOTH=3WAVEFORM_SQUARE=2WAVEFORM_TRIANGLE=1NoneintegerfrequencyThe frequency in hertz of the sound
integerdurationThe duration in milliseconds of the sound
integervolumeThe volume intensity of the sound from 0 to 100
1
2
3
use Libraries.Robots.Spike.Sound
Sound noise
noise:Beep(440, 500, 100)NoneintegerfrequencyThe frequency in hertz of the sound
integerdurationThe duration in milliseconds of the sound
integervolumeThe volume intensity of the sound from 0 to 100
integerattackThe time in milliseconds between the start of the sound to the peak
integerdecayThe time in milliseconds between the peak volume to sustain volume
integersustainThe volume intensity of the sustain of the sound between 0 and 100 until the sound is released
integerreleaseThe time in milliseconds for the volume intensity to decay to 0 from release time
integertransitionThe time in milliseconds for the sound to transition from the currently playing sound
integerwaveformThe waveform to use to play the sound, using one of the constants defined in the Sound class
integerchannelThe channel to play on, either DEFAULT or ANY from the constants defined in the Sound class
1
2
3
use Libraries.Robots.Spike.Sound
Sound noise
noise:Beep(440, 500, 100, 120, 50, 50, 60, 10, noise:WAVEFORM_SQUARE, noise:DEFAULT)NoneintegervolThe volume intensity of the sound from 0 to 100
1
2
3
4
use Libraries.Robots.Spike.Sound
Sound noise
noise:Beep(440, 5000, 100)
noise:Stop()NoneNone1
2
3
4
5
6
7
use Libraries.Robots.Spike.Sound
use Libraries.Robots.Spike.Hub
Sound noise
Hub hb
noise:Beep(440, 5000, 100)
hb:Sleep(1000)
noise:SetVolume(25)