*** empty log message ***
[chuck-blob.git] / v1 / midiio_win32.h
blob0c33f5fb19a5106089bba29a00cb25751575057b
1 /*----------------------------------------------------------------------------
2 ChucK Concurrent, On-the-fly Audio Programming Language
3 Compiler and Virtual Machine
5 Copyright (c) 2004 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.cs.princeton.edu/
7 http://soundlab.cs.princeton.edu/
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 U.S.A.
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
26 // file: midiio.h
27 // desc: midi io header
29 // author: Ge Wang (gewang@cs.princeton.edu)
30 // Perry R. Cook (prc@cs.princeton.edu)
31 //-----------------------------------------------------------------------------
32 #ifndef __MIDI_IO_H__
33 #define __MIDI_IO_H__
35 #include <windows.h>
36 #include <mmsystem.h>
37 #include "util_buffers.h"
42 //-----------------------------------------------------------------------------
43 // stuff
44 //-----------------------------------------------------------------------------
45 #define MIDI_NOTEON 0x90
46 #define MIDI_NOTEOFF 0x80
47 #define MIDI_POLYPRESS 0xa0
48 #define MIDI_CTRLCHANGE 0xb0
49 #define MIDI_PROGCHANGE 0xc0
50 #define MIDI_CHANPRESS 0xd0
51 #define MIDI_PITCHBEND 0xe0
52 #define MIDI_ALLNOTESOFF 0x7b
57 //-----------------------------------------------------------------------------
58 // definitions
59 //-----------------------------------------------------------------------------
60 union MidiMsg
62 BYTE data[4];
63 DWORD dw;
69 //-----------------------------------------------------------------------------
70 // name: class MidiOut
71 // desc: midi out
72 //-----------------------------------------------------------------------------
73 class MidiOut
75 public:
76 MidiOut();
77 ~MidiOut();
79 public:
80 BOOL open( UINT device_num = 0 );
81 BOOL close();
83 public:
84 UINT send( BYTE status );
85 UINT send( BYTE status, BYTE data1 );
86 UINT send( BYTE status, BYTE data1, BYTE data2 );
87 UINT send( const MidiMsg * msg );
89 public:
90 UINT noteon( UINT channel, UINT note, UINT velocity );
91 UINT noteoff( UINT channel, UINT note, UINT velocity );
92 UINT polypress( UINT channel, UINT note, UINT pressure );
93 UINT ctrlchange( UINT channel, UINT ctrl_num, UINT ctrl_val );
94 UINT progchange( UINT channel, UINT patch );
95 UINT chanpress( UINT channel, UINT pressure );
96 UINT pitchbend( UINT channel, UINT bend_val );
97 UINT allnotesoff( UINT channel );
99 public:
100 static void CALLBACK cb_midi_output( HMIDIOUT hm_out, UINT msg,
101 DWORD instance, DWORD param1, DWORD param2 );
103 protected:
104 UINT m_device_num;
105 HMIDIOUT m_midi_out;
111 //-----------------------------------------------------------------------------
112 // name: class MidiIn
113 // desc: midi
114 //-----------------------------------------------------------------------------
115 class MidiIn
117 public:
118 MidiIn();
119 ~MidiIn();
121 public:
122 BOOL open( UINT device_num = 0 );
123 BOOL close();
125 public:
126 UINT recv( MidiMsg * msg );
128 public:
129 static void CALLBACK cb_midi_input( HMIDIIN hm_in, UINT msg,
130 DWORD instance, DWORD param1, DWORD param2 );
132 protected:
133 UINT m_device_num;
134 HMIDIIN m_midi_in;
135 CBuffer m_buffer;
141 #endif