Libraries.Robots.Spike.Music Documentation

The music library is used to play music through the SPIKE App.

Example Code

use Libraries.Spike.Music
Music music
music:PlayDrum(music:DRUM_SNARE)

Inherits from: Libraries.Language.Object

Variables Table

VariablesDescription
integer INSTRUMENT_BASS
integer DRUM_CONGA
integer INSTRUMENT_TROMBONE
integer DRUM_CLAVES
integer DRUM_WOOD_BLOCK
integer INSTRUMENT_PIANOConstants for instruments
integer INSTRUMENT_BASSOON
integer DRUM_BONGO
integer DRUM_SNAREConstants for drums
integer DRUM_TAMBOURINE
integer DRUM_OPEN_HI_HAT
integer INSTRUMENT_CLARINET
integer DRUM_SIDE_STICK
integer DRUM_TRIANGLE
integer DRUM_VIBRASLAP
integer DRUM_BASS
integer DRUM_HAND_CLAP
integer INSTRUMENT_ELECTRIC_GUITAR
integer DRUM_COWBELL
integer INSTRUMENT_ORGAN
integer INSTRUMENT_MUSIC_BOX
integer INSTRUMENT_CHOIR
integer DRUM_CLOSED_HI_HAT
integer INSTRUMENT_SAXOPHONE
integer INSTRUMENT_SYNTH_LEAD
integer INSTRUMENT_ELECTRIC_PIANO
integer INSTRUMENT_STEEL_DRUM
integer DRUM_CUICAConstants for instruments
integer INSTRUMENT_PIZZICATO
integer INSTRUMENT_WOODEN_FLUTE
integer INSTRUMENT_SYNTH_PADPlay the provided drum sound
integer INSTRUMENT_CELLO
integer DRUM_GUIRO
integer INSTRUMENT_FLUTE
integer INSTRUMENT_GUITAR
integer INSTRUMENT_VIBRAPHONE
integer DRUM_CABASA
integer INSTRUMENT_MARIMBA
integer DRUM_CRASH_CYMBAL

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

PlayDrum(integer drum)

Play the provided drum sound

Parameters

  • integer drum: 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

  • integer instrument: Which instrument to play, out of the INSTRUMENT constants
  • integer note: The midi note to play (0-130)
  • integer duration: 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