comparison scripts/hvresources/heavy_render.cpp @ 496:eb237b131ec7 prerelease

Tested and fixed midi glitches heavy
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 21 Jun 2016 20:00:12 +0100
parents e9821d65b9ba
children c932df224fd3
comparison
equal deleted inserted replaced
495:a5867381a97b 496:eb237b131ec7
168 //| | 168 //| |
169 //| [print pgmin_channel] 169 //| [print pgmin_channel]
170 //[print pgmin_number] 170 //[print pgmin_number]
171 hvMidiHashes[kmmProgramChange] = hv_stringToHash("__hv_pgmin"); 171 hvMidiHashes[kmmProgramChange] = hv_stringToHash("__hv_pgmin");
172 hvMidiHashes[kmmPolyphonicKeyPressure] = hv_stringToHash("__hv_polytouchin"); 172 hvMidiHashes[kmmPolyphonicKeyPressure] = hv_stringToHash("__hv_polytouchin");
173 hvMidiHashes[kmmChannelPressure] = hv_stringToHash("__hv_touch"); 173 hvMidiHashes[kmmChannelPressure] = hv_stringToHash("__hv_touchin");
174 hvMidiHashes[kmmPitchBend] = hv_stringToHash("__hv_bendin"); 174 hvMidiHashes[kmmPitchBend] = hv_stringToHash("__hv_bendin");
175 175
176 gHeavyContext = hv_bela_new(context->audioSampleRate); 176 gHeavyContext = hv_bela_new(context->audioSampleRate);
177 177
178 gHvInputChannels = hv_getNumInputChannels(gHeavyContext); 178 gHvInputChannels = hv_getNumInputChannels(gHeavyContext);
241 int noteNumber = message.getDataByte(0); 241 int noteNumber = message.getDataByte(0);
242 int velocity = message.getDataByte(1); 242 int velocity = message.getDataByte(1);
243 int channel = message.getChannel(); 243 int channel = message.getChannel();
244 // rt_printf("message: noteNumber: %f, velocity: %f, channel: %f\n", noteNumber, velocity, channel); 244 // rt_printf("message: noteNumber: %f, velocity: %f, channel: %f\n", noteNumber, velocity, channel);
245 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmNoteOn], 0, "fff", 245 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmNoteOn], 0, "fff",
246 (float)noteNumber, (float)velocity, (float)channel); 246 (float)noteNumber, (float)velocity, (float)channel+1);
247 break; 247 break;
248 } 248 }
249 case kmmNoteOff: { 249 case kmmNoteOff: {
250 /* PureData does not seem to handle noteoff messages as per the MIDI specs, 250 /* PureData does not seem to handle noteoff messages as per the MIDI specs,
251 * so that the noteoff velocity is ignored. Here we convert them to noteon 251 * so that the noteoff velocity is ignored. Here we convert them to noteon
254 int noteNumber = message.getDataByte(0); 254 int noteNumber = message.getDataByte(0);
255 // int velocity = message.getDataByte(1); // would be ignored by Pd 255 // int velocity = message.getDataByte(1); // would be ignored by Pd
256 int channel = message.getChannel(); 256 int channel = message.getChannel();
257 // note we are sending the below to hvHashes[kmmNoteOn] !! 257 // note we are sending the below to hvHashes[kmmNoteOn] !!
258 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmNoteOn], 0, "fff", 258 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmNoteOn], 0, "fff",
259 (float)noteNumber, (float)0, (float)channel); 259 (float)noteNumber, (float)0, (float)channel+1);
260 break; 260 break;
261 } 261 }
262 case kmmControlChange: { 262 case kmmControlChange: {
263 int channel = message.getChannel(); 263 int channel = message.getChannel();
264 int controller = message.getDataByte(0); 264 int controller = message.getDataByte(0);
265 int value = message.getDataByte(1); 265 int value = message.getDataByte(1);
266 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmControlChange], 0, "fff", 266 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmControlChange], 0, "fff",
267 (float)value, (float)controller, (float)channel); 267 (float)value, (float)controller, (float)channel+1);
268 break; 268 break;
269 } 269 }
270 case kmmProgramChange: { 270 case kmmProgramChange: {
271 message.prettyPrint();
271 int channel = message.getChannel(); 272 int channel = message.getChannel();
272 int program = message.getDataByte(0); 273 int program = message.getDataByte(0);
273 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmProgramChange], 0, "ff", 274 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmProgramChange], 0, "ff",
274 (float)program, (float)channel); 275 (float)program, (float)channel+1);
275 break; 276 break;
276 } 277 }
277 case kmmPolyphonicKeyPressure: { 278 case kmmPolyphonicKeyPressure: {
279 message.prettyPrint();
280
278 //TODO: untested, I do not have anything with polyTouch... who does, anyhow? 281 //TODO: untested, I do not have anything with polyTouch... who does, anyhow?
279 int channel = message.getChannel(); 282 int channel = message.getChannel();
280 int pitch = message.getDataByte(0); 283 int pitch = message.getDataByte(0);
281 int value = message.getDataByte(1); 284 int value = message.getDataByte(1);
282 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmPolyphonicKeyPressure], 0, "fff", 285 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmPolyphonicKeyPressure], 0, "fff",
283 (float)channel, (float)pitch, (float)value); 286 (float)channel+1, (float)pitch, (float)value);
284 break; 287 break;
285 } 288 }
286 case kmmChannelPressure: 289 case kmmChannelPressure:
287 { 290 {
288 //TODO: untested, I do not have anything with aftertouch...
289 int channel = message.getChannel(); 291 int channel = message.getChannel();
290 int value = message.getDataByte(0); 292 int value = message.getDataByte(0);
291 //TODO: maybe the order of the arguments is wrong here?
292 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmChannelPressure], 0, "ff", 293 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmChannelPressure], 0, "ff",
293 (float)channel, (float)value); 294 (float)value, (float)channel+1);
294 break; 295 break;
295 } 296 }
296 case kmmPitchBend: 297 case kmmPitchBend:
297 { 298 {
298 int channel = message.getChannel(); 299 int channel = message.getChannel();
299 int value = ((message.getDataByte(1) << 7) | message.getDataByte(0)) - 8192; 300 int value = ((message.getDataByte(1) << 7) | message.getDataByte(0)) - 8192;
300 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmPitchBend], 0, "ff", 301 hv_vscheduleMessageForReceiver(gHeavyContext, hvMidiHashes[kmmPitchBend], 0, "ff",
301 (float)channel, (float)value); 302 (float)channel+1, (float)value);
302 break; 303 break;
303 } 304 }
304 case kmmNone: 305 case kmmNone:
305 case kmmAny: 306 case kmmAny:
306 break; 307 break;