OSDN Git Service

最初のコミット
[winaudioj/stedx.git] / rcp.h
1 /** @file
2   RCP converter
3
4   Copyright 1999 by Daisuke Nagano <breeze.nagano@nifty.ne.jp>
5   Feb.05.1999
6   Oct.16.2002
7
8
9   Permission is hereby granted, free of charge, to any person obtaining a copy
10   of this software and associated documentation files (the "Software"), to deal
11   in the Software without restriction, including without limitation the rights
12   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13   copies of the Software, and to permit persons to whom the Software is
14   furnished to do so, subject to the following conditions:
15
16   The above copyright notice and this permission notice shall be included in
17   all copies or substantial portions of the Software.
18
19   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
22   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25   THE SOFTWARE.
26 */
27 #pragma once
28 #ifndef _RCP_H_
29 #define _RCP_H_
30
31 #define FLAG_TRUE  1
32 #define FLAG_FALSE 0
33
34 #define RCP_HEADER_STRING        "RCM-PC98V2.0(C)COME ON MUSIC"
35 #define STEDDATA_HEADER_STRING   "STEDDATAx.xxDedicatedToTURBO"
36
37 #define RCP_MAX_TRACKS           36
38 #define RCP_MAX_USER_EXCLUSIVE   8
39 #define RCP_MAX_COMMENT_SIZE     36
40 #define RCP_MAX_NOTES            128
41 #define RCP_MAX_LOOPS            128
42
43 #define RCP_MAX_RESULT_SMF_SIZE  256
44 #define RCP_USER_EXCLUSIVE_SIZE  24
45
46 #define RCP_DEFAULT_SMF_SIZE     65536
47
48 #define ENABLE_PORT_CHANGE
49
50 /* structs */
51
52 /** ループ構造体 */
53 typedef struct _LOOP_DATA {
54   int top_ptr;/**< 開始位置 */
55   int loop_count;/**< ループ回数 */
56   int same_measure_flag;/**< */
57   int same_measure_ptr;/**< */
58
59 } LOOP_DATA;
60
61 typedef struct _RCP_TRACK {
62   int           top;                        /**< base pointer */
63   int           size;                       /**< data size */
64   int           midi_ch;                    /**< midi channel */
65   int           port;                       /**< midi port (0 to 15 ) */
66   int           key;                        /**< key offset */
67   int           st;                         /**< step offset */
68   int           mode;                       /**< mode */
69                                             /**< comment */
70   unsigned char comment[RCP_MAX_COMMENT_SIZE];
71
72   /* track work */
73
74   int           enabled;
75   int           finished;
76
77   int           current_ptr;
78   long          delta_step;
79   long          total_step;
80
81   int           event;
82   int           step;
83   int           gate;
84   int           vel;
85
86   int           notes[RCP_MAX_NOTES];
87   int           notes_min;
88   int           notes_max;
89   int           all_notes_expired;
90
91   int           yamaha_base[2];
92   int           roland_base[2];
93
94   int           loop_depth;
95   LOOP_DATA     loop[RCP_MAX_LOOPS];
96
97   int           same_measure_flag;
98   int           same_measure_ptr;
99
100   unsigned char *smf;
101   int           smf_ptr;
102
103 } RCP_TRACK;
104
105 typedef struct _RCP_DATA {
106
107   unsigned char *data;        /* data */
108   size_t         length;      /* data length */
109   unsigned char *file_name;   /* original RCP/G36 filename */
110   unsigned char *date;        /* original RCP/R36 timestamp */
111   unsigned char *command_name;/* command name ( typically "rcptomid" ) */
112   unsigned char *copyright;   /* copyright notice */
113
114   int g36;                    /* flag for G18/G36 format */
115   int rcp;                    /* flag for RCP/R36 format */
116   int steddata;               /* flag for STED3 format */
117
118   unsigned char  title[65];   /* data title ( perhaps SJIS ) */
119   unsigned char  memo[337];   /* memo */
120
121   int timebase;               /* timebase */
122   int tempo;                  /* tempo */
123   int realtempo;              /* tempo (Beat per minute) */
124   int rtm_delta;              /* timebase / 24 */
125   int beat_h;                 /* beat */
126   int beat_l;                 /* beat */
127
128   int key;                    /* key */
129   int play_bias;              /* play bias */
130
131   int tracks;                 /* track number (RCP:18 R36:26) */
132
133   long step;                  /* total step */
134
135                               /* user exclusive */
136   int user_exclusive[RCP_MAX_USER_EXCLUSIVE][24];
137   int yamaha_dev_id;
138   int yamaha_model_id;
139   int roland_dev_id;
140   int roland_model_id;
141
142                               /* track work area */
143
144   RCP_TRACK track[RCP_MAX_TRACKS];
145
146   int result_smf[RCP_MAX_RESULT_SMF_SIZE];
147
148   unsigned char *smf_tempo_track;
149   int            smf_tempo_track_ptr;
150
151   unsigned char *smf_data;
152   int            smf_size;
153
154   int            enable_converter_notice;
155   int            enable_verbose;
156
157   /* player's informations */
158
159   char          *output_device;
160   int            is_player;
161   int            is_send_rtm;
162   int            is_buffered;
163
164   long           timer_sec;
165   long           timer_usec;
166
167   void*          rcd;
168 } RCP_DATA;
169
170  void           error_end( char *);
171  RCP_DATA      *rcp_read_file( char * );
172  int            rcp_close( RCP_DATA * );
173
174  unsigned char *rcptomid( RCP_DATA * );
175
176
177 /* RCP data structure definition */
178
179 #define RCP_USER_EXCLUSIVE_1         0x90
180 #define RCP_USER_EXCLUSIVE_2         0x91
181 #define RCP_USER_EXCLUSIVE_3         0x92
182 #define RCP_USER_EXCLUSIVE_4         0x93
183 #define RCP_USER_EXCLUSIVE_5         0x94
184 #define RCP_USER_EXCLUSIVE_6         0x95
185 #define RCP_USER_EXCLUSIVE_7         0x96
186 #define RCP_USER_EXCLUSIVE_8         0x97
187 #define RCP_CH_EXCLUSIVE             0x98
188 #define RCP_EXEC_EXTERN_PROG         0x99
189 #define RCP_BANK_AND_PROG            0xe2
190 #define RCP_KEY_SCAN                 0xe5
191 #define RCP_MIDI_CH_CHANGE           0xe6
192 #define RCP_TEMPO_CHANGE             0xe7
193 #define RCP_AFTER_TOUCH              0xea
194 #define RCP_CONTROL_CHANGE           0xeb
195 #define RCP_PROGRAM_CHANGE           0xec
196 #define RCP_AFTER_TOUCH_POLY         0xed
197 #define RCP_PITCH_BEND               0xee
198 #define RCP_YAMAHA_BASE              0xd0
199 #define RCP_YAMAHA_DEV_NUM           0xd1
200 #define RCP_YAMAHA_ADDR              0xd2
201 #define RCP_YAMAHA_XG_AD             0xd3
202 #define RCP_ROLAND_BASE              0xdd
203 #define RCP_ROLAND_PARA              0xde
204 #define RCP_ROLAND_DEV               0xdf
205 #define RCP_KEY_CHANGE               0xf5
206 #define RCP_COMMENT_START            0xf6
207 #define RCP_LOOP_END                 0xf8
208 #define RCP_LOOP_START               0xf9
209 #define RCP_SAME_MEASURE             0xfc
210 #define RCP_MEASURE_END              0xfd
211 #define RCP_END_OF_TRACK             0xfe
212 #define RCP_DX7_FUNCTION             0xc0
213 #define RCP_DX_PARAMETER             0xc1
214 #define RCP_DX_RERF                  0xc2
215 #define RCP_TX_FUNCTION              0xc3
216 #define RCP_FB01_PARAMETER           0xc5
217 #define RCP_FB01_SYSTEM              0xc6
218 #define RCP_TX81Z_VCED               0xc7
219 #define RCP_TX81Z_ACED               0xc8
220 #define RCP_TX81Z_PCED               0xc9
221 #define RCP_TX81Z_SYSTEM             0xca
222 #define RCP_TX81Z_EFFECT             0xcb
223 #define RCP_DX7_2_REMOTE_SW          0xcc
224 #define RCP_DX7_2_ACED               0xcd
225 #define RCP_DX7_2_PCED               0xce
226 #define RCP_TX802_PCED               0xcf
227 #define RCP_MKS_7                    0xdc
228
229 #define RCP_2ND_EVENT                0xf7
230
231 #endif /* _RCP_H_ */