![]() |
wxMidi - A MIDI interface based on PortMidi
|
A database for Midi GM (General MIDI Standard) instruments. More...
#include <wxMidi.h>
Public Member Functions | |
void | PopulateWithInstruments (wxControlWithItems *pCtrol, int nSection, int nInstr=0, bool fAddNumber=false) |
Load control pCtrol with the list of all instruments that belong to section nSection . More... | |
void | PopulateWithPercusionInstr (wxControlWithItems *pCtrol, int iSel=0) |
In the MIDI standard channel 9 is reserved for "key-based" percussion sounds. More... | |
int | PopulateWithSections (wxControlWithItems *pCtrol, int nSelInstr=-1) |
Load control pCtrol with the list of all sections in which the instruments in the GM standard have been organized in the wxMidiDatabaseGM. More... | |
void | PopulateWithAllInstruments (wxControlWithItems *pCtrol, int nInstr=0) |
Load control pCtrol with the list of all instrumens in the GM standard. More... | |
int | GetNumSections () |
Returns the number of sections in which the instruments in the GM standard has been organized. More... | |
int | GetNumInstrumentsInSection (int nSect) |
Returns the number of instruments that are included in section number nSect . More... | |
int | GetInstrFromSection (int nSect, int i) |
Returns the GM number of the n th instrument in section nSect . More... | |
wxString | GetInstrumentName (int nInstr) |
Returns a string with the name of instrument nInstr . More... | |
wxString | GetSectionName (int nSect) |
Returns a string containig the name of section number nSect . More... | |
Static Public Member Functions | |
static wxMidiDatabaseGM * | GetInstance () |
Returns a pointer to the only wxMidiDatabaseGM instance. More... | |
A database for Midi GM (General MIDI Standard) instruments.
See A database for MIDI (General MIDI Standard) instruments for details
|
static |
Returns a pointer to the only wxMidiDatabaseGM instance.
Note that wxMidiDatabaseGM is a singleton and, therefore, the constructor is not public. Access to the only instance must be through this GetInstance() method.
int wxMidiDatabaseGM::GetInstrFromSection | ( | int | nSect, |
int | i | ||
) |
Returns the GM number of the n th instrument in section nSect
.
nSect | The number of the section in which it is included the instrument to retrieve. Must be a number in the range 0 to wxMidiDatabaseGM::GetNumSections() - 1. |
i | The position (0 to GetNumInstrumentsInSection() - 1 ) in section of the instrument whose GM index is desired. Remarks: This method is useful when in your application, the instruments are presented organized into sections instead of in a single list with all GM instruments. In the first case, when the user selects an instrument, it is necessary to translate the pair (section number, instrument number - relative to section -) to the GM standard program number, as in following example: |
wxString wxMidiDatabaseGM::GetInstrumentName | ( | int | nInstr | ) |
Returns a string with the name of instrument nInstr
.
nInstr | The number (0 to 127, according the GM standard) whose name is to be retrieved. |
Remarks: To populate a control (i.e. a combo box) with the names of all instruments you can do it in a single call by using method PopulateWithAllInstruments() instead of doing it inside a loop of calls to GetInstrumentName().
int wxMidiDatabaseGM::GetNumInstrumentsInSection | ( | int | nSect | ) |
Returns the number of instruments that are included in section number nSect
.
In the wxMidiDatabaseGM, the number of instruments in a section is always eight. This method was included to allow for future extensions and to deal with other MIDI standards.
nSect | The number of the section for which the number of instruments in it is desired. Must be a number in the range 0 to wxMidiDatabaseGM::GetNumSections() - 1. |
int wxMidiDatabaseGM::GetNumSections | ( | ) |
Returns the number of sections in which the instruments in the GM standard has been organized.
In the wxMidiDatabaseGM, the number sections is always 16. This method was included to allow for future extensions and to deal with other MIDI standards.
wxString wxMidiDatabaseGM::GetSectionName | ( | int | nSect | ) |
Returns a string containig the name of section number nSect
.
nSect | The number of the section whose name is desired. Must be a number in range 0 to wxMidiDatabaseGM::GetNumSections() - 1. |
Remarks: To populate a control (i.e. a combo box) with the names of all sections you can do it in a single call by using method PopulateWithSections() instead of doing it inside a loop of calls to GetSectionName().
void wxMidiDatabaseGM::PopulateWithAllInstruments | ( | wxControlWithItems * | pCtrol, |
int | nInstr = 0 |
||
) |
Load control pCtrol
with the list of all instrumens in the GM standard.
If nInstr
is specified, the name of that instrument is left selected in the control. Otherwise, the first instrument is left selected.
pCtrol | Pointer to wxControlWithItems object to be initialized and populated. |
nInstr | Number (0 to 127) of the instrument to select. |
Example:
void wxMidiDatabaseGM::PopulateWithInstruments | ( | wxControlWithItems * | pCtrol, |
int | nSection, | ||
int | nInstr = 0 , |
||
bool | fAddNumber = false |
||
) |
Load control pCtrol
with the list of all instruments that belong to section nSection
.
If nInstr
is specified, the name of that instrument is left selected in the control. Otherwise, the first instrument of the section is left selected.
pCtrol | Pointer to wxControlWithItems object to be initialized and populated. |
nSection | The number of the section whose instruments' names are going to be loaded. Must be a number in range 0 to wxMidiDatabaseGM::GetNumSections() - 1. |
nInstr | Number (0 to GetNumInstrumentsInSection() - 1 ) of the instrument to select. |
fAddNumber | When TRUE, instrument number is included in the strings loaded in in the control, i.e. "37 - Side Stick". Otherwise, if FALSE, only the instrument name is generated, i.e. "Side Stick". |
Remarks: This method is useful when in your application, the instruments are presented organized into sections instead of in a single long list with all GM instruments. For example, you have to load a combo box with the list of all sections and other combo box with the list of instruments in currently selected section, as in following example:
void wxMidiDatabaseGM::PopulateWithPercusionInstr | ( | wxControlWithItems * | pCtrol, |
int | iSel = 0 |
||
) |
In the MIDI standard channel 9 is reserved for "key-based" percussion sounds.
For these "key-based" sounds, the note number data in a NoteOn message is used to select which drum sound will be played. For example, a NoteOn message on channel 9 with note number 60 will play a Hi Bongo drum sound. Note number 59 on channel 9 will play the Ride Cymbal 2 sound. Method PopulateWithPercusionInstr() is used to load a control (combo box, list box, or other derived from wxControlWithItems) whit the list of all key-based percussion sounds in the GM standard.
pCtrol | Pointer to wxControlWithItems object to be initialized and populated. |
iSel | Number (35 to 81) of the sound to leave selected in the control. Default value (zero) is for leaving selected the first available sound (35-Acoustic Bass Drum) as well as any out of range value. |
The list of percussion sounds in the GM standard is included here for your conveniece:
iSel | Instrument | iSel | Instrument |
---|---|---|---|
35 | Acoustic Bass Drum | 59 | Ride Cymbal 2 |
36 | Bass Drum 1 | 60 | High Bongo |
37 | Side Stick | 61 | Low Bongo |
38 | Acoustic Snare | 62 | Mute High Conga |
39 | Hand clap | 63 | Open High Conga |
40 | Electric Snare | 64 | Low Conga |
41 | Low Floor Tom | 65 | High Timbale |
42 | Closed High-Hat | 66 | Low Timbale |
43 | High Floor Tom | 67 | High Agogo |
44 | Pedal High-Hat | 68 | Low Agogo |
45 | Low Tom | 69 | Casaba |
46 | Open High-Hat | 70 | Maracas |
47 | Low-Mid Tom | 71 | Short Whistle |
48 | High-Mid Tom | 72 | Long Whistle |
49 | Crash Cymbal 1 | 73 | Short Guiro |
50 | High Tom | 74 | Long Guiro |
51 | Ride Cymbal 1 | 75 | Claves |
52 | Chinese Cymbal | 76 | High Wood Block |
53 | Ride Bell | 77 | Low Wood Block |
54 | Tambourine | 78 | Mute Cuica |
55 | Splash Cymbal | 79 | Open Cuica |
56 | Cowbell | 80 | Mute Triangle |
57 | Crash Cymbal 2 | 81 | Open Triangle |
58 | Vibraslap |
int wxMidiDatabaseGM::PopulateWithSections | ( | wxControlWithItems * | pCtrol, |
int | nSelInstr = -1 |
||
) |
Load control pCtrol
with the list of all sections in which the instruments in the GM standard have been organized in the wxMidiDatabaseGM.
If nSelInstr
is specified, the name of that section is left selected in the control. Otherwise, the first section is left selected.
pCtrol | Pointer to wxControlWithItems object to be initialized and populated. |
nSelInstr | Number (0 to GetNumSections() - 1 ) of the section to select. |
Remarks: This method is useful when in your application, the instruments are presented organized into sections instead of in a single long list with all GM instruments. See an example in method PopulateWithInstruments().