Module Musician.Sampler
Sampler engine
Functions
Functions
- Musician.Sampler.GetInstrumentData (instrumentName, key)
-
Return instrument data for given MIDI key number
Parameters:
- instrumentName (string)
- key (int) MIDI key number
Returns:
-
instrumentData (table) from Musician.INSTRUMENTS
- Musician.Sampler.GetInstrumentName (instrument[, key])
-
Return instrument name from its MIDI ID and key number
Parameters:
- instrument (int) MIDI instrument ID
- key (int) Only needed to get the final instrument name for traditional percussions (optional)
Returns:
-
instrumentName (string) used as key in Musician.INSTRUMENTS
- Musician.Sampler.GetLocalizedMIDIInstrumentName (instrument)
-
Return localized General MIDI instrument name
Parameters:
- instrument (int)
Returns:
-
localizedInstrumentName (string)
- Musician.Sampler.GetMuted ()
-
Return global mute state
Returns:
-
isMuted (boolean)
- Musician.Sampler.GetNoteData (handle)
-
Return note data
Parameters:
- handle (int) The note handle returned by PlayNote()
Returns:
-
noteOnData (table) Empty table if not valid
- Musician.Sampler.GetSampleId (instrumentData, key)
-
Return sample ID for note and instrument data
Parameters:
- instrumentData (table) as returned by Musician.Sampler.GetInstrumentData()
- key (int) MIDI key number
Returns:
-
sampleId (string)
- Musician.Sampler.GetSoundFile (instrument, key)
-
Get the path to a sound file for an instrument and a key.
Also returns the instrument data from Musician.INSTRUMENTS
and all other suitable sound file paths for randomization.
Parameters:
- instrument (int|string|table) MIDI instrument index, instrument name or instrument data
- key (int) MIDI key
Returns:
- filePath (string) file path to be played
- instrumentData (table) from Musician.INSTRUMENTS
- soundFiles (table) all suitable file paths for this instrument and note
- Musician.Sampler.Init ()
- Init sampler engine
- Musician.Sampler.NoteKey (noteName)
-
Return the MIDI key of the note name
Parameters:
- noteName (string) from Musician.NOTE_NAMES
Returns:
-
key (int)
- Musician.Sampler.NoteName (key)
-
Return the note name corresponding its MIDI key
Parameters:
- key (int) MIDI key index
Returns:
-
name (string) from Musician.NOTE_NAMES
- Musician.Sampler.PlayNote (instrument, key[, onPlay[, onStop]])
-
Start playing a note
Parameters:
- instrument (int|string|table) MIDI instrument index, instrument name or instrument data
- key (int) Note MIDI key
- onPlay (function) Called when the note audio starts playing. Args: noteHandle (int) (optional)
- onStop (function) Called when the note audio is stopped. Args: noteHandle (int), decay (number) (optional)
Returns:
-
noteHandle (int)
- Musician.Sampler.PlaySoundFile (soundFile, channel)
-
Safely play a sound file, even if the sound file does not exist.
Parameters:
- soundFile (string)
- channel (string)
Returns:
- willPlay (boolean)
- soundHandle (int)
- Musician.Sampler.SetMuted (isMuted)
-
Set global mute state
Parameters:
- isMuted (boolean)
- Musician.Sampler.StopNote (handle[, decay])
-
Stop playing note
Parameters:
- handle (int) The note handle returned by PlayNote()
- decay (number) Override instrument decay (optional)
- Musician.Sampler.StopOldestNote ()
- Stop playing the oldest note to release a polyphony slot