123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- #include "stdafx.h"
- #include "MIDIEvents.h"
- OPENMPT_NAMESPACE_BEGIN
- namespace MIDIEvents
- {
- uint32 Event(EventType eventType, uint8 midiChannel, uint8 dataByte1, uint8 dataByte2)
- {
- return (eventType << 4) | (midiChannel & 0x0F) | (dataByte1 << 8) | (dataByte2 << 16);
- }
- uint32 CC(MidiCC midiCC, uint8 midiChannel, uint8 param)
- {
- return Event(evControllerChange, midiChannel, static_cast<uint8>(midiCC), param);
- }
- uint32 PitchBend(uint8 midiChannel, uint16 bendAmount)
- {
- return Event(evPitchBend, midiChannel, static_cast<uint8>(bendAmount & 0x7F), static_cast<uint8>(bendAmount >> 7));
- }
- uint32 ProgramChange(uint8 midiChannel, uint8 program)
- {
- return Event(evProgramChange, midiChannel, program, 0);
- }
- uint32 NoteOff(uint8 midiChannel, uint8 note, uint8 velocity)
- {
- return Event(evNoteOff, midiChannel, note, velocity);
- }
- uint32 NoteOn(uint8 midiChannel, uint8 note, uint8 velocity)
- {
- return Event(evNoteOn, midiChannel, note, velocity);
- }
- uint8 System(SystemEvent eventType)
- {
- return static_cast<uint8>((evSystem << 4) | eventType);
- }
- uint8 GetChannelFromEvent(uint32 midiMsg)
- {
- return static_cast<uint8>((midiMsg & 0xF));
- }
- EventType GetTypeFromEvent(uint32 midiMsg)
- {
- return static_cast<EventType>(((midiMsg >> 4) & 0xF));
- }
- uint8 GetDataByte1FromEvent(uint32 midiMsg)
- {
- return static_cast<uint8>(((midiMsg >> 8) & 0xFF));
- }
- uint8 GetDataByte2FromEvent(uint32 midiMsg)
- {
- return static_cast<uint8>(((midiMsg >> 16) & 0xFF));
- }
- uint8 GetEventLength(uint8 firstByte)
- {
- uint8 msgSize = 3;
- switch(firstByte & 0xF0)
- {
- case 0xC0:
- case 0xD0:
- msgSize = 2;
- break;
- case 0xF0:
- switch(firstByte)
- {
- case 0xF1:
- case 0xF3:
- msgSize = 2;
- break;
- case 0xF2:
- msgSize = 3;
- break;
- default:
- msgSize = 1;
- break;
- }
- break;
- }
- return msgSize;
- }
- const char* const MidiCCNames[MIDICC_end + 1] =
- {
- "BankSelect [Coarse]",
- "ModulationWheel [Coarse]",
- "Breathcontroller [Coarse]",
- "",
- "FootPedal [Coarse]",
- "PortamentoTime [Coarse]",
- "DataEntry [Coarse]",
- "Volume [Coarse]",
- "Balance [Coarse]",
- "",
- "Panposition [Coarse]",
- "Expression [Coarse]",
- "EffectControl1 [Coarse]",
- "EffectControl2 [Coarse]",
- "",
- "",
- "GeneralPurposeSlider1",
- "GeneralPurposeSlider2",
- "GeneralPurposeSlider3",
- "GeneralPurposeSlider4",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "BankSelect [Fine]",
- "ModulationWheel [Fine]",
- "Breathcontroller [Fine]",
- "",
- "FootPedal [Fine]",
- "PortamentoTime [Fine]",
- "DataEntry [Fine]",
- "Volume [Fine]",
- "Balance [Fine]",
- "",
- "Panposition [Fine]",
- "Expression [Fine]",
- "EffectControl1 [Fine]",
- "EffectControl2 [Fine]",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "HoldPedal [OnOff]",
- "Portamento [OnOff]",
- "SustenutoPedal [OnOff]",
- "SoftPedal [OnOff]",
- "LegatoPedal [OnOff]",
- "Hold2Pedal [OnOff]",
- "SoundVariation",
- "SoundTimbre",
- "SoundReleaseTime",
- "SoundAttackTime",
- "SoundBrightness",
- "SoundControl6",
- "SoundControl7",
- "SoundControl8",
- "SoundControl9",
- "SoundControl10",
- "GeneralPurposeButton1 [OnOff]",
- "GeneralPurposeButton2 [OnOff]",
- "GeneralPurposeButton3 [OnOff]",
- "GeneralPurposeButton4 [OnOff]",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "EffectsLevel",
- "TremoloLevel",
- "ChorusLevel",
- "CelesteLevel",
- "PhaserLevel",
- "DataButtonIncrement",
- "DataButtonDecrement",
- "NonRegisteredParameter [Fine]",
- "NonRegisteredParameter [Coarse]",
- "RegisteredParameter [Fine]",
- "RegisteredParameter [Coarse]",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "AllSoundOff",
- "AllControllersOff",
- "LocalKeyboard [OnOff]",
- "AllNotesOff",
- "OmniModeOff",
- "OmniModeOn",
- "MonoOperation",
- "PolyOperation",
- };
- }
- OPENMPT_NAMESPACE_END
|