1 /*
2     midiout.h:
3 
4     Copyright (C) 1997 Gabriel Maldonado, John ffitch
5 
6     This file is part of Csound.
7 
8     The Csound Library is free software; you can redistribute it
9     and/or modify it under the terms of the GNU Lesser General Public
10     License as published by the Free Software Foundation; either
11     version 2.1 of the License, or (at your option) any later version.
12 
13     Csound is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU Lesser General Public License for more details.
17 
18     You should have received a copy of the GNU Lesser General Public
19     License along with Csound; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21     02110-1301 USA
22 */
23 
24 /****************************************/
25 /** midiout UGs by Gabriel Maldonado   **/
26 /****************************************/
27 
28 typedef int BOOL;
29 #ifndef TRUE
30 #   define TRUE (1)
31 #endif
32 #ifndef FALSE
33 #   define FALSE (0)
34 #endif
35 
36 typedef struct {
37     OPDS   h;
38     MYFLT  *r;
39 } REL;
40 
41 typedef struct {
42     OPDS   h;
43     MYFLT  *extradur;
44 } XTRADUR;
45 
46 typedef struct {
47     OPDS        h;
48     MYFLT       *freq;
49     MYFLT       period, clock_tics;
50     int         beginning_flag;
51 } MCLOCK;
52 
53 typedef struct {
54     OPDS        h;
55     MYFLT       *message;
56 } MRT;
57 
58 typedef struct {
59     OPDS   h;
60     MYFLT  *ichn,*inum,*ivel;
61 } OUT_ON;
62 
63 typedef struct {
64     OPDS   h;
65     MYFLT  *ichn,*inum,*ivel,*idur;
66     MYFLT  istart_time;
67     int    chn, num, vel;
68     BOOL   fl_expired, fl_extra_dur;
69 } OUT_ON_DUR;
70 
71 typedef struct {
72     OPDS   h;
73     MYFLT  *kchn,*knum,*kvel,*kdur,*kpause;
74     MYFLT  istart_time;
75     int    last_chn, last_num, last_vel;
76     MYFLT  last_dur, last_pause;
77     BOOL   fl_note_expired, fl_first_note, fl_end_note;
78 } MOSCIL;
79 
80 typedef struct {
81     OPDS   h;
82     MYFLT  *kchn,*knum,*kvel;
83     int    last_chn, last_num, last_vel;
84     BOOL   fl_note_expired, fl_first_note;
85 } KOUT_ON;
86 
87 typedef struct {
88     OPDS   h;
89     MYFLT  *chn,*num, *value, *min, *max;
90   int    last_value, lastchn, lastctrl;
91 } OUT_CONTR;
92 
93 typedef struct {
94     OPDS   h;
95     MYFLT  *chn, *msb_num, *lsb_num, *value, *min, *max;
96     int    last_value, lastchn, lastctrl;
97 } OUT_CONTR14;
98 
99 typedef struct {
100     OPDS   h;
101     MYFLT  *chn, *value, *min, *max;
102   int    last_value,  lastchn;
103 } OUT_PB;
104 
105 typedef struct {
106     OPDS   h;
107     MYFLT  *chn, *value, *min, *max;
108   int    last_value,  lastchn;
109 } OUT_ATOUCH;
110 
111 typedef struct {
112     OPDS   h;
113     MYFLT  *chn, *prog_num, *min, *max;
114   int    last_prog_num,  lastchn;
115 } OUT_PCHG;
116 
117 typedef struct {
118     OPDS   h;
119     MYFLT  *chn, *num, *value, *min, *max;
120   int    last_value, lastchn, lastctrl;
121 } OUT_POLYATOUCH;
122 
123 typedef struct {
124     OPDS   h;
125     MYFLT  *kchn,*knum,*kvel,*ktrig;
126         int     last_chn, last_num, last_vel;
127         BOOL fl_note_expired/*, fl_first_note*/;
128 } KON2;
129 
130 typedef struct {
131     OPDS   h;
132     MYFLT  *in_type, *in_chan, *in_dat1, *in_dat2;
133 } MIDIOUT;
134 
135 typedef struct {
136     OPDS   h;
137     MYFLT  *chan, *parm_num, *parm_value;
138     int old_chan, old_parm, old_value;
139 } NRPN;
140 
141 typedef struct {
142     unsigned char status;
143     unsigned char dat1;
144     unsigned char dat2;
145     MYFLT   delay;
146 } DELTAB;
147 
148 #define DELTAB_LENGTH 1000
149 
150 typedef struct {
151     OPDS   h;
152     MYFLT  *in_status, *in_chan, *in_dat1, *in_dat2, *kdelay;
153     unsigned char status[DELTAB_LENGTH];
154     unsigned char chan[DELTAB_LENGTH];
155     unsigned char dat1[DELTAB_LENGTH];
156     unsigned char dat2[DELTAB_LENGTH];
157     MYFLT             time[DELTAB_LENGTH];
158     unsigned int  write_index, read_index;
159 } MDELAY;
160