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
23 -----------------------------------------------------------------------------*/
25 //-----------------------------------------------------------------------------
27 // desc: midi io header
29 // author: Ge Wang (gewang@cs.princeton.edu)
30 // Perry R. Cook (prc@cs.princeton.edu)
31 //-----------------------------------------------------------------------------
37 #include "util_buffers.h"
42 //-----------------------------------------------------------------------------
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 //-----------------------------------------------------------------------------
59 //-----------------------------------------------------------------------------
69 //-----------------------------------------------------------------------------
70 // name: class MidiOut
72 //-----------------------------------------------------------------------------
80 BOOL
open( UINT device_num
= 0 );
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
);
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
);
100 static void CALLBACK
cb_midi_output( HMIDIOUT hm_out
, UINT msg
,
101 DWORD instance
, DWORD param1
, DWORD param2
);
111 //-----------------------------------------------------------------------------
112 // name: class MidiIn
114 //-----------------------------------------------------------------------------
122 BOOL
open( UINT device_num
= 0 );
126 UINT
recv( MidiMsg
* msg
);
129 static void CALLBACK
cb_midi_input( HMIDIIN hm_in
, UINT msg
,
130 DWORD instance
, DWORD param1
, DWORD param2
);