summaryrefslogtreecommitdiff
path: root/apps/plugins/midi/midiutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/midi/midiutil.c')
-rw-r--r--apps/plugins/midi/midiutil.c132
1 files changed, 56 insertions, 76 deletions
diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c
index 41a02ae682..bf25d1d277 100644
--- a/apps/plugins/midi/midiutil.c
+++ b/apps/plugins/midi/midiutil.c
@@ -63,33 +63,26 @@
63extern struct plugin_api * rb; 63extern struct plugin_api * rb;
64 64
65 65
66int chVol[16] IDATA_ATTR; //Channel volume
67int chPanLeft[16] IDATA_ATTR; //Channel panning
68int chPanRight[16] IDATA_ATTR;
69int chPat[16]; //Channel patch
70int chPW[16]; //Channel pitch wheel, MSB only
71
72
73/*
66unsigned char chVol[16]; //Channel volume 74unsigned char chVol[16]; //Channel volume
67unsigned char chPanLeft[16]; //Channel panning 75unsigned char chPanLeft[16]; //Channel panning
68unsigned char chPanRight[16]; 76unsigned char chPanRight[16];
69unsigned char chPat[16]; //Channel patch 77unsigned char chPat[16]; //Channel patch
70unsigned char chPW[16]; //Channel pitch wheel, MSB only 78unsigned char chPW[16]; //Channel pitch wheel, MSB only
71 79*/
72
73struct GPatch * gusload(char *); 80struct GPatch * gusload(char *);
74struct GPatch * patchSet[128]; 81struct GPatch * patchSet[128];
75struct GPatch * drumSet[128]; 82struct GPatch * drumSet[128];
76struct SynthObject voices[MAX_VOICES];
77 83
78 84
79 85//char myarray[80] IDATA_ATTR;
80struct SynthObject
81{
82 int tmp;
83 struct GWaveform * wf;
84 unsigned int delta;
85 unsigned int decay;
86 unsigned int cp;
87 unsigned char state, pstate, loopState, loopDir;
88 unsigned char note, vol, ch, isUsed;
89 int curRate, curOffset, targetOffset;
90 int curPoint;
91};
92
93 86
94struct Event 87struct Event
95{ 88{
@@ -120,6 +113,34 @@ struct MIDIfile
120 unsigned char patches[128]; 113 unsigned char patches[128];
121 int numPatches; 114 int numPatches;
122}; 115};
116/*
117struct SynthObject
118{
119// int tmp;
120 struct GWaveform * wf;
121 unsigned int delta;
122 unsigned int decay;
123 unsigned int cp;
124 unsigned char state, loopState, loopDir;
125 unsigned char note, vol, ch, isUsed;
126 int curRate, curOffset, targetOffset;
127 unsigned int curPoint;
128};
129*/
130struct SynthObject
131{
132// int tmp;
133 struct GWaveform * wf;
134 int delta;
135 int decay;
136 int cp;
137 int state, loopState, loopDir;
138 int note, vol, ch, isUsed;
139 int curRate, curOffset, targetOffset;
140 int curPoint;
141};
142
143struct SynthObject voices[MAX_VOICES] IDATA_ATTR;
123 144
124 145
125 146
@@ -133,13 +154,16 @@ int readVarData(int file);
133int midimain(void * filename); 154int midimain(void * filename);
134 155
135 156
136//Rick's code
137void *alloc(int size) 157void *alloc(int size)
138{ 158{
139 static char *offset = NULL; 159 static char *offset = NULL;
140 static int totalSize = 0; 160 static int totalSize = 0;
141 char *ret; 161 char *ret;
142 162
163 int remainder = size % 4;
164
165 size = size + 4-remainder;
166
143 if (offset == NULL) 167 if (offset == NULL)
144 { 168 {
145 offset = rb->plugin_get_audio_buffer(&totalSize); 169 offset = rb->plugin_get_audio_buffer(&totalSize);
@@ -157,40 +181,34 @@ void *alloc(int size)
157 totalSize -= size + 4; 181 totalSize -= size + 4;
158 return ret; 182 return ret;
159} 183}
184
185
186//Rick's code
160/* 187/*
161void *ralloc(char *offset, int len) 188void *alloc(int size)
162{ 189{
163 int size; 190 static char *offset = NULL;
191 static int totalSize = 0;
164 char *ret; 192 char *ret;
165 193
194
166 if (offset == NULL) 195 if (offset == NULL)
167 { 196 {
168 return alloc(len); 197 offset = rb->plugin_get_audio_buffer(&totalSize);
169 } 198 }
170 199
171 size = *((unsigned int *)offset - 4); 200 if (size + 4 > totalSize)
172
173 if (size >= 0x02000000)
174 { 201 {
175 return NULL; 202 return NULL;
176 } 203 }
177 204
178 ret = alloc(len); 205 ret = offset + 4;
179 206 *((unsigned int *)offset) = size;
180 if (len < size)
181 {
182 rb->memcpy(ret, offset, len);
183 }
184 else
185 {
186 rb->memcpy(ret, offset, size);
187 rb->memset(ret, 0, len - size);
188 }
189 207
208 offset += size + 4;
209 totalSize -= size + 4;
190 return ret; 210 return ret;
191} 211}*/
192*/
193
194void * allocate(int size) 212void * allocate(int size)
195{ 213{
196 return alloc(size); 214 return alloc(size);
@@ -222,44 +240,6 @@ int eof(int fd)
222 240
223void printf(char *fmt, ...) {fmt=fmt; } 241void printf(char *fmt, ...) {fmt=fmt; }
224 242
225/*
226void *audio_bufferbase;
227void *audio_bufferpointer;
228unsigned int audio_buffer_free;
229
230
231
232
233void *my_malloc(int size)
234{
235
236 void *alloc;
237
238 if (!audio_bufferbase)
239 {
240 audio_bufferbase = audio_bufferpointer
241 = rb->plugin_get_audio_buffer(&audio_buffer_free);
242#if MEM <= 8 && !defined(SIMULATOR)
243
244 if ((unsigned)(ovl_start_addr - (unsigned char *)audio_bufferbase)
245 < audio_buffer_free)
246 audio_buffer_free = ovl_start_addr - (unsigned char *)audio_bufferbase;
247#endif
248 }
249 if (size + 4 > audio_buffer_free)
250 return 0;
251 alloc = audio_bufferpointer;
252 audio_bufferpointer += size + 4;
253 audio_buffer_free -= size + 4;
254 return alloc;
255}
256
257void setmallocpos(void *pointer)
258{
259 audio_bufferpointer = pointer;
260 audio_buffer_free = audio_bufferpointer - audio_bufferbase;
261}
262*/
263void exit(int code) 243void exit(int code)
264{ 244{
265 code = code; //Stub function, kill warning for now 245 code = code; //Stub function, kill warning for now