Page 1 of 1
How to get midi working?
Posted: Thu Sep 03, 2015 4:30 pm
by andersbrontosaurus
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
Re: How to get midi working?
Posted: Fri Sep 04, 2015 11:05 am
by CyberVillain
You can check this thread for some samples
http://www.mtbs3d.com/phpBB/viewtopic.php?f=139&t=20537
edit: aha, we only support reading. Can look into writing too
Re: How to get midi working?
Posted: Fri Sep 04, 2015 1:17 pm
by CyberVillain
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: Select all
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: Select all
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
Re: How to get midi working?
Posted: Fri Sep 04, 2015 4:06 pm
by andersbrontosaurus
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...
Re: How to get midi working?
Posted: Sat Sep 05, 2015 3:38 am
by CyberVillain
I gave you some pointers on the Swedish forum
Re: How to get midi working?
Posted: Fri Sep 18, 2015 3:12 pm
by andersbrontosaurus
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: Select all
//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
Re: How to get midi working?
Posted: Sat Sep 19, 2015 2:49 am
by CyberVillain
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
Re: How to get midi working?
Posted: Sat Sep 19, 2015 5:31 pm
by andersbrontosaurus
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.
Re: How to get midi working?
Posted: Sun Sep 20, 2015 4:53 am
by CyberVillain
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: Select all
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)
Re: How to get midi working?
Posted: Tue Sep 22, 2015 2:04 pm
by andersbrontosaurus
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.
Re: How to get midi working?
Posted: Thu Oct 01, 2015 4:13 am
by DrDim
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
)
Re: How to get midi working?
Posted: Fri Oct 09, 2015 10:16 pm
by DrDim
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: Select all
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
Re: How to get midi working?
Posted: Sat Oct 10, 2015 4:09 am
by CyberVillain
midi[0] means port zero and you use channel 0 is that correct for your device?
Re: How to get midi working?
Posted: Sat Oct 10, 2015 4:16 am
by CyberVillain
also, please try this version, did some minor changes, might help
Re: How to get midi working?
Posted: Sat Oct 10, 2015 12:11 pm
by DrDim
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: Select all
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:
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: Select all
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: Select all
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 ?
Re: How to get midi working?
Posted: Sun Oct 11, 2015 7:56 am
by CyberVillain
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/
Re: How to get midi working?
Posted: Sun Apr 03, 2016 9:23 am
by DOCa Cola
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: Select all
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.
Re: How to get midi working?
Posted: Mon Apr 04, 2016 1:03 am
by CyberVillain
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
)
edit: See if you can access the device with name now (Do not forget to unblock the dll)
Re: How to get midi working?
Posted: Mon Apr 04, 2016 5:53 am
by DOCa Cola
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.
Re: How to get midi working?
Posted: Mon Apr 04, 2016 2:11 pm
by DOCa Cola
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.
Re: How to get midi working?
Posted: Mon Apr 04, 2016 3:03 pm
by CyberVillain
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
Re: How to get midi working?
Posted: Mon Apr 04, 2016 3:09 pm
by DOCa Cola
yes. It still works with midi[1] for me. However using the device name, no midi message is received by the device.
Re: How to get midi working?
Posted: Mon Apr 04, 2016 3:14 pm
by CyberVillain
and the name you give matches up with the debug?
Re: How to get midi working?
Posted: Mon Apr 04, 2016 3:20 pm
by DOCa Cola
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)
Re: How to get midi working?
Posted: Tue Apr 05, 2016 12:41 am
by CyberVillain
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
Re: How to get midi working?
Posted: Tue Apr 05, 2016 1:17 am
by CyberVillain
Think I found the problem, try this version
Re: How to get midi working?
Posted: Tue Apr 05, 2016 1:24 am
by DOCa Cola
Tried your newest one and it worked right away. Nice
Re: How to get midi working?
Posted: Tue Apr 05, 2016 1:59 am
by CyberVillain
Cool, please try with both index and name
Re: How to get midi working?
Posted: Tue Apr 05, 2016 2:22 am
by DOCa Cola
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.
Re: How to get midi working?
Posted: Tue Apr 05, 2016 3:05 am
by CyberVillain
Thanks, then I can push to master
Re: How to get midi working?
Posted: Tue May 03, 2016 2:21 am
by andersbrontosaurus
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!
Re: How to get midi working?
Posted: Tue May 03, 2016 2:27 am
by CyberVillain
We just send output on a midi channel, I think it should work?
We use this library
https://midinet.codeplex.com/
Re: How to get midi working?
Posted: Thu Oct 26, 2017 2:58 pm
by DOCa Cola
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.
Re: How to get midi working?
Posted: Thu Dec 05, 2019 3:22 am
by DOCa Cola
It's been another two years. Still running the old version. Is there an update to this feature making it into the main branch?