View Single Post
Old 08-02-2017, 10:46 PM   #1505
Display
Human being with feelings
 
Display's Avatar
 
Join Date: Jun 2017
Posts: 2
Default MIDI Velocity Filter

Thank you for the suggestion chumbo! I did try those (and one did filter out the velocity but not channel specific). I'm avoiding using them as they're 32-bit and require bridging.
Ideally I'd like to use as small as possible optimal/efficient script .'D

After more searching I managed to find a someone with similar problem, so I decided to go ahead and butcher someone else's script.
I used juliansader's pitch & velocity filter
Code:
Obsolete script. See Edit!
No idea if it's correct... but it does seems to work.
No clue how to integrate "Channel Input", but this will have to do for now as I'm beyond perplexed by scripting ,'/

EDIT:
Spent more time butchering more peoples scripts and managed to get it to filter out only the specified MIDI channel!! .'D
Hope this can help someone else suffering with super sensitive AKAI MPD pads!



Code:
//Original script from juliansader: https://forum.cockos.com/showpost.php?p=1744511&postcount=12
desc: MIDI Velocity Filter
	
slider1:0<0,16,1{All,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>Channel Input
slider2:11<0,127,1>Velocity Threshold

in_pin:none
out_pin:none

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

////////////////////////////////////////////////////////////////////////////////////////////
@slider

inChannel = slider1 -1;
velocityThreshold = slider2;

////////////////////////////////////////////////////////////////////////////////////////////
@block
while
(
	midirecv(offset, msg1, msg23) ?
	(
	channel = msg1 & $x0F;
	// Is it on the selected channel
	(channel == inChannel || inChannel == -1) ? 
		(
		// Extract MIDI data
		// Note that in JS's msg23, the lower 8 bits is msg2, and the higher 8 bits is msg3.
		eventType = msg1 >> 4;
		velocity = msg23 >> 8;
		// Is it a note-on or note-off event?
		(eventType == 9 || eventType == 8) ?
			(
				// If note-on, check velocity
				(eventType == 9 && velocity != 0) ?
				(      
					(velocity >= velocityThreshold) ?
					(
						midisend(offset, msg1, msg23); // Not filtered, pass through
					);
				);
				// Is note-off? (Remember that note-on with velocity = 0 is actually a note-off.)
				(eventType == 8 || (eventType == 9 && velocity == 0)) ?
				(
					midisend(offset, msg1, msg23); // Otherwise, pass through note-off event.
				);
			) : 
			// If not note event, just pass through
			(
				midisend(offset, msg1, msg23);
			);
		) :
		// Pass message on
		midisend(offset, msg1, msg23);
		// JS 'while' loops will loop until last statement in block is equal to zero.
		1; // Force loop to continue until all messages have been processed
	);
);
Attached Files
File Type: zip MIDI_Velocity_Fillter.zip (1.4 KB, 134 views)

Last edited by Display; 08-09-2017 at 07:34 AM. Reason: working script!
Display is offline   Reply With Quote