Jump to content

Adding this script makes all drum kit to stop working, except the HiHat [SOLVED]


Danny Wyatt

Recommended Posts

UPDATE: Solution is here: viewtopic.php?f=45&t=162724&p=853928#p853928

 

 

 

function HandleMIDI(event)
{

if (event instanceof NoteOn && event.pitch == 42) {

event.articulationID = 1;

event.trace();
event.send();
}
}

 

When I add this, I can indeed change the articulationID to whatever I want, but now everything else gets muted and only the closed HiHat generates sound...

What am I missing here?

 

What I'm trying to achieve is a way to make my closed HiHat have 3 levels of velocity assigned to 3 different articulations so I can have it sound more like a real HiHat.

I didn't add the velocity code just yet, because it stopped working right away so I'm trying to figure this out first.

Link to comment
Share on other sites

you have the event.send() inside the IF statement, so only the events with pitch 42 are going through.

 

By default, Scripter does not pass any midi events through, you have to explicitly send for everything else too like this:

 

function HandleMIDI(event) {
   if (event instanceof NoteOn && event.pitch == 42) {
       event.articulationID = 1;
       event.trace();
   }
   event.send();
}

 

But I don't think this script is going to accomplish what you're hoping. The Scripter script is processed very last in the midi chain. By the time it hits scripter, it has already gone through the articulation set engine. so adding an articulation id there is not going to help you in this case

Link to comment
Share on other sites

you have the event.send() inside the IF statement, so only the events with pitch 42 are going through.

 

By default, Scripter does not pass any midi events through, you have to explicitly send for everything else too like this:

 

function HandleMIDI(event) {
   if (event instanceof NoteOn && event.pitch == 42) {
       event.articulationID = 1;
       event.trace();
   }
   event.send();
}

 

But I don't think this script is going to accomplish what you're hoping. The Scripter script is processed very last in the midi chain. By the time it hits scripter, it has already gone through the articulation set engine. so adding an articulation id there is not going to help you in this case

 

I was able to make it work for a few seconds, then suddenly the kit started acting weird. I would hit the snare 5 times and only 2 of them got sound. Or the kick, etc. But it worked great, the whole kit including the articulations, for like 10 seconds...

Any idea why? Do you think having other Scripter instances may cause this? As of now, I have 5 inserts of Scripter with different scripts before that one. I want to merge everything, but still trying to understand how to do that... ;)

 

I just noticed that once it starts acting weird, if I just disable that instance and enable it again, everything goers back to normal... for a few seconds.

Link to comment
Share on other sites

as I said, the articulation set input switch section is not meant to be triggered by the notes themselves its treating your input notes like switches.. Setting the articulationID In the script will not affect the articulationset behavior at all. The script above basically should be having no affect on anything. You can enable and disable it and you will see the same erratic behavior, which is probably related to what you're trying to to in the articulation set.
Link to comment
Share on other sites

as I said, the articulation set input switch section is not meant to be triggered by the notes themselves its treating your input notes like switches.. Setting the articulationID In the script will not affect the articulationset behavior at all. The script above basically should be having no affect on anything. You can enable and disable it and you will see the same erratic behavior, which is probably related to what you're trying to to in the articulation set.

 

I'm very amateur when it comes to the Scripter (as you know by now) and also articulations/keyswitches in general.

I'm watching a video about articulations and Keyswitches, but what you are saying is a bit confusing to me...

 

The issue I was having with the other approach (from this post: viewtopic.php?p=853870#p853870) is not the same as I am having now.

With the articulations window, I couldn't make the open HiHat work at all.

Now with the Scripter, the whole kit behaves as expected, including the closed HiHat having that extra sound associated with the articulation 3, when I play it above velocity 120. The open HiHat also plays. I am able to play the whole kit for like 10 seconds, then it starts acting weird...

If the issue would be what you mention (which I still don't understand) wouldn't it be an issue once the Scripter is active? Why is it only becoming an issue after a few seconds of my playing the kit?

Also, I would like to mention that right now, that other articulation window I have on my other post, is not active, meaning on the Inspector, I have no active articulation:

1590133927_ScreenShot2022-02-16at10_38_11PM.png.e458d43f4502ee9954a936ec158f4a7f.png

 

Is that what you were saying? That having both active would cause some kind of conflict?

Link to comment
Share on other sites

afraid you will have to figure it out yourself as you are venturing into an area that I don't know that much about, the input switches of the articulation set. But what I am saying is that Scripter is the LAST to act on the midi stream right before the midi goes to your instrument in the instrument channel strip. So setting the articulationID in that script should have no effete whatsoever on what the ArticulationSet is doing. Whatever the articulation set does has already been done by the time the midi hits the Scripter script.

 

Secondly I think you are trying to do something with the articulation set that its not designed to do, but I leave that to you and others to experiment and see if you can figure it out.

 

Good luck

Link to comment
Share on other sites

afraid you will have to figure it out yourself as you are venturing into an area that I don't know that much about, the input switches of the articulation set. But what I am saying is that Scripter is the LAST to act on the midi stream right before the midi goes to your instrument in the instrument channel strip. So setting the articulationID in that script should have no effete whatsoever on what the ArticulationSet is doing. Whatever the articulation set does has already been done by the time the midi hits the Scripter script.

 

Secondly I think you are trying to do something with the articulation set that its not designed to do, but I leave that to you and others to experiment and see if you can figure it out.

 

Good luck

 

I think I'm onto something... maybe you can help me:

Is there a way to tell the script:

"If this and this happens (for example if a note is A#), set the ModWheel value to 127"?

My main goal here is to change the ModWheel value to any value I choose.

 

Here's my thought process:

If I change the Input Mapping inside to GM + ModWheel controls HiHat opening level, now I can have the ModWheel act as an "articulation" (kinda).

So I can tell the script:

If the note is X and the velocity is Y, open the ModWheel to Z value.

So now I can set 3 different values for the closed hihat. Then the same for the open hihat.

Now for the foot pedal sound, I can just make G#1 play A0 which is another foot pedal sound (using Scripter as well).

 

Does it make sense?

 

So, if that's possible, how can I add a line of code that tells the ModWheel to change its value?

Link to comment
Share on other sites

you lost me a little bit on what you're trying to do, but you can send a CC message easily like this:

 


var ccval = 50;

function HandleMIDI(event) {
   var cc = new ControlChange;
   cc.channel = event.channel;
   cc.number = 1;
   cc.value = ccval;
   cc.send();
}

 

Thanks for the code! :D

 

 

It's pretty simple :)

When you change the Input Mapping inside the Drum Kit Designer to "GM + ModWheel controls HiHat open level", now depending on the ModWheel value, you will achieve similar results as when you use the articulations, which is just different HiHat sounds from closed to open and all in between, correct?

When you change that setting, now all 3 notes sound exactly the same (F#1, G#1, A#1). They no longer sound like Closed HiHat, Foot Pedal, Open HiHat.

 

So with the script I'm sharing below, I assigned different velocities to different ModWheel values, so if I play softer, the ModWheel has a lower value, making the HiHat sound closed. The stronger I hit it, the higher the ModWheel value, making it sound more open, like a real HiHat.

 

Now for the Open HiHat, the only value I need is a value on the ModWheel that sounds like an open HiHat: 127.

So far so good.

 

Now what about the foot pedal, since all 3 notes sound the same?

Well, luckily, the note A0 is also a foot pedal, so on the script I just replaced G#1 with A0 and now I have my foot pedal back :)

 

Here's the script (please let me know if there's something I could improve/change. It's working as is, but maybe you would approach it differently?):

var ccval = 1;

function HandleMIDI(event) {
   var cc = new ControlChange;
   cc.channel = event.channel;
   cc.number = 1;
   
   //Closed HiHat
   if (event instanceof Note && event.pitch == 42 && event.velocity <=50) {
   cc.value = 1;
   }
   else if (event instanceof Note && event.pitch == 42 && event.velocity >=51 && event.velocity <=115) {
   cc.value = 30;
   }
   else if (event instanceof Note && event.pitch == 42 && event.velocity >=116) {
   cc.value = 60;
   }
   
   //Open HiHat
   if (event instanceof Note && event.pitch == 46) {
   cc.value = 127;
   }
   
   // Foot Pedal
   if (event instanceof Note && event.pitch == 44) {
   event.pitch = 33;
   }
   
   cc.send();
   cc.trace();
   event.send();
   
}

Link to comment
Share on other sites

if it works then great. here's slightly cleaned up version

 

var cc = new ControlChange;
cc.number = 1;

function HandleMIDI(event) {
   cc.channel = event.channel;
   
   //Closed HiHat
   if (event instanceof Note && event.pitch == 42 && event.velocity <=50) {
       cc.value = 1;
   }
   else if (event instanceof Note && event.pitch == 42 && event.velocity >=51 
           && event.velocity <=115) {
       cc.value = 30;
   }
   else if (event instanceof Note && event.pitch == 42 && event.velocity >=116) {
       cc.value = 60;
   }
   
   //Open HiHat
   if (event instanceof Note && event.pitch == 46) {
       cc.value = 127;
   }
   
   // Foot Pedal
   if (event instanceof Note && event.pitch == 44) {
       event.pitch = 33;
   }
   
   cc.send();
   cc.trace();
   event.send();
   
}

 

I see you are doing this for both NoteOn and NoteOff (you used Note, which is referring to both. if you only need CC's sent in front of NoteOn, then change the instanceof comparison to use NoteOn instead of Note.

Link to comment
Share on other sites

if it works then great. here's slightly cleaned up version

 

var cc = new ControlChange;
cc.number = 1;

function HandleMIDI(event) {
   cc.channel = event.channel;
   
   //Closed HiHat
   if (event instanceof Note && event.pitch == 42 && event.velocity <=50) {
       cc.value = 1;
   }
   else if (event instanceof Note && event.pitch == 42 && event.velocity >=51 
           && event.velocity <=115) {
       cc.value = 30;
   }
   else if (event instanceof Note && event.pitch == 42 && event.velocity >=116) {
       cc.value = 60;
   }
   
   //Open HiHat
   if (event instanceof Note && event.pitch == 46) {
       cc.value = 127;
   }
   
   // Foot Pedal
   if (event instanceof Note && event.pitch == 44) {
       event.pitch = 33;
   }
   
   cc.send();
   cc.trace();
   event.send();
   
}

 

I see you are doing this for both NoteOn and NoteOff (you used Note, which is referring to both. if you only need CC's sent in front of NoteOn, then change the instanceof comparison to use NoteOn instead of Note.

 

Thanks for the cleaner version! :)

I tried changing it to NoteOn, but what I noticed was that after a while, it would start acting weird, the way it was with that articulation script. After a few seconds (in this case it was longer than 10 seconds, I was able to maybe play for a minute or so), some pieces would only play 1 out of 5 hits.

I don't know why this happens, but using your clean version using Note instead of NoteOn, worked like a charm. No issues at all, so I guess I will leave it like that.

 

I really appreciate your time and help :D

My kit is almost perfect. Still want to try a few more things and see if I can fix them. You will probably hear from me very soon again ;)

Link to comment
Share on other sites

I guess maybe the case of open hat where you are changing the pitch, thst would need to be Note. The the other cases where you are inserting cc could be just NoteOn. But if it works just leave it

 

Didn’t you mean Foot Pedal? That’s the one changing the pitch, not the Open HiHat.

Or am missing something there?

But yes, it’s working so far :)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...