62#include "cnfs_image.h"
72#define MIDI_CHANNEL_COUNT 16
74#define POOL_VOICE_COUNT 24
76#define PERCUSSION_VOICES 16
78#define NUM_GLOBAL_PLAYERS 2
87#define MIDI_FALSE 0x00
88#define MIDI_TO_BOOL(val) (val > 63)
89#define BOOL_TO_MIDI(val) (val ? MIDI_TRUE : MIDI_FALSE)
90#define MIDI_DEF_HEADROOM 0x4000
91#define PITCH_BEND_CENTER 0x2000
94#define SAMPLES_TO_MIDI_TICKS(n, tempo, div) ((int64_t)(n) * 1000000 * (div) / DAC_SAMPLE_RATE_HZ / (tempo))
97#define TICKS_TO_SAMPLES(ticks, tempo, div) ((int64_t)(ticks) * DAC_SAMPLE_RATE_HZ / (1000000) * (tempo) / (div))
100#define SAMPLES_TO_MS(samp) (((samp) * 1000) / DAC_SAMPLE_RATE_HZ)
103#define SAMPLES_TO_US(samp) (((samp) * 1000000) / DAC_SAMPLE_RATE_HZ)
106#define MS_TO_SAMPLES(ms) ((ms) * DAC_SAMPLE_RATE_HZ / 1000)
109#define MIDI_TICKS_TO_US(ticks, tempo, div) (int64_t)((int64_t)((int64_t)(ticks) * (int64_t)(tempo)) / ((int64_t)(div)))
uint32_t uq24_8
unsigned 24 bits integer, 8 bits fraction
Definition fp_math.h:41
uint32_t uq8_24
unsigned 8 bits integer, 24 bits fraction
Definition fp_math.h:43
int32_t q24_8
24 bits integer, 8 bits fraction
Definition fp_math.h:36
int32_t q8_24
8 bits integer, 24 bits fraction
Definition fp_math.h:38
uint32_t uq16_16
unsigned 16 bits integer, 16 bits fraction
Definition fp_math.h:42
metaEventType_t
The possible types of meta-events.
Definition midiFileParser.h:34
Contains information for an entire MIDI event or non-MIDI meta-event.
Definition midiFileParser.h:236
Definition midiFileParser.h:110
Contains information which applies to the entire MIDI file.
Definition midiFileParser.h:87
int32_t releaseTime
Base time it takes to silence the note after release, in DAC samples.
Definition midiPlayer.h:413
uint32_t loopStart
The start of the loop portion of the sample.
Definition midiPlayer.h:485
void midiNoteOn(midiPlayer_t *player, uint8_t channel, uint8_t note, uint8_t velocity)
Begin playing a note on a given MIDI channel.
Definition midiPlayer.c:1737
q8_24 volRate
Rate-of-change of the volume per tick, can be positive or negative.
Definition midiPlayer.h:564
uint16_t midiGetControlValue14bit(midiPlayer_t *player, uint8_t channel, midiControl_t control)
Get the combined value of two MIDI control registers.
Definition midiPlayer.c:2435
uint32_t loop
0 to loop forever, or the number of loops to play
Definition midiPlayer.h:482
midiEvent_t pendingEvent
The next event in the MIDI file, which occurs after the current time.
Definition midiPlayer.h:774
bool paused
True when playback of the current file is paused.
Definition midiPlayer.h:783
q24_8 sustainVolVel
This value will be multiplied by the note velocity and added to the attack time.
Definition midiPlayer.h:422
void midiSustain(midiPlayer_t *player, uint8_t channel, uint8_t val)
Set the hold pedal status.
Definition midiPlayer.c:2125
uint32_t stateChangeTick
The next tick at which state will change.
Definition midiPlayer.h:576
void globalMidiRestore(void *data)
Resume MIDI playback from the state stored in the given pointer. The data will be freed after this ca...
Definition midiFileParser.c:1072
void midiResetChannelControllers(midiPlayer_t *player, uint8_t channel)
Reset all controllers on a MIDI channel.
Definition midiPlayer.c:1636
const noteSampleMap_t * map
A map of different samples to use.
bool registeredParameter
Whether selectedParameter represents a registered or non-registered parameter.
Definition midiPlayer.h:688
timbreType_t
The sample source for an instrument.
Definition midiPlayer.h:135
@ PLAY_FUNC
Definition midiPlayer.h:142
@ SAMPLE
Definition midiPlayer.h:138
@ WAVETABLE
Samples are generated by sampling a particular wave shape.
Definition midiPlayer.h:137
@ WAVE_SHAPE
Definition midiPlayer.h:140
@ MULTI_SAMPLE
Definition midiPlayer.h:141
@ NOISE
Definition midiPlayer.h:139
q24_8 releaseTimeVel
This value will be multiplied by the note velocity and added to the attack time.
Definition midiPlayer.h:416
envelope_t envelope
Definition midiPlayer.h:496
void midiGmOn(midiPlayer_t *player)
Activate General MIDI mode on a MIDI player.
Definition midiPlayer.c:1651
uint32_t tempo
The number of microseconds per quarter note.
Definition midiPlayer.h:780
void midiPlayerResetNewSong(midiPlayer_t *player)
Reset the MIDI player state by only doing the bare minimum. This is useful when playing multiple soun...
Definition midiPlayer.c:1419
uint32_t length
The number of samples in the data.
void globalMidiPlayerPlaySong(midiFile_t *song, uint8_t trackType)
Play a song on one of the system-wide MIDI players, either BGM or SFX.
Definition midiPlayer.c:2744
synthOscillator_t oscillator
uint32_t sustenuto
Bitfield of voices which are being held by the sustenuto pedal.
Definition midiPlayer.h:670
uint32_t held
Bitfield of voices which are being held by the pedal.
Definition midiPlayer.h:667
midiManufacturerId_t
Values that can be directly compared against midiSysexEvent_t::manufacturerId.
Definition midiPlayer.h:384
@ MMFR_EDUCATIONAL_USE
Definition midiPlayer.h:385
@ MMFR_UNIVERSAL_NON_REAL_TIME
Definition midiPlayer.h:386
@ MMFR_UNIVERSAL_REAL_TIME
Definition midiPlayer.h:387
int32_t midiPlayerStep(midiPlayer_t *player)
Calculate and return the next MIDI sample, stepping the player state forward by one sample.
Definition midiPlayer.c:1430
void midiAfterTouch(midiPlayer_t *player, uint8_t channel, uint8_t note, uint8_t velocity)
Change the velocity of a note on a given MIDI channel, after the note starts playing.
Definition midiPlayer.c:1959
q8_24 volAccel
Acceleration of the volume per tick, which will be added to the rate.
Definition midiPlayer.h:567
voiceStates_t poolVoiceStates
The global voice pool state bitmaps.
Definition midiPlayer.h:743
void midiPlayerFillBuffer(midiPlayer_t *player, uint8_t *samples, int16_t len)
Fill a buffer with the next set of samples from the MIDI player. This should be called by the callbac...
Definition midiPlayer.c:1511
midiTimbre_t timbre
The actual current timbre definition which the program ID corresponds to.
Definition midiPlayer.h:694
waveFunc_t waveFunc
The function to use to retrieve wavetable samples.
int32_t attackTime
Base time taken to ramp up to full volume.
Definition midiPlayer.h:401
timbreSample_t sample
Definition midiPlayer.h:495
midiVoice_t percVoices[PERCUSSION_VOICES]
The voices reserved for percussion.
Definition midiPlayer.h:727
uq16_16 baseNote
The sample's base frequency.
voiceStates_t percVoiceStates
The percussion voice state bitmaps.
Definition midiPlayer.h:730
uint32_t loopStart
The sample number to return to after reaching the loop end.
uint32_t loopEnd
The end of the loop portion of the sample.
Definition midiPlayer.h:488
q24_8 attackTimeVel
This value will be multiplied by the note velocity and added to the attack time,.
Definition midiPlayer.h:404
timbreType_t type
The source of samples for this instrument.
Definition midiPlayer.h:505
uint32_t loopEnd
The sample number after which to return to the loop start.
void midiSetParameter(midiPlayer_t *player, uint8_t channel, bool registered, uint16_t param, uint16_t value)
Set a registered or non-registered parameter value.
Definition midiPlayer.c:2453
void midiSeek(midiPlayer_t *player, uint32_t ticks)
Seek to a given time offset within a file.
Definition midiPlayer.c:2610
voiceType_t
Enum which defines the method used to retrieve a sample from each voice.
Definition midiPlayer.h:162
@ VOICE_PLAY_FUNC
Definition midiPlayer.h:164
@ VOICE_WAVE_FUNC
Definition midiPlayer.h:163
@ VOICE_SAMPLE
Definition midiPlayer.h:165
void deinitGlobalMidiPlayer(void)
Deinitialize and free memory associated with the system-wide MIDI players.
Definition midiPlayer.c:2716
void globalMidiPlayerStop(bool reset)
Stop all songs currently being played by the system-wide MIDI players, optionally resetting their sta...
Definition midiPlayer.c:2810
bool held
Whether notes will be held after release.
Definition midiPlayer.h:706
uint32_t percSpecialStates
A bitmap to track which percussion voices have special notes playing This includes all 3 hi-hats (ope...
Definition midiPlayer.h:737
void midiSustenuto(midiPlayer_t *player, uint8_t channel, uint8_t val)
Set the sustenuto pedal status.
Definition midiPlayer.c:2172
uq16_16 pitch
The ultimate pitch of this voice after pitch bending, etc.
Definition midiPlayer.h:579
void midiSetProgram(midiPlayer_t *player, uint8_t channel, uint8_t program)
Change the program (instrument) on a given MIDI channel.
Definition midiPlayer.c:2108
uq24_8 sampleRateRatio
The pre-calculated samples-per-second.
bool loop
If true, the playing file will automatically repeat when complete.
Definition midiPlayer.h:789
adsrState_t
Enum representing specific ADSR states.
Definition midiPlayer.h:173
@ ADSR_ON
On, in which the note is on but doesn't have any specific ADSR states set (what?)
Definition midiPlayer.h:175
@ ADSR_RELEASE
Release, in which the volume falls from the sustain volume to 0 quadratically.
Definition midiPlayer.h:183
@ ADSR_OFF
Off, in which the note has finished playing completely.
Definition midiPlayer.h:185
@ ADSR_DECAY
Decay, in which the volume falls from the max volume to the sustain volume linearly.
Definition midiPlayer.h:179
@ ADSR_ATTACK
Attack, in which the volume rises from 0 to the max volume linearly.
Definition midiPlayer.h:177
@ ADSR_SUSTAIN
Sustain, in which the volume remains at the sustain volume.
Definition midiPlayer.h:181
bool sustenuto
Whether certain notes will be held after release.
Definition midiPlayer.h:709
midiFileReader_t reader
A MIDI reader to use for file playback, when in MIDI_FILE mode.
Definition midiPlayer.h:749
uint32_t rate
The number of samples per second of raw sample data.
uint8_t velocity
The MIDI note velocity of the playing note.
Definition midiPlayer.h:585
void midiPlayerInit(midiPlayer_t *player)
Initialize the MIDI player.
Definition midiPlayer.c:1388
uint8_t channel
The index of the MIDI channel that owns the currently playing note. If 255 or any other value >= 16,...
Definition midiPlayer.h:589
uint8_t sustainVol
The base volume of the sustained note, proportional to the sample volume.
Definition midiPlayer.h:419
uq8_24 curVol
The current volume as a fixed-point value.
Definition midiPlayer.h:561
void globalMidiPlayerResumeAll(void)
Resume all songs currently being played by the system-wide MIDI players.
Definition midiPlayer.c:2799
#define PERCUSSION_VOICES
Definition midiPlayer.h:76
int32_t headroom
The constant value to multiply each frame's samples by, before being shifted right 16 bits This value...
Definition midiPlayer.h:764
void globalMidiPlayerFillBuffer(uint8_t *samples, int16_t len)
Fill the given sample buffer with samples from both the BGM and SFX system-wide MIDI players.
Definition midiPlayer.c:2732
void midiPitchWheel(midiPlayer_t *player, uint8_t channel, uint16_t value)
Set the pitch wheel value on a given MIDI channel.
Definition midiPlayer.c:2541
uint32_t attack
Bitfield of voices currently in the attack stage.
Definition midiPlayer.h:655
void midiGmOff(midiPlayer_t *player)
Deactivate General MIDI mode on a MIDI player.
Definition midiPlayer.c:1667
uint8_t note
The MIDI note number for the sound being played.
Definition midiPlayer.h:582
int8_t tune
The sample's fine tuning.
percussionFunc_t func
A callback to call for drum data.
void midiNoteOff(midiPlayer_t *player, uint8_t channel, uint8_t note, uint8_t velocity)
Stop playing a particular note on a given MIDI channel.
Definition midiPlayer.c:2044
#define POOL_VOICE_COUNT
Definition midiPlayer.h:74
uint32_t rate
The sample rate.
Definition midiPlayer.h:473
midiPlayerMode_t
Represents the source of MIDI data.
Definition midiPlayer.h:123
@ MIDI_STREAMING
Streaming over USB.
Definition midiPlayer.h:125
@ MIDI_FILE
Reading from a midiFileReader_t.
Definition midiPlayer.h:128
midiVoice_t poolVoices[POOL_VOICE_COUNT]
The global voice pool for non-percussion channels.
Definition midiPlayer.h:740
uint32_t decay
Bitfield of voices currently in the decay stage.
Definition midiPlayer.h:661
bool percussion
Whether this channel is reserved for percussion.
Definition midiPlayer.h:703
void globalMidiPlayerPauseAll(void)
Pause all songs currently being played by the system-wide MIDI players.
Definition midiPlayer.c:2788
int32_t decayTime
Base time taken for the volume to fade to the sustain volume.
Definition midiPlayer.h:407
uint32_t clipped
Number of samples that were clipped Note: This is not set when using midiPlayerFillBufferMulti()
Definition midiPlayer.h:768
void * data
User data to pass to the drumkit.
void midiAllSoundOff(midiPlayer_t *player)
Stop all sound immediately. This is not affected by the sustain pedal.
Definition midiPlayer.c:1580
const char * name
The name of this timbre, if any.
Definition midiPlayer.h:550
void(* midiTextCallback_t)(metaEventType_t type, const char *text, uint32_t length)
A function to handle text meta-messages from playing MIDI files.
Definition midiPlayer.h:455
#define MIDI_CHANNEL_COUNT
Definition midiPlayer.h:72
bool eventAvailable
True if pendingEvent is valid, false if it must be updated.
Definition midiPlayer.h:777
midiTextCallback_t textMessageCallback
A callback to call when a text meta-message is received.
Definition midiPlayer.h:755
uint64_t sampleCount
The number of samples elapsed in the playing song.
Definition midiPlayer.h:771
q24_8 decayTimeVel
This value will be multiplied by the note velocity and added to the decay time.
Definition midiPlayer.h:410
uint32_t allocedVoices
A bitmap of which voices have been allocated to this channel.
Definition midiPlayer.h:697
uint16_t selectedParameter
The ID of the currently selected registered or non-registered parameter.
Definition midiPlayer.h:691
void midiAllNotesOff(midiPlayer_t *player, uint8_t channel)
Tun off all notes which are currently on, as though midiNoteOff() were called for each note....
Definition midiPlayer.c:1719
uint32_t release
Bitfield of voices currently in the release stage.
Definition midiPlayer.h:664
bool seeking
True when the MIDI player is seeking, and will not produce sound.
Definition midiPlayer.h:786
uint8_t midiGetControlValue(midiPlayer_t *player, uint8_t channel, midiControl_t control)
Get the value of a MIDI control.
Definition midiPlayer.c:2397
midiChannel_t channels[MIDI_CHANNEL_COUNT]
The state of all MIDI channels.
Definition midiPlayer.h:724
void globalMidiPlayerPlaySongCb(midiFile_t *song, uint8_t trackType, songFinishedCbFn cb)
Play a song on noe of the system-wide MIDI players, with a callback once the song finishes.
Definition midiPlayer.c:2758
uint16_t bank
The bank to use for program changes on this channel.
Definition midiPlayer.h:682
uint16_t waveIndex
The index of this timbre's wave in the table, when type is WAVETABLE.
uint8_t program
The ID of the program (timbre) set for this channel.
Definition midiPlayer.h:685
uint8_t noteEnd
Definition midiPlayer.h:494
uint32_t on
Whether this note is set to on via MIDI, regardless of if it's making sound.
Definition midiPlayer.h:652
void midiControlChange(midiPlayer_t *player, uint8_t channel, midiControl_t control, uint8_t val)
Set a MIDI control value.
Definition midiPlayer.c:2215
midiPlayerMode_t mode
Whether this player is playing a song or a MIDI stream.
Definition midiPlayer.h:746
uint16_t volume
The 14-bit volume level for this channel only.
Definition midiPlayer.h:679
uint8_t noteStart
Definition midiPlayer.h:493
void midiSetFile(midiPlayer_t *player, const midiFile_t *file)
Configure this MIDI player to read from a MIDI file.
Definition midiPlayer.c:2586
songFinishedCbFn songFinishedCallback
A callback to call when the playing song is finished.
Definition midiPlayer.h:758
void initGlobalMidiPlayer(void)
Initialize the system-wide MIDI players for both BGM and SFX.
Definition midiPlayer.c:2704
uq24_8 error
The number of fractional samples remaining.
timbreFlags_t flags
Flags bitfield for this timbre.
Definition midiPlayer.h:508
void midiPause(midiPlayer_t *player, bool pause)
Set the paused state of a MIDI song.
Definition midiPlayer.c:2605
midiControl_t
Defines the MIDI continuous controller registers.
Definition midiPlayer.h:281
@ MCC_GP_BUTTON_1
Definition midiPlayer.h:342
@ MCC_PAN_LSB
Definition midiPlayer.h:312
@ MCC_OMNI_MODE_ON
Definition midiPlayer.h:373
@ MCC_EFFECT_1_MSB
Definition midiPlayer.h:294
@ MCC_DETUNE_LEVEL
Definition midiPlayer.h:353
@ MCC_BREATH_LSB
Definition midiPlayer.h:304
@ MCC_BANK_LSB
Definition midiPlayer.h:302
@ MCC_MODULATION_WHEEL_MSB
Definition midiPlayer.h:283
@ MCC_PORTAMENTO
Definition midiPlayer.h:320
@ MCC_SOUND_CONTROL_10
Definition midiPlayer.h:340
@ MCC_GP_SLIDER_4
Definition midiPlayer.h:300
@ MCC_FOOT_PEDAL_MSB
Definition midiPlayer.h:286
@ MCC_BALANCE_MSB
Definition midiPlayer.h:290
@ MCC_LOCAL_KEYBOARD
Definition midiPlayer.h:367
@ MCC_FOOT_PEDAL_LSB
Definition midiPlayer.h:306
@ MCC_PAN_MSB
Definition midiPlayer.h:292
@ MCC_SOUND_CONTROL_7
Definition midiPlayer.h:337
@ MCC_REGISTERED_PARAM_MSB
Definition midiPlayer.h:360
@ MCC_VOLUME_LSB
Definition midiPlayer.h:309
@ MCC_OMNI_MODE_OFF
Definition midiPlayer.h:371
@ MCC_HOLD_PEDAL
Definition midiPlayer.h:318
@ MCC_GP_BUTTON_2
Definition midiPlayer.h:344
@ MCC_NON_REGISTERED_PARAM_MSB
Definition midiPlayer.h:358
@ MCC_GP_SLIDER_2
Definition midiPlayer.h:298
@ MCC_ALL_SOUND_OFF
Definition midiPlayer.h:363
@ MCC_HOLD_2_PEDAL
Definition midiPlayer.h:328
@ MCC_PORTAMENTO_TIME_MSB
Definition midiPlayer.h:287
@ MCC_DATA_BUTTON_DEC
Definition midiPlayer.h:356
@ MCC_LEGATO_PEDAL
Definition midiPlayer.h:326
@ MCC_PORTAMENTO_TIME_LSB
Definition midiPlayer.h:307
@ MCC_SOUND_CONTROL_8
Definition midiPlayer.h:338
@ MCC_EFFECT_2_LSB
Definition midiPlayer.h:315
@ MCC_DATA_ENTRY_LSB
Definition midiPlayer.h:308
@ MCC_VOLUME_MSB
Definition midiPlayer.h:289
@ MCC_DATA_BUTTON_INC
Definition midiPlayer.h:355
@ MCC_BREATH_MSB
Definition midiPlayer.h:284
@ MCC_EFFECT_2_MSB
Definition midiPlayer.h:295
@ MCC_SOFT_PEDAL
Definition midiPlayer.h:324
@ MCC_SOUND_VARIATION
Definition midiPlayer.h:329
@ MCC_PHASER_LEVEL
Definition midiPlayer.h:354
@ MCC_CHORUS_LEVEL
Definition midiPlayer.h:352
@ MCC_EFFECT_1_LSB
Definition midiPlayer.h:314
@ MCC_DATA_ENTRY_MSB
Definition midiPlayer.h:288
@ MCC_ALL_CONTROLS_OFF
Definition midiPlayer.h:365
@ MCC_BANK_MSB
Definition midiPlayer.h:282
@ MCC_BALANCE_LSB
Definition midiPlayer.h:310
@ MCC_EXPRESSION_LSB
Definition midiPlayer.h:313
@ MCC_GP_BUTTON_4
Definition midiPlayer.h:348
@ MCC_SOUND_BRIGHTNESS
Definition midiPlayer.h:333
@ MCC_SOUND_TIMBRE
Definition midiPlayer.h:330
@ MCC_SOUND_CONTROL_9
Definition midiPlayer.h:339
@ MCC_MODULATION_WHEEL_LSB
Definition midiPlayer.h:303
@ MCC_GP_SLIDER_3
Definition midiPlayer.h:299
@ MCC_SOUND_ATTACK_TIME
Definition midiPlayer.h:332
@ MCC_SOUND_RELEASE_TIME
Definition midiPlayer.h:331
@ MCC_REGISTERED_PARAM_LSB
Definition midiPlayer.h:359
@ MCC_NON_REGISTERED_PARAM_LSB
Definition midiPlayer.h:357
@ MCC_MONO_OPERATION
Definition midiPlayer.h:375
@ MCC_ALL_NOTE_OFF
Definition midiPlayer.h:369
@ MCC_TREMOLO_LEVEL
Definition midiPlayer.h:351
@ MCC_EFFECTS_LEVEL
Definition midiPlayer.h:350
@ MCC_SOUND_CONTROL_6
Definition midiPlayer.h:335
@ MCC_SUSTENUTO_PEDAL
Definition midiPlayer.h:322
@ MCC_POLY_OPERATION
Definition midiPlayer.h:377
@ MCC_EXPRESSION_MSB
Definition midiPlayer.h:293
@ MCC_GP_SLIDER_1
Definition midiPlayer.h:297
@ MCC_GP_BUTTON_3
Definition midiPlayer.h:346
uint32_t sampleTick
The non-monotonic tick counter for playback of sampled timbres.
Definition midiPlayer.h:573
uint16_t midiGetParameterValue(midiPlayer_t *player, uint8_t channel, bool registered, uint16_t param)
Get the value of a registered or non-registered parameter.
Definition midiPlayer.c:2514
cnfsFileIdx_t fIdx
The file index containing the sample data.
Definition midiPlayer.h:470
void(* songFinishedCbFn)(void)
Callback function used to provide feedback when a song finishes playing.
Definition midiPlayer.h:112
bool ignore
If set, events on this channel will be completely ignored.
Definition midiPlayer.h:712
uint32_t sustain
Bitfield of voices currently in the sustain stage.
Definition midiPlayer.h:658
percussionNote_t
Defines the MIDI note numbers mapped to by the General MIDI percussion note names.
Definition midiPlayer.h:192
@ OPEN_TRIANGLE
This note supersedes any MUTE_TRIANGLE or OPEN_TRIANGLE notes playing.
Definition midiPlayer.h:260
@ COWBELL
Definition midiPlayer.h:227
@ ACOUSTIC_SNARE
Definition midiPlayer.h:206
@ CLOSED_HI_HAT
This note supersedes any CLOSED_HI_HAT, PEDAL_HI_HAT, or OPEN_HI_HAT notes playing.
Definition midiPlayer.h:211
@ LOW_BONGO
Definition midiPlayer.h:232
@ HIGH_BONGO
Definition midiPlayer.h:231
@ CHINESE_CYMBAL
Definition midiPlayer.h:223
@ RIDE_CYMBAL_2
Definition midiPlayer.h:230
@ LONG_GUIRO
This note supersedes any SHORT_GUIRO or LONG_GUIRO notes playing.
Definition midiPlayer.h:249
@ RIDE_BELL
Definition midiPlayer.h:224
@ SHORT_GUIRO
This note supersedes any SHORT_GUIRO or LONG_GUIRO notes playing.
Definition midiPlayer.h:247
@ HIGH_TOM
Definition midiPlayer.h:221
@ MUTE_CUICA
This note supersedes any SHORT_GUIRO or LONG_GUIRO notes playing.
Definition midiPlayer.h:254
@ CABASA
Definition midiPlayer.h:240
@ CRASH_CYMBAL_2
Definition midiPlayer.h:228
@ CRASH_CYMBAL_1
Definition midiPlayer.h:220
@ LOW_MID_TOM
Definition midiPlayer.h:218
@ LOW_AGOGO
Definition midiPlayer.h:239
@ HIGH_TIMBALE
Definition midiPlayer.h:236
@ SIDE_STICK
Definition midiPlayer.h:205
@ RIDE_CYMBAL_1
Definition midiPlayer.h:222
@ ELECTRIC_SNARE_OR_RIMSHOT
Definition midiPlayer.h:208
@ CLAVES
Definition midiPlayer.h:250
@ OPEN_HIGH_CONGA
Definition midiPlayer.h:234
@ LONG_WHISTLE
This note supersedes any SHORT_WHISTLE or LONG_WHISTLE notes playing.
Definition midiPlayer.h:245
@ LOW_TOM
Definition midiPlayer.h:215
@ HIGH_AGOGO
Definition midiPlayer.h:238
@ TAMBOURINE
Definition midiPlayer.h:225
@ HIGH_MID_TOM
Definition midiPlayer.h:219
@ MUTE_HIGH_CONGA
Definition midiPlayer.h:233
@ SPLASH_CYMBAL
Definition midiPlayer.h:226
@ HIGH_WOODBLOCK
Definition midiPlayer.h:251
@ LOW_FLOOR_TOM
Definition midiPlayer.h:209
@ VIBRASLAP
Definition midiPlayer.h:229
@ SHORT_WHISTLE
This note supersedes any SHORT_WHISTLE or LONG_WHISTLE notes playing.
Definition midiPlayer.h:243
@ PEDAL_HI_HAT
This note supersedes any CLOSED_HI_HAT, PEDAL_HI_HAT, or OPEN_HI_HAT notes playing.
Definition midiPlayer.h:214
@ LOW_CONGA
Definition midiPlayer.h:235
@ LOW_TIMBALE
Definition midiPlayer.h:237
@ OPEN_CUICA
This note supersedes any SHORT_GUIRO or LONG_GUIRO notes playing.
Definition midiPlayer.h:256
@ ELECTRIC_BASS_DRUM_OR_HIGH_BASS_DRUM
Definition midiPlayer.h:204
@ LOW_WOODBLOCK
Definition midiPlayer.h:252
@ HIGH_FLOOR_TOM
Definition midiPlayer.h:212
@ MARACAS
Definition midiPlayer.h:241
@ HAND_CLAP
Definition midiPlayer.h:207
@ MUTE_TRIANGLE
This note supersedes any MUTE_TRIANGLE or OPEN_TRIANGLE notes playing.
Definition midiPlayer.h:258
@ OPEN_HI_HAT
This note supersedes any CLOSED_HI_HAT, PEDAL_HI_HAT, or OPEN_HI_HAT notes playing.
Definition midiPlayer.h:217
@ ACOUSTIC_BASS_DRUM_OR_LOW_BASS_DRUM
Definition midiPlayer.h:203
uint8_t chorus
The number of chorused voices to mix.
Definition midiPlayer.h:434
void globalMidiPlayerSetVolume(uint8_t trackType, int32_t volumeSetting)
Set the volume using a value from 0 to 13.
Definition midiPlayer.c:2767
void midiPlayerFillBufferMulti(midiPlayer_t *players, uint8_t playerCount, uint8_t *samples, int16_t len)
Fill a buffer with the next set of samples from an array of MIDI players.
Definition midiPlayer.c:1545
size_t count
The length of the sample map.
uint32_t loopsRemaining
The number of loops remaining before the voice will transition to the released state.
midiPlayer_t * globalMidiPlayerGet(uint8_t trackType)
Return a pointer to the system-wide MIDI player for the given track type, either MIDI_SFX or MIDI_BGM...
Definition midiPlayer.c:2828
uint16_t pitchBend
The 14-bit pitch wheel value.
Definition midiPlayer.h:700
bool(* midiStreamingCallback_t)(midiEvent_t *event)
A function to return MIDI events in streaming mode.
Definition midiPlayer.h:461
void midiSetTempo(midiPlayer_t *player, uint32_t tempo)
Change the MIDI playback tempo.
Definition midiPlayer.c:2578
void * globalMidiSave(void)
Stop all MIDI playback and return a pointer containing the full playback state. This state must be pa...
Definition midiFileParser.c:1037
uq8_24 baseNote
The base frequency, at which the sample plays at normal speed.
Definition midiPlayer.h:476
uint32_t voiceTick
The monotonic tick counter for this voice since starting.
Definition midiPlayer.h:570
int8_t(* percussionFunc_t)(percussionNote_t drum, uint32_t idx, bool *done, uint32_t scratch[4], void *data)
A function that returns samples for a percussion timbre rather than a melodic one.
Definition midiPlayer.h:446
int8_t tune
Fine tuning of the note, +/- 100 cents.
Definition midiPlayer.h:479
void midiPlayerReset(midiPlayer_t *player)
Reset the MIDI player state.
Definition midiPlayer.c:1397
voiceType_t type
The method for obtaining the next audio sample.
Definition midiPlayer.h:592
midiStreamingCallback_t streamingCallback
A callback function to retrieve the next event, when in MIDI_STREAMING mode.
Definition midiPlayer.h:752
timbreFlags_t
A bitfield which may contain various flags for a timbre.
Definition midiPlayer.h:149
@ TF_PERCUSSION
This timbre plays percussion sounds (percussionNote_t) rather than melodic notes.
Definition midiPlayer.h:153
@ TF_MONO
This timbre represents a monophonic instrument.
Definition midiPlayer.h:155
@ TF_NONE
No flags.
Definition midiPlayer.h:151
timbreEffects_t effects
Various effects applied to this timbre. May be ignored by percussion timbres.
Definition midiPlayer.h:547
Describes the characteristics of a particular timbre while.
Definition midiPlayer.h:399
Tracks the state of a single MIDI channel.
Definition midiPlayer.h:677
Tracks the state of the entire MIDI apparatus.
Definition midiPlayer.h:719
Defines the sound characteristics of a particular instrument.
Definition midiPlayer.h:503
Tracks the state of a single voice, playing a single note.
Definition midiPlayer.h:559
Definition midiPlayer.h:492
Definition midiPlayer.h:432
Struct that holds information about a sample that can be played.
Definition midiPlayer.h:468
Holds several bitfields that track the state of each voice for fast access. This may be used for dyna...
Definition midiPlayer.h:650
oscillatorShape_t
The different wave shapes that can be generated.
Definition swSynth.h:65
int8_t(* waveFunc_t)(uint16_t idx, void *data)
Function typedef to return a sample from a wave.
Definition swSynth.h:97
A software oscillator with controllable frequency, amplitude, and shape.
Definition swSynth.h:107