Old 01-05-2012, 06:33 PM   #1
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default Multi Channel MIDI Keyswitch

Hello,

I'm new here. I came to reaper about 3 days ago when I got sick of Cubase's inflexibilities.

I think I am a convert, but still experimenting

Any-hoo I was using Bidule's keyswitch module to switch channels on a multitimbral VSTi and I figured I'd check out this JS script business and see if I could knock something together that would do the same thing and wouldn't require me to load Bidule.

After getting my head around this little scripting language I have put together a script that seems to do the job.
You can select a seperate keyswitch for each channel and all incoming MIDI data will be routed to the channel that you select, until another keyswitch key is pressed.


If you find any bugs let me know

Link:-
https://stash.reaper.fm/v/11328/Multi...DI%20Keyswitch

Hope some of you find this useful.
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)

Last edited by reddiesel41264; 01-06-2012 at 07:23 AM. Reason: v1.1 Keys now numbered correctly
reddiesel41264 is offline   Reply With Quote
Old 01-06-2012, 01:48 PM   #2
stephane
Human being with feelings
 
Join Date: May 2010
Location: France
Posts: 97
Default

Hello David

Very useful.

However I found a problem with EWQLSO Gold.

This is how to reproduced the problem:

With one instance of Play:
Channel 1: choose 18V Butter Legato
Channel 2: choose 18V Pizz

Set up a KS on C2 key for channel 1
Set up a KS on D2 key for channel 2

Play a note (C4 for example) on keyboard with Butter Legato patch.
Then press D2 to switch to Pizz patch but without releasing the C4 note.

Butter Legato is still playing although Pizz patch is selected

If you play a new note, pizzicato is ok, but the first C4 note (in my example with butter legato) is always here

Hope this will help you (in despite of my bad english )

Thanks for the script.
stephane is offline   Reply With Quote
Old 01-06-2012, 01:59 PM   #3
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

Glad you're finding it useful. It should be an easy problem to solve, I'll look into it when I get the chance

Until then, maybe just press one keyswitch at a time?
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-07-2012, 07:23 AM   #4
KevinW
Human being with feelings
 
KevinW's Avatar
 
Join Date: Sep 2009
Location: Dayton, Ohio USA
Posts: 1,714
Default

Quote:
Originally Posted by reddiesel41264 View Post
Glad you're finding it useful. It should be an easy problem to solve, I'll look into it when I get the chance

Until then, maybe just press one keyswitch at a time?
Three days in and you're already generating this kind of thing? Fantastic! Thanks!

I suggest you post a link to this in the tips and tricks section. Too many great ideas seem to get overlooked in the scripting forum.

BTW, welcome to reaperville.
KevinW is offline   Reply With Quote
Old 01-07-2012, 07:27 AM   #5
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

Thanks! I shall post a link there.
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-07-2012, 07:06 PM   #6
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

Welcome onboard!

If I could point out a couple of bugs for you....

Code:
// Extract note and status value
  note = msg23 & $x7F;
	status = msg1 & $xF0;
The value you extract there for "note" is only the note number when the message type is a Note On or Note Off message. So...
Code:
note == ks1 ? channel = 0;
... when you execute these instructions, if the message type is a Continuous Controller of the number of ks1 (for example), it will behave in the same way as if note number ks1 was received.

Also, the slight PITA of MIDI is that, because note consists of a Note On and a Note Off message, when changing channels you need to handle the possibility of a Note Off being sent to a channel different from it's original Note On channel (which results in hanging notes).

There are two ways of dealing with this, a Note Stack (where you have an list of Note Ons and Channel that have been played, match up the Note Offs to them as they occur and remove that entry) or with an array of every note (JS doesn't have arrays but you can have (roughly) the same functionality as them).

edit: I should clarify that there is a third way, which is sending an All Notes Off message to all channels which does what it says on the tin. It's not very nice when you are playing something though.

Last edited by captain_caveman; 01-07-2012 at 07:13 PM.
captain_caveman is offline   Reply With Quote
Old 01-08-2012, 05:08 AM   #7
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

Thanks for the info. I shall sort it out
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-08-2012, 06:06 AM   #8
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default v1.2

I've added a status filter, it checks to make sure KS are only note on or off messages.

Haven't had chance to look at the hanging note issue, but will get around to it at some point.


https://stash.reaper.fm/v/11328/Multi...DI%20Keyswitch
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-08-2012, 06:29 AM   #9
stephane
Human being with feelings
 
Join Date: May 2010
Location: France
Posts: 97
Default

Indeed the probleme described in my previous post is still here.
I hope you could have reproduced the issue and you'll find an solution.

Thanks David for this v1.2
stephane is offline   Reply With Quote
Old 01-08-2012, 07:22 AM   #10
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

Hi Stephane,

I have managed to reproduce it, just haven't had chance to implement a solution yet.
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-08-2012, 12:35 PM   #11
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

I hope you don't mind but I've updated your code with something that should almost certainly (I can't test it at the mo) fix the hanging notes issue....
Code:
//If we recieve a note on message
    statusLo ==9 ? (
          
		note == ks1 ? channel = 0;
		note == ks2 ? channel = 1;
		note == ks3 ? channel = 2;
		note == ks4 ? channel = 3;
		note == ks5 ? channel = 4;
		note == ks6 ? channel = 5;
		note == ks7 ? channel = 6;
		note == ks8 ? channel = 7;
		note == ks9 ? channel = 8;
		note == ks10 ? channel = 9;
		note == ks11 ? channel = 10;
		note == ks12 ? channel = 11;
		note == ks13 ? channel = 12;
		note == ks14 ? channel = 13;
		note == ks15 ? channel = 14;
		note == ks16 ? channel = 15;
		playednotes[note] = channel+1; //add one to the channel so unplayed slots will be zero
	); 
	
	//If we receive a note off message
	statusLo == 8 ? (
	    
		//if the slot is >0 it means this note on has been played so retrieve note on channel
		playednotes[note] > 0 ? (
		    
			channel = playednotes[note]-1;
			playednotes[note]=0; //reset the slot
			);
         );
captain_caveman is offline   Reply With Quote
Old 01-08-2012, 01:17 PM   #12
stephane
Human being with feelings
 
Join Date: May 2010
Location: France
Posts: 97
Default

Helly captain

I tried your code, but the probleme is not fixed

Code:
while( midirecv(offset,msg1,msg23) ? (

	// Extract note and status value
	note = msg23&$x7F;
	statusLo = (msg1/16)|0;
	status = msg1&$xF0;

	//If we recieve a note on message
	statusLo ==9 ? (
		note == ks1 ? channel = 0;
		note == ks2 ? channel = 1;
		note == ks3 ? channel = 2;
		note == ks4 ? channel = 3;
		note == ks5 ? channel = 4;
		note == ks6 ? channel = 5;
		note == ks7 ? channel = 6;
		note == ks8 ? channel = 7;
		note == ks9 ? channel = 8;
		note == ks10 ? channel = 9;
		note == ks11 ? channel = 10;
		note == ks12 ? channel = 11;
		note == ks13 ? channel = 12;
		note == ks14 ? channel = 13;
		note == ks15 ? channel = 14;
		note == ks16 ? channel = 15;
		playednotes[note] = channel+1; //add one to the channel so unplayed slots will be zero
	);

	//If we receive a note off message
	statusLo == 8 ? (
		//if the slot is >0 it means this note on has been played so retrieve note on channel
		playednotes[note] > 0 ? (
			channel = playednotes[note]-1;
			playednotes[note]=0; //reset the slot
		);
	);

	msg1 = status + channel;	//Route to new MIDI Channel
	midisend(offset, msg1, msg23); )// Send message on with channel adjustment

);
stephane is offline   Reply With Quote
Old 01-08-2012, 02:17 PM   #13
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

The only thing I can think of is that this line is not working...
Code:
playednotes[note] > 0 ? (
... because I have had issues before using "arrays" that were solved by using parenthesis, so changing it to...
Code:
(playednotes[note]) > 0 ? (
... might work.

If not, I'll try to test it later.
captain_caveman is offline   Reply With Quote
Old 01-08-2012, 03:37 PM   #14
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

He he, there was a mistake in there (permanently changing the "channel" variable when just retrieving a channel for one note-off).

Here's the new @block section...
Code:
@block
while (
     midirecv(offset,msg1,msg23) ? (
         // Extract note and status value
         note = msg23&$x7F;
         statusLo = (msg1/16)|0; 
         status = msg1&$xF0; 
   
         //If we recieve a note on message
         statusLo ==9 ? (
          
             note == ks1 ? channel = 0;
             note == ks2 ? channel = 1;
             note == ks3 ? channel = 2;
             note == ks4 ? channel = 3;
             note == ks5 ? channel = 4;
             note == ks6 ? channel = 5;
             note == ks7 ? channel = 6;
             note == ks8 ? channel = 7;
             note == ks9 ? channel = 8;
             note == ks10 ? channel = 9;
             note == ks11 ? channel = 10;
             note == ks12 ? channel = 11;
             note == ks13 ? channel = 12;
             note == ks14 ? channel = 13;
             note == ks15 ? channel = 14;
             note == ks16 ? channel = 15;
         
             playednotes[note] = channel+1; //add one to the channel so unplayed slots will be zero
          
         ); 
  
         //If we receive a note off message
         statusLo == 8 ? (
      
              //if the slot in is true (>0) it means this note on has been played so retrieve original channel
              (playednotes[note]) > 0 ? (
        
                  msg1 = status + (playednotes[note])-1;
                  playednotes[note]=0; //reset the slot
                  
              ):(
                  msg1 = status + channel;  //else route to new MIDI Channel
              );
         ):(
             msg1 = status + channel; //route to new MIDI channel for all non-note off events
         );

    
         midisend(offset, msg1, msg23); // Send message on with channel adjustment
    
     );
);
captain_caveman is offline   Reply With Quote
Old 01-08-2012, 04:26 PM   #15
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

Hi Captain,

All help is appreciated

Your code doesn't solve the problem though

It's not note off's that we need to look for; it's when we haven't recieved a note off for a note that has been played, but we have recieved a key switch changing the channel thus leaving the played note turned on.

We need to be able to find out which notes have been played and what their channel is, but only when recieve a KS.

I think we are almost there, just a tweak or two.
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-08-2012, 06:36 PM   #16
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

Quote:
Originally Posted by reddiesel41264 View Post
Hi Captain,

All help is appreciated

Your code doesn't solve the problem though

It's not note off's that we need to look for; it's when we haven't recieved a note off for a note that has been played, but we have recieved a key switch changing the channel thus leaving the played note turned on.

We need to be able to find out which notes have been played and what their channel is, but only when recieve a KS.

I think we are almost there, just a tweak or two.
I dunno, I've tested it and it works. What are the issues you are getting?
captain_caveman is offline   Reply With Quote
Old 01-09-2012, 06:06 AM   #17
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

Hanging notes. What test did you do? I loaded up a Sustained violin patch and a pizz patch on seperate channels, assigned each one a key switch. I then played the sustain patch and while it was playing (while i was holding the key down) I pressed the key switch to change to pizz. The result was that the sustain patch continued to play even when I released the key, because it hadn't recieved a note off.
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-09-2012, 09:50 AM   #18
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

Hmmm, strange.

I have 3 tracks, one with MIDI input from Virtual MIDI Keyboard sending channel 1 to track 2 and channel 2 to track 3. On tracks 2 and 3 are instances of z3ta+.

I get zero hanging notes, no matter how fast I keyswitch and how many notes I bash. (also obviously holding down notes whilst keyswitching)

Are you sure you have replaced the @block section with the second code that I posted, because the first one doesn't work?

(the only other thing I did was comment out the channel = 0 in the @init section, just so that starting and stopping transport wouldn't reset the channel (on that note I should probably save notesplayed[] in @serialized for the same reason))
captain_caveman is offline   Reply With Quote
Old 01-09-2012, 11:11 AM   #19
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

I tried it again, I removed the Channel = 0 in the @init (I don't think we actually need it anyway so I will get rid of it from future versions). I did the same test again but I still have the hanging notes.

We need a variable that is set when a KS is recieved, then we can check if we have recieved a KS and if we have we turn off all notes that have been turned on. I don't have time to do any code at the moment but I'm sure that it's something like that that is needed.

For testing purposes do the same as I did. One track, one input, one multitimbral VSTi on the track with two patches loaded on individual channels. Add the keyswitch script and hold down a note then press a key switch, the note should continue to play because it hasn't recieved a note off.

Let me know if you can reproduce the problem.
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-09-2012, 11:26 AM   #20
stephane
Human being with feelings
 
Join Date: May 2010
Location: France
Posts: 97
Default

it still doesn't work with EWQLSO.
stephane is offline   Reply With Quote
Old 01-09-2012, 11:33 AM   #21
stephane
Human being with feelings
 
Join Date: May 2010
Location: France
Posts: 97
Default

maybe this code will help you to find a solution. this one seems to work.
nb: i'm not the author of this script

Code:
desc:MIDI Keyboard Channel Switcher

// Keyboard Channel Switcher - DarkStar March 2011

in_pin:none
out_pin:none

slider1:1<1,16,1>Monitor: Channel in use
slider2:0<0,1,1>Reset all channels

/////////////////////////////////////////////////////////////////////
@init

// .................................................................. to be set by the user
//                                                                    for your own keyboard   
    first_switch = 41; // = note F1
    noof_switches = 7; // F1 .. B1
// .................................................................. 

    ext_noinit = 1; 
    out_channel = 0;

    NOTE_ON = 9;
    NOTE_OFF = 8;
    CC_MSG = 11;
    ALL_NOTES_OFF = 123;
    ALL_SOUND_OFF = 120;


// ========================================================
@slider

// ========================================================
@sample
while (
    midirecv(mpos, msg1, msg23) ? (
// --------------------------------------------- for EVERY MIDI msg received
        msg = (msg1 / 16) | 0;
        channel = 1 + msg1 - (msg * 16);     
        msg_num = msg23 & 127;
        msg_value = (msg23 / 256) | 0;

// is the note a channel change request ?
        change = (msg == NOTE_ON && msg_value > 0 && msg_num - first_switch >= 0 && msg_num - first_switch < noof_switches);  
// if so, change the channel
        change ? ( 
            msg1 = (CC_MSG * 16) + out_channel;
            midisend(mpos,msg1,ALL_NOTES_OFF);
            out_channel = msg_num - first_switch; 
            slider1 = out_channel +1;
        ):(
            msg1 = (msg * 16) + out_channel;
            midisend(mpos, msg1, msg23);
        );
 
// Reset received ? 
        slider2 == 1 ? (
            slider2 = 0;
dbg_ano +=1;
            msg1 = (CC_MSG * 16);
            midisend(mpos,msg1 + 0,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 1,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 2,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 3,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 4,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 5,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 6,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 7,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 8,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 9,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 10,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 11,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 12,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 13,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 14,ALL_NOTES_OFF);
            midisend(mpos,msg1 + 15,ALL_NOTES_OFF);
        );
    );
);
stephane is offline   Reply With Quote
Old 01-09-2012, 12:25 PM   #22
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

I have attached the version I am using with my changes so that we are all on the same page. It's working here.

It intentionally doesn't cut off notes when a Key Switch is received (the same as playing keyswitched instruments in a sampler), notes can be held after a Key Switch and can subsequently be released and cut off as normal (ie no hanging notes).
Attached Files
File Type: txt test.txt (21.9 KB, 324 views)
captain_caveman is offline   Reply With Quote
Old 01-09-2012, 12:55 PM   #23
stephane
Human being with feelings
 
Join Date: May 2010
Location: France
Posts: 97
Default

Quote:
Originally Posted by captain_caveman View Post
I have attached the version I am using with my changes so that we are all on the same page. It's working here.

It intentionally doesn't cut off notes when a Key Switch is received (the same as playing keyswitched instruments in a sampler), notes can be held after a Key Switch and can subsequently be released and cut off as normal (ie no hanging notes).
Hello captain

I tried your file. The problem is still here with your version and EWQLSO
stephane is offline   Reply With Quote
Old 01-09-2012, 12:56 PM   #24
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

Quote:
Originally Posted by stephane View Post
Hello captain

I tried your file. The problem is still here with your version and EWQLSO
Thanks for checking it out. Could you describe exactly what is happening please?

edit: And tell me what you expect should happen?
captain_caveman is offline   Reply With Quote
Old 01-09-2012, 12:58 PM   #25
stephane
Human being with feelings
 
Join Date: May 2010
Location: France
Posts: 97
Default

same thing as described by David here:

http://forum.cockos.com/showpost.php...0&postcount=17
stephane is offline   Reply With Quote
Old 01-09-2012, 01:55 PM   #26
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

Quote:
Originally Posted by stephane View Post
same thing as described by David here:

http://forum.cockos.com/showpost.php...0&postcount=17
I don't know what is happening then, because what I get is....

1. Press key to play note
1a Note plays
2. Press KS note to change channel (this note sounds if not filtered by other plugin)
2a Note continues playing (as intended)
2b Release KS note (this note stops if not filtered by other plugin)
3. Release key from step 1 to stop note.
3a Note stops.
etc etc etc with chords etc.

.... this is with a multitimbral VSTi (I'm using Plogue Chipsounds) on the same track or when routing to other tracks. I am using the Virtual MIDI Keyboard, but I can't imagine that making any difference.

Something that would make a difference is putting multi-channel MIDI into the plugin with the same notes overlapping.

Other than that, I have no idea.
captain_caveman is offline   Reply With Quote
Old 01-09-2012, 05:07 PM   #27
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

I've got it to work...Yippie.

However it is causing me some problems when playing back through Sibelius. I shall solve them and then post the new version

Captain, your code is very helpful, I added to the statusLo==8 - ||velocity==0 - because some controllers don't send out a NoteOFF message they just send a note on with no velocity.

Should have something to post soon
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-09-2012, 05:13 PM   #28
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

Quote:
Originally Posted by reddiesel41264 View Post
statusLo==8 - ||velocity==0 - because some controllers don't send out a NoteOFF message they just send a note on with no velocity.
Doh!

I should have spotted that one, my SL-990 does note-ons @ 0 vel instead of note-offs so I'm usually the one getting caught out by that.

Double Doh! Grr.
captain_caveman is offline   Reply With Quote
Old 01-09-2012, 05:15 PM   #29
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

Hahaha I have it working!!!! Will post soon, just want to tidy the code a bit
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-09-2012, 07:06 PM   #30
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default v1.3

So it turns out that when I said "hahaha I have it working" I was wrong

But now I do have it working hahaha!!!

If you guys could test it for me that would be great. It turned out to be really simple in the end, I just had to move Captain Cavemans bit of code and add one or two lines more. Took me ages to figure it out.


https://stash.reaper.fm/v/11328/Multi...DI%20Keyswitch

On a side note, I think Reaper is bloody awesome, only been using it a week but I think I'm converted. I love that I can make scripts for it. So much more flexible than other sequencers I've used. And I get to collaborate with you guys!
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-10-2012, 06:05 AM   #31
captain_caveman
Human being with feelings
 
captain_caveman's Avatar
 
Join Date: Dec 2011
Posts: 999
Default

Cool, if I could just point out one tiny, weeny last buglet...

You didn't have to shuffle my code around btw, just add a check for note-ons @ 0 vel to the note-off and a vel >0 bit to the note-on bit. Anyhoo, the way you have done it is very nearly correct, except...
Code:
//Check if we have recieved a note off message.
  statusLo == 8 || velocity==0 ? (
... checks for a note off or for any other message with a value of 0 (remember that value is only velocity if the message is a note), so whenever any MIDI message of value 0 was received it would cut off the corresponding note, if one was playing (eg note 82 would be cut off by a CC82 message at value 0).

So...
Code:
statusLo == 8 || (statusLo == 9 && velocity == 0) ? (
... will stop that happening.

For the record, this was the bit missing from my code to check for note-offs that are note-ons at zero velocity, as well as a bit to make sure these messages are not confused with actual note-ons....
Code:
statusLo ==9 && velocity > 0 ? (
... but of course, since you have put this section in an else (once you've added the note-off check above), you don't need to put that in since the initial if statement will have executed with a note-on @ zero velocity.
captain_caveman is offline   Reply With Quote
Old 01-10-2012, 06:17 AM   #32
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

Quote:
Originally Posted by captain_caveman View Post
Cool, if I could just point out one tiny, weeny last buglet...

You didn't have to shuffle my code around btw, just add a check for note-ons @ 0 vel to the note-off and a vel >0 bit to the note-on bit. Anyhoo, the way you have done it is very nearly correct, except...
Code:
//Check if we have recieved a note off message.
  statusLo == 8 || velocity==0 ? (
... checks for a note off or for any other message with a value of 0 (remember that value is only velocity if the message is a note), so whenever any MIDI message of value 0 was received it would cut off the corresponding note, if one was playing (eg note 82 would be cut off by a CC82 message at value 0).

So...
Code:
statusLo == 8 || (statusLo == 9 && velocity == 0) ? (
... will stop that happening.

For the record, this was the bit missing from my code to check for note-offs that are note-ons at zero velocity, as well as a bit to make sure these messages are not confused with actual note-ons....
Code:
statusLo ==9 && velocity > 0 ? (
... but of course, since you have put this section in an else (once you've added the note-off check above), you don't need to put that in since the initial if statement will have executed with a note-on @ zero velocity.
A yes, I will update the code now. Thanks again.
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-10-2012, 06:20 AM   #33
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default v1.3.1

Done


https://stash.reaper.fm/v/11328/Multi...DI%20Keyswitch
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-10-2012, 11:52 AM   #34
stephane
Human being with feelings
 
Join Date: May 2010
Location: France
Posts: 97
Default

Yeah works fine now.
No more problems

Thanks a lot
stephane is offline   Reply With Quote
Old 01-18-2012, 04:34 AM   #35
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default v1.3.2

I have made a small update. Have added an @Serialize section. Now the channel is no longer reset everytime you restart playback. So you can jump around in the piano roll MIDI editor and the Channel will be the same until you hit another keyswitch. A kind of latch effect.

Any bugs, let me know.

Link:
https://stash.reaper.fm/v/11328/Multi...DI%20Keyswitch
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-18-2012, 10:44 AM   #36
stephane
Human being with feelings
 
Join Date: May 2010
Location: France
Posts: 97
Default

v1.3.2 works fine !

Thank you
stephane is offline   Reply With Quote
Old 01-18-2012, 10:55 AM   #37
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

Brilliant! :-D
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 01-18-2012, 04:24 PM   #38
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

A little key switch instructional video - https://www.facebook.com/totalcompos...02235589828528
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Old 02-26-2013, 11:23 AM   #39
Geoff-h3o
Human being with feelings
 
Join Date: Oct 2008
Location: West Wales
Posts: 766
Default Where (or how) to install?

this looks like just what I need: I've copied it to


C:\Users\Geoff\AppData\Roaming\REAPER\Effects\LOSE R

but no joy.

This is on win 8 x64 running Reaper x86.

Thanks
Geoff-h3o is offline   Reply With Quote
Old 02-26-2013, 02:54 PM   #40
reddiesel41264
Human being with feelings
 
reddiesel41264's Avatar
 
Join Date: Jan 2012
Location: North East UK
Posts: 493
Default

I don't know what the problem could be I'm afraid, I'm running Windows 7 64bit but apart from that I have it in the same folder location and it's loading fine in Reaper. Maybe another Win 8 user could give it a go and we can see if it's an OS issue - although I doubt it is.

Do other user JS plugins work for you? Did you remember to scan for new plugins?
__________________
http://librewave.com - Freedom respecting instruments and effects
http://xtant-audio.com/ - Purveyor of fine sample libraries (and Kontakt scripting tutorials)
reddiesel41264 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.