Volume override with MIDI Translator?

eno

2016-10-19 18:06:04

Hello, I'm a newbie here and want to find out if the MIDI Translator can help me to solve one problem. I have a MIDI guitar and a MIDI volume pedal and I want to control the volume by the pedal rather than by the velocity of my sting picking so need to override the volume content of the MIDI signals from the guitar with the volume signal from the pedal. Can I do that using MIDI Translator? Thanks!

Sakis

2016-10-20 00:37:57

As long as the volume pedal transmits Midi data ,yes it's possible :D

florian

2016-11-01 11:57:02

Hi eno, let us know if you need assistance with setting up MT Pro for that!
Florian

eno

2016-11-01 18:11:50

Thanks Florian.

In addition to velocity flattening (this is easy I guess) I also need to silence the glitches (very short notes). I'm trying to figure out an algorithm for that:
- The first translator is triggered by note-on event, waits a sertain delay time and checks if the current note ID is equal to note_off_ID. If yes then no further action, if no the note goes to the output
- The second translator is triggered by note-off event and sets a global variable note_off_ID

I understand that if there are two glitches occuring at the same time then the ID of the first one will be overwritten by the second one but this scenario is very unlikely because the glitches are very short so it's ok.

Do you think this will work? Will the second translator be triggered independently and in parallel with the first translator while the first translator is executing the wait? The flowchart on p.78 of the manual shows a sequential processing but then the section 12.3 talks about parallel processing so I'm confused.

sjcaldwell

2016-11-01 18:53:49

From what I've observed it looks like although the translators execute sequentially, they do not wait until the current translator is executed before moving on to the next, so execution appears sequential but processing appears parallel.

Sakis

2016-11-02 01:11:12

I tried something but you need to make separate rules for each midi note. It would be very time consuming.
Keep in mind that you have to add more latency to detect the time duration between mote on and off.
If for example the glitch is 50ms ,then all notes will be delayed 50 ms.
Could you try recording in a sequencer ,isolate some glitches and post the duration of the glitch?

Another approach is looking at the velocity of the glitches. If they are always below a threshold it would be easier to filter the note and there would be no need for detecting the time duration (and no latency added)

eno

2016-11-02 02:01:58

I tried something but you need to make separate rules for each midi note. It would be very time consuming.
goodness, you are right! Is there a way to trigger on any note, capture the note number, assign it to a variable and then pass it to the MIDI output note number?
Keep in mind that you have to add more latency to detect the time duration between mote on and off.
If for example the glitch is 50ms ,then all notes will be delayed 50 ms.
Yes I understand, this is the price to pay. glitches are worse than latency
Could you try recording in a sequencer ,isolate some glitches and post the duration of the glitch?
No, I need this for live performance
Another approach is looking at the velocity of the glitches.
no, they are pretty loud

This is for MIDI guitars like Fender Squire MIDI, Lineage and YRG, they produce double notes and glitches

Sakis

2016-11-02 03:46:38

Is there a way to trigger on any note, capture the note number, assign it to a variable and then pass it to the MIDI output note number?
I can't find a project I did in the past . Polyphonic to mono ,where I had to store notes to variables. I will try again tomorrow.

Regarding the recording :
It will help to set the detection time to a proper value. Also if the glitches are over 50ms ,latency will ruin the live performance.

In the meantime ,have you checked an app called Midi Guitar?
http://www.jamorigin.com/products/midi-guitar/

I tried the demo in the past and it has great potential.

eno

2016-11-02 04:18:34

It will help to set the detection time to a proper value. Also if the glitches are over 50ms ,latency will ruin the live performance.
I know, right now I'm doing it in Kontakt and if I set detection time to 40ms it removes most of the glitches with tolerable latency
In the meantime ,have you checked an app called Midi Guitar?
http://www.jamorigin.com/products/midi-guitar/
I tried the demo in the past and it has great potential
yes I tried that and many more (Fishman Triple Play, YouRockGuitar, Lineage, Fender MIDI...), they are all with flaws especially for fingerpicking and classical style playing. No perfect MIDI guitar exists yet, Lineage and Fender Squire MIDI are the best but still with problems, namely double notes in some modes. Lineage makes double notes with right hand fingerpicking (when playing with nails) but works great in tapping mode, Fender is the other way around - works great for fingerpicking but makes double notes in tapping mode. I'm trying to find a way to fix it.

Sakis

2016-11-05 22:02:12

Try the project attached :)

With keys 4,5,6,7,8,9,0 you set detection time to 40,50,....90,100ms (70ms is the default).Not with the numeric keys because some laptops don't have.
Velocity (on launch) by default is 127 ,but is assignable. I mapped it to GM volume CC#7 on channel 1 but you can change the CC#.
Also midi notes are set on channel 1.

The polyphony (inducing glitches) must NOT exceed 9 notes in the detection time.
The good news is that you can adjust it by adding more variables (VOICES).

Since it would take more time for me to explain the project than time I spend to make it, I would prefer ,you test it first and then I'll explain it.
Attachments
NoGlitchMidiGuitar6.bmtp
(5.32 KiB) Downloaded 146 times

eno

2016-11-06 03:00:03

WOW, thank you so much Sakis! I tried this and it works which immediately made me buy a license :) I also added another preset to pass any control-change messages from in to out.

Sakis

2016-11-06 05:58:43

Nice :D
Well, this means I have to explain how it works... :roll:

Hopefully, in a few days, have fun!

eno

2016-11-06 13:14:37

Sakis wrote:Well, this means I have to explain how it works... :roll:
you don't have to, I can figure it out myself just by looking at the code, it will be a good exercise for me

eno

2016-11-06 18:17:47

Sakis, I'm seeing a strange problem. When I fresh start the Bome your code works well. Then after some playing and sending control commands it suddenly stops sending note-off signals to MIDI out. The note-off signals are still visible in the translator output but not in the output of the whole script. I tried to reinstall the Bome and reboot the comp, no difference. See the screenshot
Attachments
Bome no note off.jpg
Bome no note off.jpg (207.79 KiB) Viewed 6010 times

Sakis

2016-11-06 20:52:25

Hi,
Lets check 2 scenarios
1. polyphony exceeds the 9 voices . I put 2 global variables . "k4" will take a value of "44" in case of too many noteOn messages and "k9" will take a value of "99" when too many note-off messages .

2. There might be a chance that the timer reaches a maximum value and starts not from zero but from a negative large number. In that case "kt" will get a value of 33.

While playing and everything is normal I'd suggest you go in BMT log window and click on "Dumb Variables". Save the values somewhere . Then when problem comes click again to "Dumb Variables" and post all here.

It is normal you see note-off signals in the translator output since you have selected "capture midi". This captures all the input signals from all ports :)
The problem is in the project ,but we will figure this.
Attachments
NoGlitchMidiGuitar7.bmtp
(5.46 KiB) Downloaded 140 times

eno

2016-11-06 21:53:31

weird, I don't see those k4, k9 and kt variables in the Dump Variables output:
Attachments
Bome no note off 2.jpg
Bome no note off 2.jpg (188.07 KiB) Viewed 6000 times

Sakis

2016-11-06 22:27:59

They don't show if they zero. It means that polyphony is not the problem ,nor the timer...
Did you have the same issue when captured the screenshot?

EDIT: Wait, I made a mistake on timer...
I made a rule on counter (1:2, Preset 1 : Translator 2)

Code: Select all

//debug ,check if timer reaches maximum and resets to negative number
if gt<0 then kt=33
Attachments
NoGlitchMidiGuitar7a.bmtp
(5.47 KiB) Downloaded 156 times

eno

2016-11-07 02:50:15

I think I figured what the problem is: after 1/2 hour or so the gt timer counter reaches the max 2197739 and stops there so it has to be restarted

Sakis

2016-11-07 12:23:03

That's an easy fix, we will make a rule to reset the timer but we need to also edit the subtraction a in case of negative number.
Let's say that the timer max value is 100. When a note arrives at gt 90 then g1=90.
But when a note of message comes the subtraction would be g1= gt - g1, and if we reset timer to zero a possible gt value would be less than 100, maybe 30
So g1 would be g1= 30 - 90 resulting in minus 60.
We will put a rule on each voice

Code: Select all

if g1<0 then g1=0-g1
And on the counter gt=gt+1 another rule

Code: Select all

if gt> 2197000 then gt=0

eno

2016-11-07 18:24:21

OK I can try that.
Sakis wrote:We will put a rule on each voice

Code: Select all

if g1<0 then g1=0-g1
should I put this into the voices of NoteOn or NoteOff or both translators?

Sakis

2016-11-07 21:09:05

Time to explain the project. (1:0, Preset 1 : Translator 0)
On launch we trigger a timer that hits always every 1 msec to '1:2'. There we set a counter "gt=gt+1" and time is generated!

0:0
Triggered by any Note-On message "oo" , rules:

Code: Select all

if ga==0 then Goto "VOICE1"
if gb==0 then Goto "VOICE2"
....
if gh==0 then Goto "VOICE8"
if gi==0 then Goto "VOICE9"
The global variable "ga" is zero (all globals are zero when we start a project ,unless we set them to a specific value).
This means that the translator will jump to Label "VOICE1" :

Code: Select all

Label "VOICE1"
ga=oo
g1=gt
exit rules, execute Outgoing Action
Now ,"ga" will take the value of the first NoteOn message, lets say it's "40" so we have our first identified NoteOn message which came on time g1=gt (remember the gt counter). Now we exit rules and trigger a timer once ,named "Note",but with a delay of "gl"=70ms to give us time to calculate things. (it's gl, not g1)
The "Note" timer will hit all translators from 0:2 to 0:10 ,but on these translators we have set some rules. Let's see what is happening on 0:2

Code: Select all

A. if ga==0 then exit rules, skip Outgoing Action
B. h1=h1+1
C. if h1>1 then exit rules, skip Outgoing Action
BMTpro will ignore rule A since "ga" got a value of "40".Nice! Now on 'B' there is a strange "h1" counter. This counter is essential to avoid multiple triggers. We we talk about this very soon. Now "h1" has a value of 1 which is NOT greater than 1 so rule 'C' will be ignored. BMTpro will execute the outgoing action which is a note 40 .
from 0:3 to 0:10
gb,gc,gd ....etc =0 ,so the outgoing action (triggering a note gb,gc,gd........) will be ignored!
It's time to pause here and create a scenario where we play our second Note with value of 50.(note 40 is still played)

Let's go back to 0:0

Code: Select all

if ga==0 then Goto "VOICE1"
It's not zero so BMTpro will go to next rule (this is serial)

Code: Select all

if gb==0 then Goto "VOICE2"
This one is zero so it will take a value of gb=50 and timestamped on gb=gt. But it will also trigger the one-shot timer "Note" which will hit again all translators from 0:2 to 0:10.
0:2
A. is not zero so we go to B.
B "h1" was 1 and now it will be 2
C. 2 is indeed greater than 1, so we managed to tell BMT not to trigger again the "ga" note output, yeah!

0:3 Now you got the point. It is not zero and it's the first time that the timer "Note" hit it so we have our second note "gb" output
0:4 to 0:10 gc,gd.... are zero so nothing bad will happen!

All good, but how can we avoid the glitches?
Let's say that a glitch note-on message arrived which will take a "gc"=60 and gt=12000msec. That will trigger the usual "Note" timer and hit translators 0:2 to 0:10. The race starts!We have 70ms as I've mentioned erlier to calculate things!
As we know glitches are very short in duration and let's pretend that glitch had a duration of 50msec. This means that we have a NoteOff message "oo"
0:1

Code: Select all

if oo==ga then Goto "VOICE1"
if oo==gb then Goto "VOICE2"
if oo==gc then Goto "VOICE3"
ga and gb are still not zeroed so BMT will go to Label 'VOICE3'

Code: Select all

Label "VOICE3"
A. gc=0
B. h3=0
C. g3=gt-g3
D. if g3<0 then g3=0 //we'll talk about this later
E. if g3<gl then exit rules, skip Outgoing Action
It's time to initialize "gc" since we don't need it anymore (note "gc" has already triggered the timer ,let's hurry up!)
B. initialize "h3" which is used to avoid double triggers from the "Note" timer.
C. g3=12050-12000=50ms so on rule E ( g3<gl => 50<70=True ) will will skip triggering the output of "oo" NoteOff message! Great we killed the glitch NoteOff message!
But now the 70ms passed and timer "Note" hits translator 0:3,
if ga==0 then exit rules, skip Outgoing Action it is still 40 so BMT moves to next rule
h1=h1+1 //it was already hit twice so now h1=3
if h1>1 then exit rules, skip Outgoing Action // no false midi note output!

0:4 still 50 , "h2"=2 and again no false midi trigger

0:5 .

Code: Select all

if gc==0 then exit rules, skip Outgoing Action
Congratulations , on the NoteOff message 0:1 we have already initialized "gc" so no glitched note is generated!!!

Now it's time to release the previous virtual note on messages ga=40,gb=50 and since the period of time ,passed from the note-on to note-off message ,Is greater than "gl" 70 we will trigger successfully the appropriate note off messages on 0:1


You had a problem where the timer stopped. This means that either BMT has a fail safe mechanism and stops timer after long time (it will be trouble,so I hope not) or we must simply reset manually the timer . So on 0:2

Code: Select all

gt=gt+1
I added

Code: Select all

if gt>2197000 then gt=0
That could lead to a problem. Let's say we have a note on event after 2197000ms .As an example ga is triggered and g1=2197000
Time always runs so "gt" went back to zero and starts rising again. This is where the problem comes. At a NoteOff message we have a rule to calculate time. (as an example note-off came after 2 sec)
g1=gt-g1=>
g1=2000 - 2197000 which is <0 so

Code: Select all

if g1<gl then exit rules, skip Outgoing Action
-2195000<70 and we never get a noteoff event.

So I've placed
if g1<0 then g1=0-g1

Take your time :D
Attachments
NoGlitchMidiGuitar8a.bmtp
(5.39 KiB) Downloaded 113 times

eno

2016-11-08 00:59:22

Sakis, thanks a LOT! The code works great now, the only bug there (I fixed it myself) is that you forgot to place "exit rules, execute Outgoing Action" at the end of each voice in the NoteOff translator (you had them in the original code v6). Here is the final code with all fixes and also passing the control messages to the out
Attachments
NoGlitchMidiGuitar9a.bmtp
(5.61 KiB) Downloaded 130 times

Sakis

2016-11-09 16:50:28

Nice!
About the "exit rules, execute Outgoing Action" on 0:1 ,
I removed them on purpose ,because BMT will return from the Label to the other rules and ....hmmmm...
OK, YOU ARE CORRECT. I assumed that the other variables would be zero , but sometimes they are not. Thanks!