diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2013-09-16 21:26:57 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2013-09-16 21:26:57 -0700 |
commit | 82ba45b3f22a761df6e06ff6a540b91f1aa20fdc (patch) | |
tree | 8b8110a87c488ab3f1b5d5b178fdbb4245abb168 /src/SekaijuApp.cpp | |
parent | 1c58d3924a9ff4a57aee3e3377d473fed7e221f5 (diff) | |
download | sekaiju-82ba45b3f22a761df6e06ff6a540b91f1aa20fdc.tar.gz sekaiju-82ba45b3f22a761df6e06ff6a540b91f1aa20fdc.tar.bz2 sekaiju-82ba45b3f22a761df6e06ff6a540b91f1aa20fdc.zip |
New feature: "MIDI thru" is implemented by bindings from
input ports to output ports which is user-configurable and
stored in the .ini file. Tracks no longer perform "MIDI thru",
but only capture and playback.
Diffstat (limited to 'src/SekaijuApp.cpp')
-rw-r--r-- | src/SekaijuApp.cpp | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/SekaijuApp.cpp b/src/SekaijuApp.cpp index 8fe4eb9..8af01a5 100644 --- a/src/SekaijuApp.cpp +++ b/src/SekaijuApp.cpp @@ -722,6 +722,12 @@ BOOL CSekaijuApp::LoadIniFile () { if (m_strMIDIOutName[0] == _T("")) {
m_strMIDIOutName[0] = _T("MIDI Mapper");
}
+ // [MIDIThruBinding]
+ for (i = 0; i < MAXMIDIINDEVICENUM; i++) {
+ memset (szTemp, 0, sizeof (szTemp));
+ _sntprintf (szTemp, 255, _T("%03d"), i);
+ m_nMIDIThruBinding[i] = GetProfileInt (_T("MIDIThruBinding"), szTemp, i + 1);
+ }
// [MIDIInstDefNorm]
for (i = 0; i < MAXMIDIOUTDEVICENUM; i++) {
memset (szTemp, 0, sizeof (szTemp));
@@ -748,6 +754,8 @@ BOOL CSekaijuApp::LoadIniFile () { _sntprintf (szTemp, 255, _T("%03d"), i);
m_lMIDIOutSyncMode[i] = GetProfileInt (_T("MIDIOutSyncMode"), szTemp, i == 0 ? 1 : 0);
}
+ // [MIDIThroughPatch]
+
// [WindowPlacement]
m_theWindowPlacement.m_bIconic = (BOOL)GetProfileInt (_T("WindowPlacement"), _T("Iconic"), FALSE);
@@ -981,6 +989,12 @@ BOOL CSekaijuApp::SaveIniFile () { CString quotedVal = CString(_T("\"")) + m_strMIDIOutName[i] + _T("\"");
WriteProfileString (_T("MIDIOutDevice"), szTemp, quotedVal);
}
+ // [MIDIThruBinding]
+ for (i = 0; i < MAXMIDIINDEVICENUM; i++) {
+ memset (szTemp, 0, sizeof (szTemp));
+ _sntprintf (szTemp, 255, _T("%03d"), i);
+ WriteProfileInt (_T("MIDIThruBinding"), szTemp, m_nMIDIThruBinding[i]);
+ }
// [MIDIInstDefNorm]
for (i = 0; i < MAXMIDIOUTDEVICENUM; i++) {
memset (szTemp, 0, sizeof (szTemp));
@@ -1528,6 +1542,7 @@ BOOL CSekaijuApp::PlayRecordProc (LPVOID pInfo) { for (i = 0; i < MAXMIDIINDEVICENUM; i++) {
// MIDI入力デバイスが有効ならば
if (m_pMIDIIn[i] != NULL) {
+ int nMidiThru = pSekaijuApp->m_nMIDIThruBinding[i] - 1;
long lMIDIInSyncMode = pSekaijuApp->m_lMIDIInSyncMode[i];
// MIDIメッセージの取得できる限り
while (1) {
@@ -1539,6 +1554,20 @@ BOOL CSekaijuApp::PlayRecordProc (LPVOID pInfo) { }
// MIDIInStatusへの記録
MIDIStatus_PutMIDIMessage (m_pMIDIInStatus[i], byMsg, lLen);
+
+ // ループ
+ if (nMidiThru >= 0 && nMidiThru < MAXMIDIOUTDEVICENUM) {
+ MIDIOut* pMIDIOut = m_pMIDIOut[nMidiThru];
+ if (pMIDIOut)
+ MIDIOut_PutMIDIMessage (pMIDIOut, byMsg, lLen);
+ // MIDIチャンネルメッセージの場合
+ if (0x80 <= byMsg[0] && byMsg[0] <= 0xEF) {
+ MIDIStatus* pMIDIOutStatus = m_pMIDIOutStatus[nMidiThru];
+ if (pMIDIOutStatus)
+ MIDIStatus_PutMIDIMessage (pMIDIOutStatus, byMsg, lLen);
+ }
+ }
+
// アクティブセンシングの場合
if (byMsg[0] == 0xFE) {
;
@@ -1611,28 +1640,11 @@ BOOL CSekaijuApp::PlayRecordProc (LPVOID pInfo) { if (lInputOn && lInputPort == i && lInputChannel == (byMsg[0] & 0x0F)) {
// 出力チャンネルの変換
BYTE byMsg2[sizeof(byMsg)];
- memset (byMsg2, 0, sizeof (byMsg));
memcpy (byMsg2, byMsg, sizeof (byMsg));
if (0 <= lOutputChannel && lOutputChannel < 16) {
byMsg2[0] &= 0xF0;
byMsg2[0] |= (BYTE)lOutputChannel;
}
- // 音出し処理(演奏中でなくかつ録音中でない場合のみ)
- if (!(m_bPlaying && m_bRecording)) {
- MIDIOut* pMIDIOut = NULL;
- MIDIStatus* pMIDIOutStatus = NULL;
- if (0 <= lOutputPort && lOutputPort < MAXMIDIOUTDEVICENUM) {
- pMIDIOut = m_pMIDIOut[lOutputPort];
- pMIDIOutStatus = m_pMIDIOutStatus [lOutputPort];
- }
- if (pMIDIOut) {
- //TODO:MIDIメッセージがループバックする場合下記を無効にしてください。
- MIDIOut_PutMIDIMessage (pMIDIOut, byMsg2, lLen);
- }
- if (pMIDIOutStatus) {
- MIDIStatus_PutMIDIMessage (pMIDIOutStatus, byMsg2, lLen);
- }
- }
// このMIDIメッセージをMIDIデータに記録
if (m_bRecording) {
MIDIEvent* pMIDIEvent = MIDIEvent_Create
@@ -1686,17 +1698,6 @@ BOOL CSekaijuApp::PlayRecordProc (LPVOID pInfo) { long lOutputPort = MIDITrack_GetOutputPort (pMIDITrack);
long lOutputChannel = MIDITrack_GetOutputChannel (pMIDITrack);
if (lInputOn && lInputPort == i && lInputChannel == -1) {
- // 音出し処理(演奏中でなくかつ録音中でない場合のみ)
- if (!(m_bPlaying && m_bRecording)) {
- MIDIOut* pMIDIOut = NULL;
- if (0 <= lOutputPort && lOutputPort < MAXMIDIOUTDEVICENUM) {
- pMIDIOut = m_pMIDIOut[lOutputPort];
- }
- if (pMIDIOut) {
- //TODO:MIDIメッセージがループバックする場合下記を無効にしてください。
- MIDIOut_PutMIDIMessage (pMIDIOut, byMsg, lLen);
- }
- }
// このMIDIメッセージをMIDIデータに記録
if (m_bRecording) {
MIDITrack_InsertSysExEvent
@@ -3494,6 +3495,7 @@ void CSekaijuApp::OnSetupMIDIDevice () { else {
theSheet.m_theMIDIInDevicePage.m_strMIDIInName[i] = m_strMIDIInName[i];
}
+ theSheet.m_theMIDIThruBindingPage.m_nMIDIThruBinding[i] = m_nMIDIThruBinding[i];
}
for (i = 0; i < MAXMIDIOUTDEVICENUM; i++) {
if (m_strMIDIOutName[i] == _T("")) {
@@ -3522,6 +3524,7 @@ void CSekaijuApp::OnSetupMIDIDevice () { if (theSheet.DoModal () == IDOK) {
for (i = 0; i < MAXMIDIINDEVICENUM; i++) {
m_strMIDIInName[i] = theSheet.m_theMIDIInDevicePage.m_strMIDIInName[i];
+ m_nMIDIThruBinding[i] = theSheet.m_theMIDIThruBindingPage.m_nMIDIThruBinding[i];
}
for (i = 0; i < MAXMIDIOUTDEVICENUM; i++) {
m_strMIDIOutName[i] = theSheet.m_theMIDIOutDevicePage.m_strMIDIOutName[i];
|