Last active
May 17, 2018 18:35
-
-
Save jpcima/8afc0064fba09a1f3290245f878da4c8 to your computer and use it in GitHub Desktop.
Dynamic instrument API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct ADLMIDI_Bank | |
{ | |
void *pointer[3]; | |
} ADLMIDI_Bank; | |
typedef struct ADLMIDI_BankId | |
{ | |
ADL_UInt8 msb, lsb; | |
ADL_UInt8 percussive; | |
} ADLMIDI_BankId; | |
enum ADLMIDI_BankFlags | |
{ | |
ADLMIDI_Bank_Create = 1, | |
ADLMIDI_Bank_DoNotAllocate = 2, | |
}; | |
typedef struct ADLMIDI_Instrument ADLMIDI_Instrument; | |
/* Preallocates a minimum number of bank slots. Returns the actual capacity. */ | |
extern int adl_reserveBanks(struct ADL_MIDIPlayer *device, unsigned banks); | |
/* Gets the bank designated by the identifier, potentially creating if it does not exist. */ | |
extern int adl_getBank(struct ADL_MIDIPlayer *device, const ADLMIDI_BankId *id, int flags, ADLMIDI_Bank *bank); | |
/* Gets the identifier of a bank. */ | |
extern int adl_getBankId(struct ADL_MIDIPlayer *device, const ADLMIDI_Bank *bank, ADLMIDI_BankId *id); | |
/* Removes a bank. */ | |
extern int adl_removeBank(struct ADL_MIDIPlayer *device, ADLMIDI_Bank *bank); | |
/* Gets the first bank. */ | |
extern int adl_getFirstBank(struct ADL_MIDIPlayer *device, ADLMIDI_Bank *bank); | |
/* Interates to the next bank. */ | |
extern int adl_getNextBank(struct ADL_MIDIPlayer *device, ADLMIDI_Bank *bank); | |
/* Gets the nth intrument in the bank [0..127]. */ | |
extern int adl_getInstrument(struct ADL_MIDIPlayer *device, const ADLMIDI_Bank *bank, unsigned index, ADLMIDI_Instrument *ins); | |
/* Sets the nth intrument in the bank [0..127]. */ | |
extern int adl_setInstrument(struct ADL_MIDIPlayer *device, ADLMIDI_Bank *bank, unsigned index, const ADLMIDI_Instrument *ins); | |
/*--------------------------------------------------------------------*/ | |
/**Instrument structures**/ | |
enum | |
{ | |
ADLMIDI_InstrumentVersion = 0, | |
}; | |
typedef enum ADLMIDI_InstrumentFlags | |
{ | |
/* Is two-operator single-voice instrument (no flags) */ | |
ADLMIDI_Ins_2op = 0x00, | |
/* Is true four-operator instrument */ | |
ADLMIDI_Ins_4op = 0x01, | |
/* Is pseudo four-operator (two 2-operator voices) instrument */ | |
ADLMIDI_Ins_Pseudo4op = 0x02, | |
/* Is a blank instrument entry */ | |
ADLMIDI_Ins_IsBlank = 0x04, | |
/* Mask of the flags range */ | |
ADLMIDI_Ins_ALL_MASK = 0x07, | |
} ADLMIDI_InstrumentFlags; | |
typedef struct ADLMIDI_Operator | |
{ | |
/* AM/Vib/Env/Ksr/FMult characteristics */ | |
ADL_UInt8 avekf_20; | |
/* Key Scale Level / Total level register data */ | |
ADL_UInt8 ksl_l_40; | |
/* Attack / Decay */ | |
ADL_UInt8 atdec_60; | |
/* Systain and Release register data */ | |
ADL_UInt8 susrel_80; | |
/* Wave form */ | |
ADL_UInt8 waveform_E0; | |
} ADLMIDI_Operator; | |
typedef struct ADLMIDI_Instrument | |
{ | |
/* Version of the instrument object */ | |
int version; | |
/* MIDI note key (half-tone) offset for an instrument (or a first voice in pseudo-4-op mode) */ | |
ADL_SInt16 note_offset1; | |
/* MIDI note key (half-tone) offset for a second voice in pseudo-4-op mode */ | |
ADL_SInt16 note_offset2; | |
/* MIDI note velocity offset (taken from Apogee TMB format) */ | |
ADL_SInt8 midi_velocity_offset; | |
/* Second voice detune level (taken from DMX OP2) */ | |
ADL_SInt8 second_voice_detune; | |
/* Percussion MIDI base tone number at which this drum will be played */ | |
ADL_UInt8 percussion_key_number; | |
/* Enum ADLMIDI_InstrumentFlags */ | |
ADL_UInt8 inst_flags; | |
/* Feedback&Connection register for first and second operators */ | |
ADL_UInt8 fb_conn1_C0; | |
/* Feedback&Connection register for third and fourth operators */ | |
ADL_UInt8 fb_conn2_C0; | |
/* Operators register data */ | |
ADLMIDI_Operator operators[4]; | |
/* Millisecond delay of sounding while key is on */ | |
ADL_UInt16 delay_on_ms; | |
/* Millisecond delay of sounding after key off */ | |
ADL_UInt16 delay_off_ms; | |
} ADLMIDI_Instrument; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment