Improve audio and midi support.
This commit is contained in:
parent
9bcc0ae88e
commit
8b5f485d1e
47 changed files with 1446 additions and 634 deletions
|
@ -9,16 +9,16 @@ MidiChannelEvent::MidiChannelEvent()
|
|||
|
||||
}
|
||||
|
||||
std::shared_ptr<MidiChannelEvent> MidiChannelEvent::Create()
|
||||
std::unique_ptr<MidiChannelEvent> MidiChannelEvent::Create()
|
||||
{
|
||||
return std::make_shared<MidiChannelEvent>();
|
||||
return std::make_unique<MidiChannelEvent>();
|
||||
}
|
||||
|
||||
void MidiChannelEvent::SetType(Type type)
|
||||
{
|
||||
mType = type;
|
||||
}
|
||||
MidiChannelEvent::Type MidiChannelEvent::GetType()
|
||||
MidiChannelEvent::Type MidiChannelEvent::GetType() const
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
|
@ -27,54 +27,88 @@ void MidiChannelEvent::SetValues(int value0, int value1)
|
|||
mValue0 = value0;
|
||||
mValue1 = value1;
|
||||
}
|
||||
int MidiChannelEvent::GetValue0()
|
||||
int MidiChannelEvent::GetValue0() const
|
||||
{
|
||||
return mValue0;
|
||||
}
|
||||
int MidiChannelEvent::GetValue1()
|
||||
int MidiChannelEvent::GetValue1() const
|
||||
{
|
||||
return mValue1;
|
||||
}
|
||||
|
||||
bool MidiChannelEvent::IsControllerEvent(int c)
|
||||
void MidiChannelEvent::SetTypeAndChannel(char c)
|
||||
{
|
||||
return (c & CONTROLLER) == CONTROLLER;
|
||||
}
|
||||
const int first_four_bits = 0xF0;
|
||||
const int second_four_bits = 0xF;
|
||||
const int event_type = (c & first_four_bits) >> 4;
|
||||
|
||||
bool MidiChannelEvent::IsNoteOnEvent(int c)
|
||||
{
|
||||
return (c & NOTE_ON) == NOTE_ON;
|
||||
}
|
||||
|
||||
bool MidiChannelEvent::IsNoteOffEvent(int c)
|
||||
{
|
||||
return (c & NOTE_OFF) == NOTE_OFF;
|
||||
}
|
||||
|
||||
bool MidiChannelEvent::IsNoteAfterTouchEvent(int c)
|
||||
{
|
||||
return (c & NOTE_AFTERTOUCH) == NOTE_AFTERTOUCH;
|
||||
}
|
||||
|
||||
bool MidiChannelEvent::IsProgramEvent(int c)
|
||||
{
|
||||
return (c & PROGRAM) == PROGRAM;
|
||||
}
|
||||
|
||||
bool MidiChannelEvent::IsChannelAftertouchEvent(int c)
|
||||
{
|
||||
return (c & CHANNEL_AFTERTOUCH) == CHANNEL_AFTERTOUCH;
|
||||
}
|
||||
|
||||
bool MidiChannelEvent::IsPitchbendEvent(int c)
|
||||
{
|
||||
return (c & PITCH_BEND) == PITCH_BEND;
|
||||
}
|
||||
|
||||
bool MidiChannelEvent::IsStatusByte(int c)
|
||||
{
|
||||
return IsControllerEvent(c) || IsNoteOnEvent(c) ||
|
||||
IsNoteOffEvent(c) || IsNoteAfterTouchEvent(c) ||
|
||||
IsProgramEvent(c) || IsChannelAftertouchEvent(c) ||
|
||||
IsPitchbendEvent(c);
|
||||
const bool isSystemMessage = event_type == 0xF;
|
||||
if(!isSystemMessage)
|
||||
{
|
||||
mChannel = (c & second_four_bits) >> 4;
|
||||
switch(event_type)
|
||||
{
|
||||
case NOTE_OFF:
|
||||
mType = Type::NOTE_OFF;
|
||||
break;
|
||||
case NOTE_ON:
|
||||
mType = Type::NOTE_ON;
|
||||
break;
|
||||
case NOTE_AFTERTOUCH:
|
||||
mType = Type::NOTE_AFTERTOUCH;
|
||||
break;
|
||||
case CONTROLLER:
|
||||
mType = Type::CONTROLLER;
|
||||
break;
|
||||
case PROGRAM:
|
||||
mType = Type::PROGRAM;
|
||||
break;
|
||||
case CHANNEL_AFTERTOUCH:
|
||||
mType = Type::CHANNEL_AFTERTOUCH;
|
||||
break;
|
||||
case PITCH_BEND:
|
||||
mType = Type::PITCH_BEND;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const int subType = (c & second_four_bits) >> 4;
|
||||
switch(subType)
|
||||
{
|
||||
case SYS_EXCLUSIVE:
|
||||
mType = Type::SYS_EXCLUSIVE;
|
||||
break;
|
||||
case SYS_SONG_POS:
|
||||
mType = Type::SYS_SONG_POS;
|
||||
break;
|
||||
case SYS_SONG_SELECT:
|
||||
mType = Type::SYS_SONG_SELECT;
|
||||
break;
|
||||
case SYS_TUNE_REQUEST:
|
||||
mType = Type::SYS_TUNE_REQUEST;
|
||||
break;
|
||||
case SYS_END_EXCLUSIVE:
|
||||
mType = Type::SYS_END_EXCLUSIVE;
|
||||
break;
|
||||
case SYS_TIMING_CLOCK:
|
||||
mType = Type::SYS_TIMING_CLOCK;
|
||||
break;
|
||||
case SYS_START:
|
||||
mType = Type::SYS_START;
|
||||
break;
|
||||
case SYS_CONTINUE:
|
||||
mType = Type::SYS_CONTINUE;
|
||||
break;
|
||||
case SYS_STOP:
|
||||
mType = Type::SYS_STOP;
|
||||
break;
|
||||
case SYS_ACTIVE_SENSING:
|
||||
mType = Type::SYS_ACTIVE_SENSING;
|
||||
break;
|
||||
case SYS_RESET:
|
||||
mType = Type::SYS_RESET;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue