Windows Apps
修订版 | 69d230b08e1f13b450a98c0a5e2a3972aa5e382c (tree) |
---|---|
时间 | 2014-07-06 19:53:24 |
作者 | oga <oga@mxg....> |
Commiter | oga |
V1.04-18 support specify midifile argument
V0.50-16 fix 0xff data length prob.
@@ -33,4 +33,6 @@ ToDo | ||
33 | 33 | #Tempoが効かないことがある件調査(Exメッセージ処理不正対策で解決?) |
34 | 34 | (8)キーボード和音押し表示対応 V1.04-16 |
35 | 35 | (9)midiファイルを引数で再生できるようにする。 V1.04-18 |
36 | +(10)Hoedown.midで無限ループする (ff03の文字列長の複数バイト処理不足) V0.50-16 | |
37 | + | |
36 | 38 |
@@ -800,11 +800,16 @@ int len; | ||
800 | 800 | * ffxxLLDDDDDDD... |
801 | 801 | */ |
802 | 802 | cmd1 = buf[pt]; /* 0xff */ |
803 | - cmd2 = buf[pt+1]; /* sub command */ | |
803 | + cmd2 = buf[pt+1]; /* sub command */ | |
804 | 804 | nlen = buf[pt+2]; /* command len */ |
805 | - pt += 3; /* skip ffxxLL */ | |
805 | + pt += 3; /* skip ffxxLL */ | |
806 | + | |
807 | + nlen = GetDeltaTime(&buf[pt-1], codebuf, &size); /* get strlen V0.20-A V0.50-16-A */ | |
808 | + pt += (size-1); /* skip ffxx<LL..> V0.20-A V0.50-16-A */ | |
809 | + | |
810 | + strcpy(&codebuf[strlen(codebuf)-1], " :"); /* V0.20-A V0.50-16-A */ | |
811 | + printf("%02x %02x %s ", cmd1, cmd2, codebuf); /* V0.15-C V0.20-C V0.50-16-A */ | |
806 | 812 | |
807 | - printf("%02x %02x %02x : ",cmd1,cmd2,nlen); /* V0.15-C */ | |
808 | 813 | switch (cmd2) { |
809 | 814 | case 0x00: /* ff00 02 ssss Sequence Number V0.16-A */ |
810 | 815 | /* シーケンス番号(format 2 only) len:2 */ |
@@ -844,16 +849,16 @@ int len; | ||
844 | 849 | * ("Introduction" とか "A", "B" など) |
845 | 850 | */ |
846 | 851 | printf("SUB(06):Marker : "); |
847 | - PutTextData(&buf[pt], nlen); | |
848 | - break; | |
852 | + PutTextData(&buf[pt], nlen); | |
853 | + break; | |
849 | 854 | case 0x07: /* ff07 Queue Point */ |
850 | 855 | /* キューポイント: 曲データ中、このメタイベントの |
851 | 856 | * 挿入されている位置で、 その曲以外の進行を記述する |
852 | 857 | * のに用いる。 (曲中の進行の記述には、マーカーを用いる) |
853 | 858 | */ |
854 | 859 | printf("SUB(07):Queue Point : "); |
855 | - PutTextData(&buf[pt], nlen); | |
856 | - break; | |
860 | + PutTextData(&buf[pt], nlen); | |
861 | + break; | |
857 | 862 | case 0x20: /* ff20 01 cc MIDI channel prefix V0.16-A */ |
858 | 863 | /* MIDIチャンネルプリフィックス(len:1) */ |
859 | 864 | val = buf[pt]; /* prefix */ |
@@ -1235,6 +1240,10 @@ int trknm; | ||
1235 | 1240 | cmd2 = buf[pt+1]; /* sub command */ |
1236 | 1241 | nlen = buf[pt+2]; /* command len */ |
1237 | 1242 | pt += 3; /* skip ffxxLL */ |
1243 | + | |
1244 | + nlen = GetDeltaTime(&buf[pt-1], codebuf, &size); /* get strlen V0.20-A V0.50-16-A */ | |
1245 | + pt += (size-1); /* skip ffxx<LL..> V0.20-A V0.50-16-A */ | |
1246 | + | |
1238 | 1247 | switch(cmd2) { |
1239 | 1248 | case 0x51: /* ff51 03 tttttt Set Tempo */ |
1240 | 1249 | tempo = buf[pt]*256*256 + buf[pt+1]*256 + buf[pt+2]; /* tempo */ |
@@ -13,11 +13,11 @@ Class2=CWkeyboardDlg | ||
13 | 13 | Class3=CAboutDlg |
14 | 14 | |
15 | 15 | ResourceCount=4 |
16 | -Resource1=IDD_SELINST_DLG | |
16 | +Resource1=IDD_ABOUTBOX | |
17 | 17 | Resource2=IDR_MAINFRAME |
18 | -Resource3=IDD_ABOUTBOX | |
18 | +Resource3=IDD_WKEYBOARD_DIALOG | |
19 | 19 | Class4=CSelectInst |
20 | -Resource4=IDD_WKEYBOARD_DIALOG | |
20 | +Resource4=IDD_SELINST_DLG | |
21 | 21 | |
22 | 22 | [CLS:CWkeyboardApp] |
23 | 23 | Type=0 |
@@ -530,6 +530,16 @@ BOOL CWkeyboardDlg::OnInitDialog() | ||
530 | 530 | |
531 | 531 | ClearPushRect2(); |
532 | 532 | // V1.04-A end |
533 | + | |
534 | + // 引数取得 V1.04-18-A start | |
535 | + char wk[4096]; | |
536 | + GetArg(GetCommandLine(), wk, 2); | |
537 | + if (strlen(wk)) { | |
538 | + // ファイル指定あり | |
539 | + strcpy(mFname, wk); | |
540 | + ReadMidiFile(); | |
541 | + } | |
542 | + // V1.04-18-A end | |
533 | 543 | |
534 | 544 | // oga end |
535 | 545 |
@@ -1828,13 +1838,32 @@ void CWkeyboardDlg::OnTimer(UINT nIDEvent) | ||
1828 | 1838 | } |
1829 | 1839 | |
1830 | 1840 | // V1.04-A start |
1841 | +// V1.04-18-A start | |
1842 | +void CWkeyboardDlg::ReadMidiFile() | |
1843 | +{ | |
1844 | + char work[4096]; | |
1845 | + | |
1846 | + // MIDIデータ読込み | |
1847 | + if (MidiRead(mFname) == 0) { | |
1848 | + // 再生ボタン有効 | |
1849 | + SetPlayButtons(TRUE); | |
1850 | + | |
1851 | + // タイトルバーにファイル名表示 | |
1852 | + sprintf(work, "wkeyboard - %s", mFname); | |
1853 | + SetWindowText(work); | |
1854 | + } | |
1855 | + | |
1856 | + // 自動再生 | |
1857 | + OnBtnPlay(); | |
1858 | +} | |
1859 | +// V1.04-18-A end | |
1860 | + | |
1831 | 1861 | void CWkeyboardDlg::OnDropFiles( HDROP hDropInfo ) |
1832 | 1862 | { |
1833 | 1863 | // Drag & Drop時の処理 |
1834 | 1864 | int i; |
1835 | 1865 | int size; |
1836 | 1866 | int nfiles = 0; |
1837 | - char work[4096]; | |
1838 | 1867 | |
1839 | 1868 | SetWindowText("wkeyboard"); |
1840 | 1869 |
@@ -1848,16 +1877,7 @@ void CWkeyboardDlg::OnDropFiles( HDROP hDropInfo ) | ||
1848 | 1877 | /* fnameにそれぞれのドラッグされたファイルが入る(複数あった場合最後だけ有効) */ |
1849 | 1878 | } |
1850 | 1879 | |
1851 | - // MIDIデータ読込み | |
1852 | - if (MidiRead(mFname) == 0) { | |
1853 | - // 再生ボタン有効 | |
1854 | - SetPlayButtons(TRUE); | |
1855 | - | |
1856 | - // タイトルバーにファイル名表示 | |
1857 | - sprintf(work, "wkeyboard - %s", mFname); | |
1858 | - SetWindowText(work); | |
1859 | - } | |
1860 | - | |
1880 | + ReadMidiFile(); // V1.04-18-C | |
1861 | 1881 | } |
1862 | 1882 | |
1863 | 1883 | // SetPlayButtons() |
@@ -1995,4 +2015,46 @@ void CWkeyboardDlg::OnBtnSelinst() | ||
1995 | 2015 | dlg.DoModal(); |
1996 | 2016 | } |
1997 | 2017 | |
2018 | + | |
2019 | +// V1.04-18-A start | |
2020 | +// | |
2021 | +// Get Argument from Command Line | |
2022 | +// | |
2023 | + | |
2024 | +void CWkeyboardDlg::GetArg(char *line, char *arg, int pos) | |
2025 | +{ | |
2026 | + char *pt = line; | |
2027 | + int i, j; | |
2028 | + | |
2029 | + arg[0] = '\0'; | |
2030 | + | |
2031 | + for (i = 0; i<pos; i++) { | |
2032 | + j = 0; | |
2033 | + if (*pt == '"') { | |
2034 | + ++pt; | |
2035 | + while(*pt != '"' && *pt != '\0') { | |
2036 | + arg[j++] = *pt; | |
2037 | + ++pt; | |
2038 | + } | |
2039 | + arg[j] = '\0'; | |
2040 | + ++pt; | |
2041 | + } else { | |
2042 | + while(*pt != ' ' && *pt != '\0') { | |
2043 | + arg[j++] = *pt; | |
2044 | + ++pt; | |
2045 | + } | |
2046 | + arg[j] = '\0'; | |
2047 | + } | |
2048 | + while (*pt == ' ') ++pt; // skip arg sep. | |
2049 | + if (*pt == '\0') { | |
2050 | + break; | |
2051 | + } | |
2052 | + } | |
2053 | + //MessageBox(arg); | |
2054 | + if (i != pos-1) { | |
2055 | + arg[0] = '\0'; // no arg for pos | |
2056 | + } | |
2057 | +} | |
2058 | +// V1.04-18-A end | |
2059 | + | |
1998 | 2060 | // V1.04-A end |
@@ -103,25 +103,27 @@ protected: | ||
103 | 103 | char mFname[2048]; // MIDIファイル名 V1.04-A |
104 | 104 | int mposx[GT_NFRET+1]; // ギターフレットの位置 V1.04-13-A |
105 | 105 | |
106 | - void DrawKeyBoard(CDC *pDC); | |
107 | - void DrawGuitar(CDC *pDC); // V1.01-A | |
108 | - void DrawLine(CDC *pDC, int x1, int y1, int x2, int y2, int abs); | |
109 | - void WinMidiShortMsg(MidiInst *pminst, DWORD dwMsg); | |
110 | - void WinMidiClose(MidiInst *pminst); | |
111 | - void WinMidiOpen(MidiInst *pminst); | |
112 | - void CALLBACK WinMidiOutCB(HMIDIOUT hmo, UINT wMsg, DWORD dwinst, DWORD param1, DWORD param2); | |
113 | - int GetToneNo(CPoint point, int push); // V1.04-C | |
114 | - int GetToneNoFromKey(UINT nChar, int push); // V1.04-C | |
115 | - int GetRectFromTone(int tone, int ch, CRect *pRect, int *pWhite); // V1.04-C | |
116 | - void DelRectFromTone(int tone); // for mPushRect2 V1.04-A | |
117 | - int GetMilliSec(); // V1.03-A | |
118 | - void CalcTempo(); // V1.03-A | |
119 | - BOOL PreTranslateMessage(MSG* pMsg); // キーの事前補足 | |
120 | - void ClearPushRect2(); // V1.04-A | |
121 | - void CWkeyboardDlg::SetPlayButtons(BOOL sw); // V1.04-A | |
122 | - | |
123 | - // Cの関数ポインタ代入のため、ヘッダ側でsttic定義 | |
124 | - static void MidiCallback(unsigned int cmd); // V1.04-A | |
106 | + void DrawKeyBoard(CDC *pDC); | |
107 | + void DrawGuitar(CDC *pDC); // V1.01-A | |
108 | + void DrawLine(CDC *pDC, int x1, int y1, int x2, int y2, int abs); | |
109 | + void WinMidiShortMsg(MidiInst *pminst, DWORD dwMsg); | |
110 | + void WinMidiClose(MidiInst *pminst); | |
111 | + void WinMidiOpen(MidiInst *pminst); | |
112 | + void CALLBACK WinMidiOutCB(HMIDIOUT hmo, UINT wMsg, DWORD dwinst, DWORD param1, DWORD param2); | |
113 | + int GetToneNo(CPoint point, int push); // V1.04-C | |
114 | + int GetToneNoFromKey(UINT nChar, int push); // V1.04-C | |
115 | + int GetRectFromTone(int tone, int ch, CRect *pRect, int *pWhite); // V1.04-C | |
116 | + void DelRectFromTone(int tone); // for mPushRect2 V1.04-A | |
117 | + int GetMilliSec(); // V1.03-A | |
118 | + void CalcTempo(); // V1.03-A | |
119 | + BOOL PreTranslateMessage(MSG* pMsg); // キーの事前補足 | |
120 | + void ClearPushRect2(); // V1.04-A | |
121 | + void SetPlayButtons(BOOL sw); // V1.04-A | |
122 | + void GetArg(char *line, char *arg, int pos); // V1.04-18-A | |
123 | + void ReadMidiFile(); // V1.04-18-A | |
124 | + | |
125 | + // Cの関数ポインタ代入のため、ヘッダ側でstatic定義 | |
126 | + static void MidiCallback(unsigned int cmd); // V1.04-A | |
125 | 127 | |
126 | 128 | |
127 | 129 | // 生成されたメッセージ マップ関数 |