Skip to content

API Song

LenweSaralonde edited this page Dec 20, 2020 · 7 revisions

Song class

Fields

  • id (int) Song ID, used for streaming
  • crc32 (int) CRC32 of imported song data
  • tracks (table) Song tracks, including instrument and notes
  • duration (int) Song duration in seconds
  • name (string) Song title
  • player (string) Player name, with realm slug
  • sender (string) Name of the player who sent the song
  • notified (boolean) True when the notification for the song playing has been displayed
  • playing (boolean) True when the song is playing
  • streaming (boolean) True when the song is streaming
  • importing (boolean) True when the song is being imported
  • exporting (boolean) True when the song is being exported
  • chunkDuration (number) Duration of a streaming chunk, in seconds
  • mode (int) Song mode
  • isLiveStreamingSong (boolean) Song is used for, or results from live streaming from the current player
  • cropFrom (number) Play song from this position
  • cropTo (number) Play song until this position
  • cursor (number) Cursor position, in seconds
  • soloTracks (int) Number of tracks in solo
  • polyphony (int) Current theoretical polyphony
  • drops (int) Dropped notes

Functions

Musician.Song.create

Song class

Musician.Song.create()

Musician.Song:GetId

Return song ID

songId = Musician.Song:GetId()

Returns

  • songId (int)

Musician.Song:IsPlaying

Return true if the song is playing or about to be played (preloading).

isPlaying = Musician.Song:IsPlaying()

Returns

  • isPlaying (boolean)

Musician.Song:GetProgression

Return playing progression

progression = Musician.Song:GetProgression()

Returns

  • progression (number)

Musician.Song:SetTrackMuted

Mute or unmute track

Musician.Song:SetTrackMuted(track, isMuted)

Arguments

  • track (table)
  • isMuted (boolean)

Musician.Song:TrackIsMuted

Return true if the track is muted

isMuted = Musician.Song:TrackIsMuted(track)

Arguments

  • track (table)

Returns

  • isMuted (boolean)

Musician.Song:SetTrackSolo

Set/unset track solo

Musician.Song:SetTrackSolo(track, isSolo)

Arguments

  • track (table)
  • isSolo (boolean)

Musician.Song:Play

Play song

Musician.Song:Play(delay)

Arguments

  • delay (number) Delay in seconds to wait before playing the song

Musician.Song:Reset

Reset song to initial position

Musician.Song:Reset()

Musician.Song:Seek

Seek to position

Musician.Song:Seek(cursor)

Arguments

  • cursor (number)

Musician.Song:Resume

Resume a song playing

Musician.Song:Resume(eventSent)

Arguments

  • eventSent (boolean)

Musician.Song:Stop

Stop song

Musician.Song:Stop()

Musician.Song.OnUpdate

Main on frame update function

Musician.Song.OnUpdate(elapsed)

Arguments

  • elapsed (number)

Musician.Song:PlayOnFrame

Play notes accordingly to every frame.

Musician.Song:PlayOnFrame(elapsed)

Arguments

  • elapsed (number)

Musician.Song:IsAudible

Returns true when the song is being played and can be heard

isAudible = Musician.Song:IsAudible()

Returns

  • isAudible (boolean)

Musician.Song:NoteOn

Play a note

Musician.Song:NoteOn(track, noteIndex, retries)

Arguments

  • track (table) Reference to the track
  • noteIndex (int) Note index
  • retries (int) Number of attempts to recover dropped notes

Musician.Song:NoteOff

Stop a note of a track

Musician.Song:NoteOff(track, key, audioOnly, decay)

Arguments

  • track (table) Reference to the track
  • key (int) Note key
  • audioOnly (boolean) Stop note audio only
  • decay (number) Override instrument decay (optional)

Musician.Song:TrackNotesOff

Stop all notes of a track

Musician.Song:TrackNotesOff(track, audioOnly)

Arguments

  • track (table) Reference to the track
  • audioOnly (boolean)

Musician.Song:SongNotesOff

Stop all notes of the song

Musician.Song:SongNotesOff()

Musician.Song:ImportFromBase64

Import song from a base 64 encoded string

Musician.Song:ImportFromBase64(base64data, crop, onComplete)

Arguments

  • base64data (string)
  • crop (boolean) Automatically crop song to first and last note
  • onComplete (function) Called when the whole import process is complete. Argument is true when successful (optional)

Musician.Song:ImportCompressed

Import song from a compressed string

Musician.Song:ImportCompressed(compressedData, crop, onComplete)

Arguments

  • compressedData (string)
  • crop (boolean) Automatically crop song to first and last note
  • onComplete (function) Called when the whole import process is complete. Argument is true when successful (optional)

Musician.Song:Import

Import song from string

Musician.Song:Import(data, crop, previousProgression, onComplete)

Arguments

  • data (string)
  • crop (boolean) Automatically crop song to first and last note
  • previousProgression (number) Add previous progression (0-1) _(default=0)
  • onComplete (function) Called when the whole import process is complete. Argument is true when successful (optional)

Musician.Song:Export

Export song to string

Musician.Song:Export(onComplete, progressionFactor)

Arguments

  • onComplete (function) Called when the whole export process is complete. Data is provided when successful
  • progressionFactor (number) (0-1) _(default=1)

Musician.Song:ExportCompressed

Export song to compressed string

Musician.Song:ExportCompressed(onComplete)

Arguments

  • onComplete (function) Called when the whole export process is complete. Data is provided when successful

Musician.Song:CancelImport

Cancel current import

Musician.Song:CancelImport()

Musician.Song:CancelExport

Cancel current export

Musician.Song:CancelExport()

Musician.Song:OnImportError

Handle importing error

Musician.Song:OnImportError(msg, onComplete)

Arguments

  • msg (string) Error message
  • onComplete (function) (optional)

Musician.Song:OnExportError

Handle exporting error

Musician.Song:OnExportError(msg, onComplete)

Arguments

  • msg (string) Error message
  • onComplete (function) (optional)

Musician.Song:Clone

Clone song

song = Musician.Song:Clone()

Returns

  • song (Musician.Song)

Musician.Song:Stream

Stream song

Musician.Song:Stream()

Musician.Song:StopStreaming

Stop streaming song

Musician.Song:StopStreaming()

Musician.Song:AppendChunk

Append chunk data to current song

Musician.Song:AppendChunk(chunk, mode, songId, chunkDuration, playtimeLeft, player)

Arguments

  • chunk (table)
  • mode (number)
  • songId (number)
  • chunkDuration (number)
  • playtimeLeft (number)
  • player (string)

Musician.Song:StreamOnFrame

Stream a chunk of the song on frame

Musician.Song:StreamOnFrame(elapsed)

Arguments

  • elapsed (number)

Musician.Song:PackChunk

Pack a song chunk

data = Musician.Song:PackChunk(chunk)

Arguments

  • chunk (table)

Returns

  • data (string)

Musician.Song.UnpackChunkHeader

Unpack song chunk header

mode, songId, chunkDuration, playtimeLeft, position, trackCount, headerLength = Musician.Song.UnpackChunkHeader(data)

Arguments

  • data (string)

Returns

  • mode (int)
  • songId (int)
  • chunkDuration (number)
  • playtimeLeft (number)
  • position (table) player position and GUID
  • trackCount (int)
  • headerLength (number)

Musician.Song.UnpackChunkData

Unpack song chunk data

chunk = Musician.Song.UnpackChunkData(data)

Arguments

  • data (string)

Returns

  • chunk (table)

Musician.Song.GetPlayingSongs

Return songs currently playing

playingSongCount = Musician.Song.GetPlayingSongs()

Returns

  • playingSongCount (int)

Musician.Song.GetPlayingSongCount

Return the number of songs currently playing

playingSongCount = Musician.Song.GetPlayingSongCount()

Returns

  • playingSongCount (int)

Musician.Song:ConvertToLive

Convert song to live mode.

For testing only

Musician.Song:ConvertToLive()

Clone this wiki locally