Music
Package: Libraries.Robots.Spike · Inherits from: Libraries.Language.Object
The music library is used to play music through the SPIKE App.
Example Code
use Libraries.Robots.Spike.Music
Music music
music:PlayDrum(music:DRUM_SNARE)
Variables
integer INSTRUMENT_BASSinteger DRUM_BASSinteger DRUM_TRIANGLEinteger INSTRUMENT_GUITARinteger DRUM_CLAVESinteger DRUM_BONGOinteger INSTRUMENT_ELECTRIC_PIANOinteger DRUM_SIDE_STICKinteger DRUM_CLOSED_HI_HATinteger INSTRUMENT_CHOIRinteger INSTRUMENT_MUSIC_BOXinteger INSTRUMENT_STEEL_DRUMinteger DRUM_CABASAinteger DRUM_OPEN_HI_HATinteger DRUM_SNARE: Constants for drumsinteger INSTRUMENT_ORGANinteger INSTRUMENT_ELECTRIC_GUITARinteger DRUM_VIBRASLAPinteger DRUM_CRASH_CYMBALinteger DRUM_WOOD_BLOCKinteger INSTRUMENT_VIBRAPHONEinteger INSTRUMENT_SYNTH_PAD: Play the provided drum soundinteger INSTRUMENT_BASSOONinteger INSTRUMENT_CLARINETinteger DRUM_TAMBOURINEinteger INSTRUMENT_PIZZICATOinteger DRUM_GUIROinteger DRUM_HAND_CLAPinteger INSTRUMENT_WOODEN_FLUTEinteger INSTRUMENT_SAXOPHONEinteger INSTRUMENT_MARIMBAinteger INSTRUMENT_FLUTEinteger INSTRUMENT_TROMBONEinteger INSTRUMENT_CELLOinteger DRUM_CONGAinteger INSTRUMENT_SYNTH_LEADinteger DRUM_CUICA: Constants for instrumentsinteger DRUM_COWBELLinteger INSTRUMENT_PIANO: Constants for instruments
Actions
PlayDrum(integer drum)
Play the provided drum sound
Parameters
druminteger: Which drum to play, out of the DRUM constants
Example
use Libraries.Robots.Spike.Music
Music ms
ms:PlayDrum(ms:DRUM_SNARE)
PlayInstrument(integer instrument, integer note, integer duration)
Play the provided instrument sound with a given tone and duration
Parameters
instrumentinteger: Which instrument to play, out of the INSTRUMENT constantsnoteinteger: The midi note to play (0-130)durationinteger: How long to play the instrument/note for, in milliseconds
Example
use Libraries.Robots.Spike.Music
Music ms
ms:PlayInstrument(ms:INSTRUMENT_PIANO, 50, 3000) // Play for 3 seconds