dertimo Posted November 19, 2020 Share Posted November 19, 2020 Hello, I am looking for a script to trigger a sound when releasing the note. In Logics EXS24 you can edit a sampler instrument that it behaves that way. Since I don't want to edit every sampler instrument I am using I's like to solve that with a midi script. My aim is to play an easy drum rhythm on a organ pedal. When I press any note on it there is a kick drum. When I release the pedal I'd like to have a Hihat or something similar. Can you help? Best regards, dertimo Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted November 19, 2020 Share Posted November 19, 2020 That one looks like it shouldn't be too difficult, I'm going to give it a try. Quote Link to comment Share on other sites More sharing options...
dertimo Posted November 19, 2020 Author Share Posted November 19, 2020 That's great. Thanks. Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted November 19, 2020 Share Posted November 19, 2020 Ok try this project. Push a C1 key to hear a kick then release to hear a Hi-Hat. Note Off to Note On.zip Quote Link to comment Share on other sites More sharing options...
dertimo Posted November 19, 2020 Author Share Posted November 19, 2020 Thanks a lot. Is there a way to add other note numbers? I'd like to play a Bass along with the kick and have this effect on every note. And would it be possible to just have ne note off sound (hh) without the note on sound (bd)? Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted November 19, 2020 Share Posted November 19, 2020 Thanks a lot. Is there a way to add other note numbers? I'd like to play a Bass along with the kick and have this effect on every note. And would it be possible to just have ne note off sound (hh) without the note on sound (bd)? I'm not sure what you mean with the bass? To have the note off without the note on just use this: function HandleMIDI(event) { if ((event instanceof NoteOn) && event.pitch == 36) { event.send(); } else if ((event instanceof NoteOff) && event.pitch == 36) { var note = new NoteOn; note.pitch = (42); note.velocity = 100; } else { event.send(); } } Quote Link to comment Share on other sites More sharing options...
dertimo Posted November 20, 2020 Author Share Posted November 20, 2020 Hm... Seams you deleted the wrong commands. Now it's only playing the note on kick drum. But I solved the problem by trial and error. Now its only playing the note offs. But anyway thank a lot. Here is the script. Sorry I didn't manage to insert it as code as you did. function HandleMIDI(event) { if ((event instanceof NoteOn) && event.pitch == 36) {} else if ((event instanceof NoteOff) && event.pitch == 36) { var note = new NoteOn; note.pitch = (42); note.velocity = 100; note.send(); } else { event.send(); } } PS: I wrote another topic. Could you help me with that one too? Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted November 20, 2020 Share Posted November 20, 2020 (edited) A couple things... First...in order to post your code on this forum in a nicer way, just use the CODE block.. you can see an icon on the toolbar above that looks like this: if you just click that toolbar button, it will insert the following in the editor: [code] [/code] You can then put some javascript code in there. If you select the javascript code before hitting the toolbar button, it will sandwich it for you, like this: [code] function HandleMIDI(event) { if ((event instanceof NoteOn) && event.pitch == 36) { event.send(); } else if ((event instanceof NoteOff) && event.pitch == 36) { var note = new NoteOn; note.pitch = (42); note.velocity = 100; note.send(); } else { event.send(); } } [/code] After you do that, your post will have nicely formatted javascript code. Notice I was able to make my font smaller as well by using the Small font option in the toolbar as well, set to a size of 70. that looks like this in the editor: [size=70][code] function HandleMIDI(event) { // do stuff } [/code] [/size] now on to your code.... Edited November 20, 2020 by Dewdman42 Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted November 20, 2020 Share Posted November 20, 2020 (edited) Looks to me that you took out the event.send() that David originally had for handling NoteOn. Also don't forget to assign channel to the pitch 42. So here it is, put back, along with the channel: function HandleMIDI(event) { if ((event instanceof NoteOn) && event.pitch == 36) { event.send(); } else if ((event instanceof NoteOff) && event.pitch == 36) { var note = new NoteOn; note.pitch = (42); note.velocity = 100; note.channel = event.channel; note.send(); } else { event.send(); } } I want to point out also that you do not have NoteOff events making it to your instrument for each of the two sounds you are intending to use. You will need to make sure to send NoteOff's also otherwise your instrument could become confused with hanging notes.. If these are percussive sounds that only need a few ms of duration for each note, then you could do that like this: function HandleMIDI(event) { if ((event instanceof NoteOn) && event.pitch == 36) { event.send(); } else if ((event instanceof NoteOff) && event.pitch == 36) { event.send(); // first send the Noteoff itself for the original pitch var note = new NoteOn; note.pitch = (42); note.velocity = 100; note.channel = event.channel; note.send(); note.velocity = 0; note.sendAfterMilliseconds(50); } else { event.send(); } } Edited November 20, 2020 by Dewdman42 Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted November 20, 2020 Share Posted November 20, 2020 (edited) To add more pitches to your script, just copy and paste the else if sections for each pitch. For example: function HandleMIDI(event) { // Pitch 36 if ((event instanceof NoteOn) && event.pitch == 36) { event.send(); } else if ((event instanceof NoteOff) && event.pitch == 36) { event.send(); var note = new NoteOn; note.pitch = (42); note.velocity = 100; note.channel = event.channel; note.send(); note.velocity = 0; note.sendAfterMilliseconds(50); } // Pitch 37 else if ((event instanceof NoteOn) && event.pitch == 37) { event.send(); } else if ((event instanceof NoteOff) && event.pitch == 37) { event.send(); var note = new NoteOn; note.pitch = (43); note.velocity = 100; note.channel = event.channel; note.send(); note.velocity = 0; note.sendAfterMilliseconds(50); } // everything else else { event.send(); } } Edited November 20, 2020 by Dewdman42 Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted November 20, 2020 Share Posted November 20, 2020 Lastly, you can make it a little easier to read and avoid duplicated code by using a javascript function, like this: function HandleMIDI(event) { if (event instanceof NoteOff) { if(event.pitch == 36) { sendOff( event, 42 ); } else if(event.pitch == 37) { sendOff( event, 43); } // all other NoteOff's else { event.send(); } } // everything else, including NoteOn else { event.send(); } } function sendOff(event, offPitch) { event.send(); // send original NoteOff var note = new NoteOn; note.channel = event.channel; note.velocity = 100; note.pitch = offPitch; note.send(); note.velocity = 0; note.sendAfterMilliseconds(100); } Quote Link to comment Share on other sites More sharing options...
dertimo Posted November 21, 2020 Author Share Posted November 21, 2020 Thanks for your advice and the detailed comments. Now the script works perfectly well. I posted another topic. viewtopic.php?f=45&t=153444&p=803675 Maby you can help me with that one too? Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted November 21, 2020 Share Posted November 21, 2020 that other one you asked about is possible but quite a bit more involved and I'm sorry but I won't have time to do it for you. Quote Link to comment Share on other sites More sharing options...
dertimo Posted November 23, 2020 Author Share Posted November 23, 2020 Good to know, that it would be possible and totally comprehensible if you say you don't have the time to write it. Do you know someone I could hire to write it for me? I looked for programmers on fiverr.com or freelancer.com but for now without success. Quote Link to comment Share on other sites More sharing options...
David Nahmani Posted November 23, 2020 Share Posted November 23, 2020 Let's see if Steve is willing to do it for you as a work for hire. If not, I know someone who may be able to help you out. Quote Link to comment Share on other sites More sharing options...
Dewdman42 Posted November 23, 2020 Share Posted November 23, 2020 sorry dudes, I'm not available for hire on scripting. Have been asked many times. If I get some time I will take a look to see if I can do it in less then an hour I will, but I can't promise anything and I doubt its less then an hour. Quote Link to comment Share on other sites More sharing options...
dertimo Posted November 23, 2020 Author Share Posted November 23, 2020 Thanks. I take, what I get. Quote Link to comment Share on other sites More sharing options...
Thomaskix Posted December 13, 2020 Share Posted December 13, 2020 I was experimenting a little bit in Sibelius, when I decided Id post a song here. It isnt completely finished yet, but you still can get the message. Please give some feedback. Quote Link to comment Share on other sites More sharing options...
Atlas007 Posted December 13, 2020 Share Posted December 13, 2020 I was experimenting a little bit in Sibelius, when I decided Id post a song here. It isnt completely finished yet, but you still can get the message. Please give some feedback. I think that you are posting in the wrong forum section / topic... 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.