Constant Stream of CCs >> single Note On Message

60Works

2012-07-03 00:21:35

Hi Folks!

I'm working on a controller for a client, and he needs a single drum pad on his unit. I'm all set on the hardware side with the appropriate wiring and components. (Picture) That square unit sends data based on the amount of pressure you put on it.

Problem is, the MIDI unit for this project doesn't have the firmware to convert those messages into an appropriate velocity-sensitive Note On message. All I can receive is a constant stream of CC data. So, I'm writing my own firmware with MT!

I've spent the day noodling around, and have made some progress. I'm looking for help with one problem, related to this "constant stream of CC data."


Let me try to break this down:

INPUT is a stream of CC data. The starting CC value is random. The length of the stream is random. The end of the stream is ALWAYS a value of 0.
Desired OUTPUT is a Note ON message based on the first CC value of the stream. That note should stay held (not repeated) through the length of the stream. The note is OFF when the stream ends.

What I CAN do:
1. Capture the first CC value and store it through the length of the stream. (This is the note velocity.)
2. Identify when the stream ends. (This is the Note Off.)

What I CANNOT do:
* Hold a SINGLE, NON-REPEATING note through the length of the stream.


Any advice here? The problem here is that the trigger for this action is constantly sending data, while I only care about the start and end points. I think I need to create some kind of external variable + trigger to represent the "Press" action.


Thanks much!
Dave Cross

DvlsAdvct

2012-07-05 16:08:18

Hi 60Works (huge fan of the site :))

What you want to do is totally possible. It requires the use of timers to tell MT that the button is still pressed, and then that it is released.

My only question is does it matter what the initial value is? If all the ccs are random, do you want it to read a velocity or just on/off? I'll go through the examples for just on/off, but if we need to make it more complex let me know.

For timers it's pretty easy. I'm going to use 90 00 pp as the example incoming message. It would be coded as such

Code: Select all

Translator 1: Press
Incoming Message: 90 00 pp
Rules:
if pp>0 then Goto "Down"
if pp==0 then Goto "Up"
Label "Down"
if g0==1 then exit rules, skip outgoing action
g0=1
Exit rules, execute outgoing action
Label "Up"
g0=0
Exit rules, execute outgoing action
Outgoing message: Press Timer 0ms

Translator 2: Press Timer
Incoming Message: Press Timer
Rules: if g0==1 then pp=127
if g0==0 then pp=0
Outgoing Message: 90 00 pp
That should lock out all incoming messages from the button once the button is pressed. This should be the cleanest way to handle it. If you prefer a different method involving Presets let me know and I can code that up as well as an example. :)

Thanks
Jared

60Works

2012-07-06 00:53:42

Wow, that worked wonderfully! I don't know if I would've figured that out on my own, thanks so much for the help!
(And thanks for the kind words about the site. Your help is directly affecting my ability to satisfy a client, so you're a part of the process now!)

I used your code to make a version that reads velocity, scales it a bit, and makes sure that any extra-hard presses are limited to a velocity of 127. It's below.

Is it impossible to use decimal points in Expressions? Any workarounds? (You'll notice my weird fraction math to scale. X*=1.25 would be much easier ;))

Code: Select all

Preset 4: From Forums

Translator 4.0: Press
Options: stop=false
Incoming: MIDI B0 24 pp
Rules: 
  if pp>0 then Goto "Down"
  if pp==0 then Goto "Up"
  Label "Down"
  if g0==1 then exit rules, skip Outgoing Action
  g0=1
  g1=pp
  exit rules, execute Outgoing Action
  Label "Up"
  g0=0
  exit rules, execute Outgoing Action
Outgoing: One-shot timer "Timer": 0 ms delay

Translator 4.1: Press Timer
Options: stop=false
Incoming: On timer "Timer"
Rules: 
  if g0==0 then g1=0
  oo=g1/3
  qq=g1/4
  ss=oo+qq
  rr=g1/13
  tt=ss+rr
  g1=g1+tt
  if g1>127 then g1=127
Outgoing: MIDI 90 4A g1

DvlsAdvct

2012-07-06 02:03:05

If you need it scaled by 1.25 it would be easier to multiply by 125 and then divide by 100. The problem you run into is you'll never get a value lower than 2, as MIDI Translator always rounds up. But if that isn't an issue this should work fine.

I agree, though. I know the update to 2.x is going to include a BUNCH of updates that will make all of our lives easier. I'll put this on the list for Florian to include, if he doesn't already have it. :)

I'm generally around for questions, so don't hesitate to bring any.

60Works

2012-07-06 17:04:06

Thanks again mate!