It is currently Sun Jan 19, 2020 2:48 am



Reply to topic  [ 34 posts ] 
 How to get midi working? 
Author Message
One Eyed Hopeful

Joined: Thu Sep 03, 2015 4:24 pm
Posts: 6
Reply with quote
I've read that freepie now can be used for midi but I can't grasp how to pull it off. I'd like to be able to use both gamepads and an extra qwerty-keyboard as midicontrollers with my music software (Which is jeskola buzz). If someone could push me towards a pedagogic tutorial I'd be utterly grateful.

Thx
Anders


Thu Sep 03, 2015 4:30 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
You can check this thread for some samples

viewtopic.php?f=139&t=20537

edit: aha, we only support reading. Can look into writing too

_________________
FreePIE
My blog


Fri Sep 04, 2015 11:05 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
I did a test shot, I havent tested it so cant tell if it works

Somethign like this to send on port 0, channel 0, control mode note off, data = 127

Code:
midi[0].data.channel = 0
midi[0].data.status = MidiStatus.NoteOff
midi[0].data.dataOne = 127


edit: I do not support the these bits, maybe they are needed for the program to work?

Code:
11110000= F0= 240   System Exclusive   **   **
11110001= F1= 241   MIDI Time Code Qtr. Frame   -see spec-   -see spec-
11110010= F2= 242   Song Position Pointer   LSB   MSB
11110011= F3= 243   Song Select (Song #)   (0-127)   none
11110100= F4= 244   Undefined (Reserved)   ---   ---
11110101= F5= 245   Undefined (Reserved)   ---   ---
11110110= F6= 246   Tune request   none   none
11110111= F7= 247   End of SysEx (EOX)   none   none
11111000= F8= 248   Timing clock   none   none
11111001= F9= 249   Undefined (Reserved)   ---   ---
11111010= FA= 250   Start   none   none
11111011= FB= 251   Continue   none   none
11111100= FC= 252   Stop   none   none
11111101= FD= 253   Undefined (Reserved)   ---   ---
11111110= FE= 254   Active Sensing   none   none
11111111= FF= 255   System Reset   none   none


You do not have the required permissions to view the files attached to this post.

_________________
FreePIE
My blog


Fri Sep 04, 2015 1:17 pm
Profile
One Eyed Hopeful

Joined: Thu Sep 03, 2015 4:24 pm
Posts: 6
Reply with quote
Sorry for not understanding.

Freepie downladed and installed. Then what?
I can't get my head around how or where to start.
Could someone put me infront of an understandable tutorial?
I've glanced at the forum, the homepage, youtube and even glovepies documentation but not really grasping things... :oops:


Fri Sep 04, 2015 4:06 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
I gave you some pointers on the Swedish forum

_________________
FreePIE
My blog


Sat Sep 05, 2015 3:38 am
Profile
One Eyed Hopeful

Joined: Thu Sep 03, 2015 4:24 pm
Posts: 6
Reply with quote
Hi. I decided to try for a while with fergo's tool at fergonez.net since it seemed like a soft start but it died on me with runtime error 380 so I decided to learn freepie way now.

Found a glovepie-script that I thought I could use as inspiration/guidance but it won't work. Is it at all compatible?

Code:
    //DUEL ACTION GAMEPAD TO MIDI
    //WRITTEN FOR MIDI CHAN 1 ON JOYSTICK #1
    midi.DefaultChannel=1
    //BUTTONS
    midi.C1=joystick1.Button1
    midi.D1=joystick1.Button2
    midi.E1=joystick1.Button3
    midi.F1=joystick1.Button4
    //TOP BUTTONS
    midi.G1=joystick1.Button5
    midi.A1=joystick1.Button6
    midi.B1=joystick1.Button7
    midi.C2=joystick1.Button8
    //SELECT/START BUTTONS
    midi.D2=joystick1.Button9
    midi.E2=joystick1.Button10
    //STICK BUTTONS
    midi.F2=joystick1.Button11
    midi.G2=joystick1.Button12
    //POV
    midi.A2=joystick1.Pov1Up
    midi.B2=joystick1.Pov1Down
    midi.C3=joystick1.Pov1Left
    midi.D3=joystick1.Pov1Right
    //midi.E3=joystick1.Pov1Center
    //ANALOG STICKS
    midi.Control1=(joystick1.x/261)+64
    midi.Control2=(joystick1.y/261)+64
    midi.Control3=(joystick1.z/261)+64
    midi.Control4=(joystick1.roll/261)+64


Fri Sep 18, 2015 3:12 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
FreePIE is based on python and have a completely different syntax.

I can wipe something up as a test for you, and you can work it from there

_________________
FreePIE
My blog


Sat Sep 19, 2015 2:49 am
Profile
One Eyed Hopeful

Joined: Thu Sep 03, 2015 4:24 pm
Posts: 6
Reply with quote
ah. guess it's me cheating again, hoping for the best. I remember reading that freepie was a successor to glove pie so I thought they where more compatible.

if you would give me a headstart with something I could work from and even learn something, then I'd be both happy and grateful.
if it's for gamepad or qwertykeyboard is equally good.


Sat Sep 19, 2015 5:31 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
Code:
midi.C1=joystick1.Button1


Looks like Glovepie has an abstaction layer so that you easy set notes directly. We dont have that. Maybe something can be done in the future. Right now you got to hard wire it. Someting like

Code:
def sendNote(note, strength):
   diagnostics.debug("note {0}", note)
   midi[0].data.status = MidiStatus.NoteOn
   midi[0].data.dataOne = note
   midi[0].data.dataTwo = strength

if starting:
   midi[0].data.channel = 0   
   
if keyboard.getPressed(Key.A):   
   sendNote(64, 127)

_________________
FreePIE
My blog


Sun Sep 20, 2015 4:53 am
Profile
One Eyed Hopeful

Joined: Thu Sep 03, 2015 4:24 pm
Posts: 6
Reply with quote
Apologies for my late reply and thank you for your efforts. My wife is ill so it'll take a while before I get to look into this but when I do, I'll write back.


Tue Sep 22, 2015 2:04 pm
Profile
One Eyed Hopeful

Joined: Mon Jan 05, 2015 4:33 am
Posts: 23
Reply with quote
If I understand this correctly: Is (basic) midi output already in the current version but untested?

Ah! Overlooked the attached file - will test in some days (have lot's of work to do right now)
Theoretically midi output shouldn't be too different to midi input and easy to implement (yeah - it's easy to say that :P )


Thu Oct 01, 2015 4:13 am
Profile
One Eyed Hopeful

Joined: Mon Jan 05, 2015 4:33 am
Posts: 23
Reply with quote
I finally found some time! Writing to MIDI would be an awesome feature - already seeing some stuff I could do with that!

So far I have no luck with your test version above. I figured out that

midi[0].data.buffer[0] and
midi[0].data.buffer[1]

now is called

midi[0].data.dataOne and
midi[0].data.dataTwo

I don't really know what to make out of "MidiStatus.NoteOn" and "MidiStatus.NoteOff". On my device midi[0].data.status is always "Control" if I watch it with diagnostics.watch()

Regardless this is the code I derived from the one posted above to test it with my device:

Code:
def sendNote(bufferzero, bufferone):
   diagnostics.debug("bufferzero {0}", bufferzero)
   midi[0].data.status = MidiStatus.NoteOn
   midi[0].data.dataOne = bufferzero
   midi[0].data.dataTwo = bufferone
   diagnostics.watch(midi[0].data.dataOne)
   diagnostics.watch(midi[0].data.dataTwo)
   diagnostics.watch(midi[0].data.channel)
   diagnostics.watch(midi[0].data.status)

if starting:
   midi[0].data.channel = 0
   
if keyboard.getPressed(Key.A):   
   sendNote(20, 127)
   
if keyboard.getPressed(Key.D):   
   sendNote(20, 0)


doesn't have any effect on my device so far


Fri Oct 09, 2015 10:16 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
midi[0] means port zero and you use channel 0 is that correct for your device?

_________________
FreePIE
My blog


Sat Oct 10, 2015 4:09 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
also, please try this version, did some minor changes, might help


You do not have the required permissions to view the files attached to this post.

_________________
FreePIE
My blog


Sat Oct 10, 2015 4:16 am
Profile
One Eyed Hopeful

Joined: Mon Jan 05, 2015 4:33 am
Posts: 23
Reply with quote
CyberVillain wrote:
midi[0] means port zero and you use channel 0 is that correct for your device?


Yes. I used a version of the old diagnostics.watch script to look up my stuff:

Code:
def update():
   diagnostics.watch(midi[0].data.channel)
   diagnostics.watch(midi[0].data.status)
   diagnostics.watch(midi[0].data.dataOne)
   diagnostics.watch(midi[0].data.dataTwo)
   
if starting:
   midi[0].update += update


had these results using input from my device:
Image


CyberVillain wrote:
also, please try this version, did some minor changes, might help


I ditched the code I tried with the last Output because I didn't understand all of it and wrote my own script (turned out to be somewhat similar but simpler. maybe too simple?).

Code:
def WriteToMidi(bufferone):
   midi[0].data.channel = 0
   midi[0].data.status = MidiStatus.Control
   midi[0].data.dataOne = 20
   midi[0].data.dataTwo = bufferone
   
if keyboard.getPressed(Key.A):   
   WriteToMidi(126)
   
if keyboard.getPressed(Key.D):   
   WriteToMidi(1)


Because the channel, status and first array in my more simple MIDI device is always the same, maybe it could be reduced like this:

Code:
def WriteToMidi(bufferone):
   midi[0].data.dataTwo = bufferone

if keyboard.getPressed(Key.A):   
   WriteToMidi(126)

if keyboard.getPressed(Key.D):   
   WriteToMidi(1)


Again no response from my MIDI device unfortunately (with either the long or the short script). Please review the code above - is it even viable?

Maybe the values are just updated in FreePIE internally but not actually written to the device when assigning a value like midi[0].data.dataTwo = int ?


Sat Oct 10, 2015 12:11 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
I do not own a midi device myself so cant test, i get tones from the built in midi in windows when I use your code.
Here is the API we use, maybe you can get some answers there?

https://midinet.codeplex.com/

_________________
FreePIE
My blog


Sun Oct 11, 2015 7:56 am
Profile
One Eyed Hopeful

Joined: Sun Apr 03, 2016 8:18 am
Posts: 11
Reply with quote
Well, here is my script that worked for me with the custom FreePie version from this thread. The code is changed from one of the samples posted earlier.
Code:
def sendCC(cc, strength):
   midi[1].data.status = MidiStatus.Control
   midi[1].data.dataOne = cc
   midi[1].data.dataTwo = strength

if starting:
   footswitchDown = False

if keyboard.getKeyDown(Key.F13) != footswitchDown:
   footswitchDown = not footswitchDown
   if footswitchDown:
      sendCC(36, 127)
   else:
      sendCC(36, 0)


Is there a way to receive the names of the midi devices? I'd like to avoid using a static device index in case windows decides to change the order.


Sun Apr 03, 2016 9:23 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
Cool and your device receives the data?
I can see if the midi device supports names instead of indexes

edit: Btw, keyboard.getKeyDown(Key.F13) != footswitchDown can be replaced with keyboard.getPressed(Key.F13) (I think :D)

edit: See if you can access the device with name now (Do not forget to unblock the dll)

Code:
midi["my name"]


You do not have the required permissions to view the files attached to this post.

_________________
FreePIE
My blog


Mon Apr 04, 2016 1:03 am
Profile
One Eyed Hopeful

Joined: Sun Apr 03, 2016 8:18 am
Posts: 11
Reply with quote
Great, thank you.
I tried with getPressed, however it only seems to fire when the key is pressed down, but not on release. Therefore i manually implemented it to fire one time on key press and on release.

Yes. I used that code for several hours in 'production' and it worked just fine. All messages i tried to send were correctly received by the midi device.
I am not sure about the midi[0].data.channel = 0 line. It seems to generate a 'zero' note or control message (do not remember which) as well. I am not sure if it is supposed to do that. It wasn't necessary to use that command anyway. With or without that line all messages seems to be received on channel 1 of the midi device.

I will try your updated version with the name feature later today.


Mon Apr 04, 2016 5:53 am
Profile
One Eyed Hopeful

Joined: Sun Apr 03, 2016 8:18 am
Posts: 11
Reply with quote
I have tested your updated DLL. I have no luck yet using the named assignment.
When i run the script with named assignment, in the Console the midi device name appears (some debug output?). If i enter a non existing device name in the brackets, i get an error (translated: sequence has no matching element). So obviously FreePie finds the correct midi device, but assignment isn't working for some reason.


Mon Apr 04, 2016 2:11 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
ok so it finds the correct device but (debug output) but it does not work? hmm will have to check the code and report back

_________________
FreePIE
My blog


Mon Apr 04, 2016 3:03 pm
Profile
One Eyed Hopeful

Joined: Sun Apr 03, 2016 8:18 am
Posts: 11
Reply with quote
yes. It still works with midi[1] for me. However using the device name, no midi message is received by the device.


Mon Apr 04, 2016 3:09 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
and the name you give matches up with the debug?

_________________
FreePIE
My blog


Mon Apr 04, 2016 3:14 pm
Profile
One Eyed Hopeful

Joined: Sun Apr 03, 2016 8:18 am
Posts: 11
Reply with quote
Yes. It matches and is the same name as in the log.
If i even try to enter a non-existing device name, the script won't run with error "sequence has no matching element" (translated)


Mon Apr 04, 2016 3:20 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
Couldn't find any obvious errors with the code, added some more debugging. I do not lnow if I should use productid or index integer. Please check the debug output in conosle


You do not have the required permissions to view the files attached to this post.

_________________
FreePIE
My blog


Tue Apr 05, 2016 12:41 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
Think I found the problem, try this version


You do not have the required permissions to view the files attached to this post.

_________________
FreePIE
My blog


Tue Apr 05, 2016 1:17 am
Profile
One Eyed Hopeful

Joined: Sun Apr 03, 2016 8:18 am
Posts: 11
Reply with quote
Tried your newest one and it worked right away. Nice :)


Tue Apr 05, 2016 1:24 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
Cool, please try with both index and name

_________________
FreePIE
My blog


Tue Apr 05, 2016 1:59 am
Profile
One Eyed Hopeful

Joined: Sun Apr 03, 2016 8:18 am
Posts: 11
Reply with quote
I tried both with index and name. Both worked with no issues. All messages were correctly received by my MIDI device.

Also a deliberately wrong device name was correctly detected in the error log.


Tue Apr 05, 2016 2:22 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
Thanks, then I can push to master

_________________
FreePIE
My blog


Tue Apr 05, 2016 3:05 am
Profile
One Eyed Hopeful

Joined: Thu Sep 03, 2015 4:24 pm
Posts: 6
Reply with quote
Oh. You start a thread and turn your back to it for half a year and suddenly it works?
May I ask, can I use freepie to send midimessages to software? During my absence I've realized that I'd be happy enough if I could generate keypresses with my gamepad and send them through "vmpk -virtual midi piano keyboard". Servicing midi directly would of course be awesome since it would give possibilities for velocity too!


Tue May 03, 2016 2:21 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2164
Location: Stockholm, Sweden
Reply with quote
We just send output on a midi channel, I think it should work?

We use this library

https://midinet.codeplex.com/

_________________
FreePIE
My blog


Tue May 03, 2016 2:27 am
Profile
One Eyed Hopeful

Joined: Sun Apr 03, 2016 8:18 am
Posts: 11
Reply with quote
I have successfully used midi indexing by name for about 1 1/2 years now :) However it seems that this feature didn't make it in the newest FreePie release.


Thu Oct 26, 2017 2:58 pm
Profile
One Eyed Hopeful

Joined: Sun Apr 03, 2016 8:18 am
Posts: 11
Reply with quote
It's been another two years. Still running the old version. Is there an update to this feature making it into the main branch?


Thu Dec 05, 2019 3:22 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 34 posts ] 

Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by STSoftware.