Jump to content

Script to change notes into program changes?


Onegin0

Recommended Posts

Hi guys

 

I'm looking for a script that takes keyswitch notes and changes them into program changes.

 

C1 -> Program Change 1

C#1 -> Program Change 2

D1 -> Program Change 3

 

etc

 

I'm new to scripting. Any pointers? No idea if this is a one line job or a big job!

 

Thanks

Link to comment
Share on other sites

Just change the cases to the different Keyswitch note numbers you want to use and pc.number to the program change numbers,

Anything that isn't a keyswitch is treated like a normal note

 

function HandleMIDI(e) {
if (e instanceof Note) {
		switch (e.pitch) {
			case 20:
				var pc = new ProgramChange();
				pc.number = 1;
				if (e instanceof NoteOn)
					pc.send();
				break;
			case 21:
				var pc = new ProgramChange();
				pc.number = 2;
				if (e instanceof NoteOn)
				pc.send();
				break;
			default:
				e.send();
		}
} else
	e.send();
}

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...