Last active
April 19, 2019 14:06
-
-
Save GOROman/a159a855aee322e13150a4c6957e8780 to your computer and use it in GitHub Desktop.
OVO LED Live control sample code for Windows
This file contains hidden or 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
// | |
// OVO LED Live control sample code for Windows | |
// | |
// 要OVO Firmwareバージョン7以降 | |
// https://www.jdsound.co.jp/products/ovo/manual/ovo_user_manual.pdf | |
#include <Windows.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <mmsystem.h> | |
#pragma comment(lib,"winmm.lib") | |
#define MIDI_CC (0xB0) // コントロールチェンジ | |
#define MIDI_NOTEON (0x90) // ノートオン | |
#define OVO_L_LED1_R (24) // OVO 左側LED 赤1 <C0> | |
#define OVO_R_LED1_B (84) // OVO 右側LED 青1 <C5> | |
#define MIDIMSG(status, data1, data2) ( (DWORD)((status) | ((data1)<<8) | ((data2)<<16)) ) | |
// OVOのMIDI出力デバイス IDを取得 | |
UINT GetOVODeviceID() | |
{ | |
UINT OVOid = -1; | |
// MIDI出力デバイス数を取得 | |
UINT numDevs = midiOutGetNumDevs(); | |
if (numDevs == 0) return OVOid; | |
// MIDI出力デバイスを列挙 | |
MIDIOUTCAPS caps; | |
ZeroMemory(&caps, sizeof(caps)); | |
for (UINT id = 0; id < numDevs; id++) { | |
midiOutGetDevCaps(id, &caps, sizeof(caps)); | |
printf("[%d] %ws\n", id, caps.szPname); | |
// OVOか? | |
if (wcscmp(caps.szPname, L"OVO") == 0) { | |
OVOid = id; | |
} | |
} | |
return OVOid; | |
} | |
int main() | |
{ | |
HMIDIOUT hMidiOut; | |
// OVOを列挙(見つからない場合は-1) | |
UINT OVOid = GetOVODeviceID(); | |
if (OVOid == -1) { | |
printf("Could not find OVO!\n"); | |
return -1; | |
} | |
// MIDI出力デバイスオープン | |
midiOutOpen(&hMidiOut, OVOid, NULL, NULL, 0); | |
// コントロールチェンジ 112番を127 (OVO LED Live有効) | |
midiOutShortMsg(hMidiOut, MIDIMSG(MIDI_CC, 112, 127)); | |
// OVOのLEDを赤に点灯 | |
for (int i = 0; i < 8; i++) { | |
// ノートオン | |
// ノートNo.24 LED RED | |
midiOutShortMsg(hMidiOut, MIDIMSG(MIDI_NOTEON, OVO_L_LED1_R + i, 127)); | |
} | |
// OVOのLEDを青に点灯 | |
for (int i = 0; i < 8; i++) { | |
midiOutShortMsg(hMidiOut, MIDIMSG(MIDI_NOTEON, OVO_R_LED1_B + i, 127)); | |
} | |
// MIDI出力デバイスをクローズ | |
midiOutClose(hMidiOut); | |
return 0; | |
} | |
連続で送るとおかしくなる問題はファームウェア7.1以降では解決
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
連続一気に送るとおかしくなることがあるので調査中