Danny Wyatt Posted February 5, 2022 Share Posted February 5, 2022 So I have these 2 scripts working when used separately, but when I copy-paste them to create a single script, one of them stops working. Here's one, to transpose a certain note: function HandleMIDI(event) { if(event instanceof Note && event.pitch == 40) { event.pitch = 37 ; } event.send(); } Then another one to choke the crash on my new electronic drum kit: function HandleMIDI(event) { event.trace(); if (event instanceof PolyPressure) { if (event.pitch == 49 && event.value == 127) { // The number 49 might be different on different drum modules. If so, use one of the two pitches when you choke your crash. It is of the type of PolyPressure. var event = new NoteOn; event.channel = 10; event.pitch = 28; event.velocity = 1; event.trace(); event.send(); var of = new NoteOff(event); of.trace(); of.send(); } else if (event.pitch == 57 && event.value == 127) { var event = new NoteOn; event.channel = 10; event.pitch = 29; event.velocity = 1; event.trace(); event.send(); var of = new NoteOff(event); of.trace(); of.send(); } } else { event.send(); } } They work when they have their own separate Scripter insert. When I put them together, the transposition stops working: // Transform snare's rim to sidestick function HandleMIDI(event) { if(event instanceof Note && event.pitch == 40) { event.pitch = 37 ; } event.send(); } // Crash choke function HandleMIDI(event) { event.trace(); if (event instanceof PolyPressure) { if (event.pitch == 49 && event.value == 127) { // The number 49 might be different on different drum modules. If so, use one of the two pitches when you choke your crash. It is of the type of PolyPressure. var event = new NoteOn; event.channel = 10; event.pitch = 28; event.velocity = 1; event.trace(); event.send(); var of = new NoteOff(event); of.trace(); of.send(); } else if (event.pitch == 57 && event.value == 127) { var event = new NoteOn; event.channel = 10; event.pitch = 29; event.velocity = 1; event.trace(); event.send(); var of = new NoteOff(event); of.trace(); of.send(); } } else { event.send(); } } Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted February 5, 2022 Share Posted February 5, 2022 Use only one function HandleMIDI(event) and only one event.send(); Copy your second if statement in the else portion of the first. Quote Link to comment Share on other sites More sharing options...
Danny Wyatt Posted February 5, 2022 Author Share Posted February 5, 2022 Use only one function HandleMIDI(event) and only one event.send(); Copy your second if statement in the else portion of the first. I have zero knowledge when it comes to Javascript Can you send me the final script, please? The first one was actually a script you sent me a while ago, to transpose a snare to the sidestick viewtopic.php?f=1&t=160516&p=842808&hilit=sidestick+snare#p842811 Quote Link to comment Share on other sites More sharing options...
Danny Wyatt Posted February 5, 2022 Author Share Posted February 5, 2022 Use only one function HandleMIDI(event) and only one event.send(); Copy your second if statement in the else portion of the first. While you look at it, do you know how to play a certain note based on a specific velocity range (1 to 63, for example) and then another note from 64 up to 127? Here's my post: viewtopic.php?f=1&t=162505 I'm trying to make this new drum kit work as expected Thanks Quote Link to comment Share on other sites More sharing options...
Solution David Nahmani Posted February 5, 2022 Solution Share Posted February 5, 2022 I'm not 100% sure and don't have time to test but try something like this: // Transform snare's rim to sidestick function HandleMIDI(event) { if(event instanceof Note && event.pitch == 40) { event.pitch = 37 ; event.send(); } else if (event instanceof PolyPressure) { if (event.pitch == 49 && event.value == 127) { // The number 49 might be different on different drum modules. If so, use one of the two pitches when you choke your crash. It is of the type of PolyPressure. var event = new NoteOn; event.channel = 10; event.pitch = 28; event.velocity = 1; event.trace(); event.send(); var of = new NoteOff(event); of.trace(); of.send(); } else if (event.pitch == 57 && event.value == 127) { var event = new NoteOn; event.channel = 10; event.pitch = 29; event.velocity = 1; event.trace(); event.send(); var of = new NoteOff(event); of.trace(); of.send(); } } else { event.send(); } } Quote Link to comment Share on other sites More sharing options...
Danny Wyatt Posted February 5, 2022 Author Share Posted February 5, 2022 I'm not 100% sure and don't have time to test but try something like this: // Transform snare's rim to sidestick function HandleMIDI(event) { if(event instanceof Note && event.pitch == 40) { event.pitch = 37 ; event.send(); } else if (event instanceof PolyPressure) { if (event.pitch == 49 && event.value == 127) { // The number 49 might be different on different drum modules. If so, use one of the two pitches when you choke your crash. It is of the type of PolyPressure. var event = new NoteOn; event.channel = 10; event.pitch = 28; event.velocity = 1; event.trace(); event.send(); var of = new NoteOff(event); of.trace(); of.send(); } else if (event.pitch == 57 && event.value == 127) { var event = new NoteOn; event.channel = 10; event.pitch = 29; event.velocity = 1; event.trace(); event.send(); var of = new NoteOff(event); of.trace(); of.send(); } } else { event.send(); } } Like a charm! Thanks! Let me know if you know the answer to the other code I'm looking for. I'm closer to fixing this kit Thanks Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted February 5, 2022 Share Posted February 5, 2022 By the way, most scripter related questions usually go to the MFX sub forum. easier to find them later in the future. Quote Link to comment Share on other sites More sharing options...
Danny Wyatt Posted February 5, 2022 Author Share Posted February 5, 2022 By the way, most scripter related questions usually go to the MFX sub forum. easier to find them later in the future. I rarely go to those sub forums... and since those are rarely visited by the users, it's always that feeling of "if I post this here, I have a low chance of it being seen" Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted February 5, 2022 Share Posted February 5, 2022 Scripting related posts generally go there Quote Link to comment Share on other sites More sharing options...
Danny Wyatt Posted February 5, 2022 Author Share Posted February 5, 2022 Scripting related posts generally go there Sure, it makes sense. In this case it's just that the fact that I'm in a bit of a "hurry" to make this drum kit work, having the posts there it would maybe take longer for someone to really go there and check them In the future, will definitely post there Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted February 6, 2022 Share Posted February 6, 2022 By the way, most scripter related questions usually go to the MFX sub forum. easier to find them later in the future. Definitely. I moved this to the MIDI FX forum. Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted February 7, 2022 Share Posted February 7, 2022 Like a charm! Thanks! Great! You're welcome. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.