transpose midi into letters

Motokiyo44

2015-10-20 21:48:58

Hello everybody,
I have a simple question, but not simple for me (I'm a noobs).
I have a device who translate resistance of my plant on MIDI message. I use this to make music, but I want to translate midi messages into words. So, for example, when she play C3, on my pages app, i would like she's able to write an A. Etc.
Sorry for my poor english, but I'm french. :roll:
Thank's. :mrgreen:

DvlsAdvct

2015-10-21 16:25:51

Hi motokiyo

Have you purchased MIDI Translator Pro, or downloaded MIDI Translator Classic? They both can handle MIDI to keystroke.

Thanks
Jared

Motokiyo44

2015-10-21 18:11:39

I have the classic, but want purchase the pro if I arrive to do my stuff with it. I'm sure I can do that with the app. But my question is how ;) can you explain me the way I have to use ? Thanks in advance.

DvlsAdvct

2015-10-21 22:10:36

Of course, I just wanted to confirm.

You need to create a translator for each key on your MIDI controller, and set a keystroke for the outgoing action. So let's start with with your example, translating C3 to A. We are going to translate the message C3 to hexadecimal, which makes it 90 (Note On Channel 1). I am hoping that it sends a different MIDI message when it's released (80 for Note Off) instead of just a 0 velocity. You would create a translator that looks like this:

Code: Select all

Translator 1: C3 to A
Incoming Action: 90 30 pp
Outgoing Action: Key Action: A
Make sure you select Key Action, and not Key Up or Key Down. This replicates not only pressing the key but releasing it. Also, this will work only with the application that is on top, so make sure your notepad is in front of everything else and the cursor is blinking. You may get two A's with this, and that is because your MIDI controller sends C3 on when pressed AND released. If that's the case you will need MIDI Translator Pro to handle this.

I hope that makes sense.
Thanks
Jared

Motokiyo44

2015-10-22 02:22:56

Thank you very much ! I try this tomorrow and tell you what is going on ! ;)

Motokiyo44

2015-10-22 14:49:22

Ouch ! So... I try to create what you explain to me.
But, when i create a new translator and select incoming key stroke... it is not possible to write two letters like C and 3, so i use midi message and select note on C3... but what i writ ein rules ? and in outgoing I select keystroke and write a. But nothing happend. Even if I select just behinf my pages app... :shock:
I'm sorry but i'm a really novice... I work with plants but never with midi before that... :cry:

Another question... I put the system on MIDI IN USB Midi in 1x1
but for the out.... to write on my pages app... Bome MIDI Translator 1 Virtual ? Gestionnaire IAC Bus 1 ? or others ?

Motokiyo44

2015-10-22 18:02:14

It work !!!!
So... now i would like she is able to write but only if she stay on the note more than 3 seconds... I imagine I need to apply a rule... that's it ?

I, unfortunely, don't know what is all the symbols.. : pp, tt, ss.... but I imagine that is one for what i want to do :wink:

Motokiyo44

2015-10-23 14:14:35

I try to explain a little more my purpose.
Now, i'm able to transpose MIDI (notes) messages in KeyStroke (like a, b, c etc...)
But I want to be able to write only when the plant hold the note more than 3 seconds.
I try to use delay...
For the moment, I have 26 translator. One by letter and one for the space bar.
My keyboard begin on C4 and finish on C6.

Can I code something to be able to accept letter only if the plant hold the note more than 3 seconds ?

Thank's for answers ;)

DvlsAdvct

2015-10-23 19:34:37

Ah, so that's a little bit more complicated. To do that you will need MT Pro, because we'll need timers and rules. Do you want to be able to play multiple keys at the same time and have multiple letters trigger at once, or do you only need one letter at a time?

Jared

Motokiyo44

2015-10-23 23:13:50

The plant can play three notes at the same time. But the most often, only the holding one is important. So I just want the holding ones. I have the pro version now.
Thank you for your help !

Motokiyo44

2015-11-13 15:03:55

Dear DvlsAdvct,
Did I write something wrong...
I wait for your solution.
Maybe I misunderstand what you asking me, but if it the cas, please tell me.
And If some others have the answer, please tell it to me ;)

DvlsAdvct

2015-11-16 23:01:53

Hi Motokiyo

So sorry for the delay. I've been caught up in some personal life stuff and it's just been a mess. Regardless, this should do what you want.

Since you are only worried about 1 key at a time, we will need one incoming message listening for the MIDI note, one for the timer, and then one for the 26 keystrokes. I'll get you started, but then let me know if you need any follow up.

Code: Select all

Translator 1: Note Press
Incoming Message: MIDI Message
Note On
Channel: 0 - Channel 1
Note: Any Note
Set Variable: pp
Velocity: Any Velocity
Set Variable: qq
Rules: if g1==1 then exit rules, skip outgoing action  
g0=pp
g1=1
Outgoing Message: Timer
Activate Timer
Timer Name: Keystroke
Initial Delay: 3000

Translator 2: Note Release 
Incoming Message: MIDI Message
Note Off
Channel: 0 - Channel 1
Note: Any Note
Velocity: Any Velocity
Rules: if g1!=1 then exit rules, skip outgoing action
if pp!=g0 then exit rules, skip outgoing action
Outgoing Message: Timer
Kill Timer
Keystroke

Translator 3: A
Incoming Message: Timer
Timer Name: Keystroke
Rules: if g0!=60 then exit rules, skip outgoing action
g1=0
Outgoing: Key Stroke
Physical Keys
A
And then you'll have 25 more translators just like Translator 3 except for ONE key difference. Every time you press a key, MT records the value as a global variable, g0. Then, when the timer triggers 3 seconds later it references what the value of g0 is. So 60 is C4. If you want two full octaves and a space bar that goes up to 85, I think. So you'd need one translator for each letter.

Does that make sense?
Jared

Motokiyo44

2015-11-16 23:24:45

I hope so ! ;) Thank you very much... I think I need time to be able to write this on the program. I have not find the way to write it like you show on your post. But with time, I will succeed ! :D

Thank's a lot ! :D:D:D

Motokiyo44

2016-12-17 07:18:57

Hello guys, I had not find the way to write the rules that Dvis gave me. Can someone help me one more time ;)

florian

2016-12-19 10:17:39

Hi, we probably don't have the time to create the full preset for all letters. But see below for the project file for example letters A and B.

Here is the (slightly simplified) project in text form:

Code: Select all

[x] Preset 0: Note to Keystroke after 3 seconds
 Default MIDI IN ports:   Keyboard

[x] Translator 0.0: Incoming Note On: start 3s timer
Options: swallow
Incoming: Note On on ch. 1 set 'g0' to note with any velocity
Outgoing: One-shot timer "Delayed Keystroke": 3000 ms delay

[x] Translator 0.1: Incoming Note Off: stop timer
Options: swallow
Incoming: Note Off on ch. 1 set 'pp' to note with any velocity
Rules:
  // if pressing more notes at the same time,
  // only consider the last one. So don't stop
  // the timer if releasing an "old" note
  if g0!=pp then exit rules, skip Outgoing Action
Outgoing: Kill timer "Delayed Keystroke"

[x] Translator 0.2: A
Incoming: On timer "Delayed Keystroke"
Rules: if g0!=60 then exit rules, skip Outgoing Action
Outgoing: Text: a

[x] Translator 0.3: B
Incoming: On timer "Delayed Keystroke"
Rules: if g0!=61 then exit rules, skip Outgoing Action
Outgoing: Text: b
Below in the attachment you can download the project file. It should be easy to add the translators for the other letters. Use the "Duplicate" function!
Florian
Attachments
NoteToDelayedKeystroke.bmtp
(1.83 KiB) Downloaded 224 times

Motokiyo44

2016-12-19 22:19:00

Thank you very much ! ;)
But even with your doc it is hard to me to understand... How can I decide for A = C3, B=C#3, C, etc... i don't understand if I need to redo your entry or if it possible with the variable g0a and it will be automatic that the app increment A in C3 etc. Cause my device work wibcdefghijjjjjjjjjjjjjjjjth (she wrotae just now... sorry) with a keyboard like piano. Sorry for my missunderstand and my poor english . :oops:

Motokiyo44

2016-12-19 22:20:34

She seems to be capable to play A or BCDEFJHIJJJJJJJJJJJJ (cause I duplicate J for the other letters) so, it means a and B are on two keys... I go back to try to find.

Motokiyo44

2016-12-19 22:39:18

Ok, I have found. You increment g0. But what is the key of g0=60 ? C4 ? And is it possible to increment when she stay 10 second then make erase (i don't find how to put erase ?) and when you double play the same note, then make a space... Sorry, if I abuse

florian

2016-12-21 23:19:19

Hi Motokiyo44,
yes, 60 is C4 (if I'm not mistaken).

10 second: erase
That's definitely possible, but the more special cases you add, the more complex the whole thing becomes.
Why don't you define a note key for erase?

Double play the same note: SPACE
Yes, possible, too, and not so hard.
A scheme would be like this:

Replace the first translator like this:

Code: Select all

Translator 0.0: Incoming Note On: start 3s timer
Options: swallow
Incoming: Note On on ch. 1 set 'pp' to note with any velocity
Rules:
 if pp==g0 then pp=10
 g0=pp
Outgoing: One-shot timer "Delayed Keystroke": 3000 ms delay
Instead of directly assigning g0 to the currently played note, we store it in the temp variable pp. Now if pp has the same value as the previous note (pp==g0) then change the note to 10. 10 is an arbitrary value which probably is too low for your keyboard, so we use it as a special value meaning SPACE.

Of course, then you need a translator to react on g0==10:

Code: Select all

[x] Translator: Space
Incoming: On timer "Delayed Keystroke"
Rules: if g0!=10 then exit rules, skip Outgoing Action
Outgoing: Text: SPACE
And to make sure the double detection is only happening when not trying to play two times the same letter, reset g0 to 0 at the end (after ALL the other translators)

Code: Select all

[x] Translator: last translator, reset g0
Incoming: On timer "Delayed Keystroke"
Rules: g0=0
Outgoing: none
Hope that makes sense.
Florian

Motokiyo44

2016-12-22 00:32:16

Ouch !!! Ok, I'll try this ;)
Another thing, I don't see possibility to oblige the keyboard to write only on one application. When I am on the Web for example, it is writing. Is it possible to oblige it to use only one app even it is not the common app ?

florian

2016-12-28 16:11:15

Hi Motokiyo44,
it is currently not possible to restrict keystrokes to a particular application.
Exceptions:
- on Windows, you can use "inject events", in the outgoing Keystroke action. Injecting will only send the keystrokes to the selected application, but injecting does not work with all applications. You can try.
- on MacOS, you could use AppleScript as outgoing action instead of using Keystroke Action to send keystrokes directly to an application.

Regards,
Florian