-
-
Notifications
You must be signed in to change notification settings - Fork 7
API Sampler
Sampler engine
-
Functions
- Musician.Sampler.Init
- Musician.Sampler.NoteName
- Musician.Sampler.NoteKey
- Musician.Sampler.GetInstrumentName
- Musician.Sampler.GetLocalizedMIDIInstrumentName
- Musician.Sampler.GetInstrumentData
- Musician.Sampler.GetSoundFile
- Musician.Sampler.IsInstrumentPlucked
- Musician.Sampler.PlayNote
- Musician.Sampler.StopNote
- Musician.Sampler.OnUpdate
- Musician.Sampler.StopOldestNote
- Musician.Sampler.GetSampleId
- Musician.Sampler.PlaySoundFile
- Musician.Sampler.SetMuted
- Musician.Sampler.GetMuted
Init sampler engine
Musician.Sampler.Init()Return the note name corresponding its MIDI key
name = Musician.Sampler.NoteName(key)Arguments
- key (int) MIDI key index
Returns
- name (string) from Musician.NOTE_NAMES
Return the MIDI key of the note name
key = Musician.Sampler.NoteKey(noteName)Arguments
- noteName (string) from Musician.NOTE_NAMES
Returns
- key (int)
Return instrument name from its MIDI ID and key number
instrumentName = Musician.Sampler.GetInstrumentName(instrument, key)Arguments
- 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
Return localized General MIDI instrument name
localizedInstrumentName = Musician.Sampler.GetLocalizedMIDIInstrumentName(instrument)Arguments
- instrument (int)
Returns
- localizedInstrumentName (string)
Return instrument data for given MIDI key number
instrumentData = Musician.Sampler.GetInstrumentData(instrumentName, key)Arguments
- instrumentName (string)
- key (int) MIDI key number
Returns
- instrumentData (table) from Musician.INSTRUMENTS
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.
filePath, instrumentData, soundFiles = Musician.Sampler.GetSoundFile(instrument, key)Arguments
- 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
Returns true if the provided instrument is "plucked".
isPlucked = Musician.Sampler.IsInstrumentPlucked(instrument)Arguments
- instrument (int) MIDI instrument ID
Returns
- isPlucked (boolean)
Start playing a note
handle, willPlay = Musician.Sampler.PlayNote(instrument, key, loopNote, track, player)Arguments
- instrument (int|string|table) MIDI instrument index, instrument name or instrument data
- key (int) Note MIDI key
- loopNote (boolean) The note sample should be looped (long note or live note)
- track (table) The track the note comes from (optional)
- player (string) The normalized name of the player who plays the note (optional)
Returns
- handle (int)
- willPlay (boolean)
Stop playing note
Musician.Sampler.StopNote(handle, decay)Arguments
- handle (int) The note handle returned by PlayNote()
- decay (number) Override instrument decay (optional)
Main on frame update function
Musician.Sampler.OnUpdate()Stop playing the oldest note to release a polyphony slot
Musician.Sampler.StopOldestNote()Return sample ID for note and instrument data
sampleId = Musician.Sampler.GetSampleId(instrumentData, key)Arguments
- instrumentData (table) as returned by Musician.Sampler.GetInstrumentData()
- key (int) MIDI key number
Returns
- sampleId (string)
Safely play a sound file, even if the sound file does not exist.
willPlay, soundHandle = Musician.Sampler.PlaySoundFile(soundFile, channel)Arguments
- soundFile (string)
- channel (string)
Returns
- willPlay (boolean)
- soundHandle (int)
Set global mute state
Musician.Sampler.SetMuted(isMuted)Arguments
- isMuted (boolean)
Return global mute state
isMuted = Musician.Sampler.GetMuted()Returns
- isMuted (boolean)
Table of contents
- User guide (FR)
- Optional modules
- What the FAQ
- Tips and Tricks
- Music producer guide
- Localization
- Technical design
- API documentation
Discord / MusicianList / Patreon / Donate