Hi, I've been looking for any way how to translate midi to osc and then to a network and found out that MidiFire has OSC Exchanger. Just after I bought it I realized it does only osc to midi. Do anyone has any idea how can I do this in iOS world, please? Thanks for any help!
Hi Nic, I'm so glad it's possible with MidiFire, you made my day! However, from the example you sent me I'm not really sure how can I achieve this: For example, if I want to send MIDI CC 10 channel 5 from the external controller to OSC with address "/mix/monitor/0/matrix/fader" on 192.168.1.1:1234 ? Thank you so much for your help !!!
Hello! I have been really enjoying midifire so far. I am also working on midi to osc atm. I have a working script but it stops sending udp messages after a while ... usually in less than a minute. I first assumed that it was trying to send too fast as I'm tracking midi CC changes. So I implemented a delay that makes it so it only sends a udp message every so often instead of for every midi message. It still stops sending after a while though. It still seems to be receiving midi data and the blocks flash and numbers on screen update as expected. However if, having reached this state, I then open the Scenes menu it will say no files instead of listing my saved scenes. If I force close and restart the midifire it works again for a while.
Looking at my code I have another question too ... in one example in the university you show what appears to be the alias host1 being used to represent an ip address but you do not show an example of initializing that alias. I tried what seemed the obvious way to me here but it throws an error.
Anyway ... here's my code:
#Alias 192.168.86.40 host Alias $8888 port Alias $50 delay Alias L00 data Alias L00 group Alias L01 public Alias L02 page Alias L03 mode Alias L04 actives Alias L05 hueOffset Alias L06 saturation Alias L07 brightness Alias L08 speed Alias L09 density Alias L0A lfo1 Alias L0B lfo2 Alias L0C lfo3 Alias L0D lfo4 Alias L10 changed Alias L11 lastosc Alias L12 lastmidi Alias T00 osctimer
If LOAD Ass data = 00 00 00 06 0A 00 00 00 00 00 00 00 00 00 Ass changed = 00 50 osctimer End
Ass lastmidi = osctimer Mat lastosc = lastosc + lastmidi
If M00 == BF 7F 7F If lastmidi < delay Block Exit End End
If M00 == B0 01 Set LB0 M02 Ass hueOffset = M02 Ass changed = 1 End
If M00 == B0 03 Set LB1 M02 Ass brightness = M02 Ass changed = 1 End
If changed == 1 If lastosc > delay Ass changed = 00 00 Ass W000 = 2F 70 61 74 74 65 72 6E 00 00 00 00 2C 69 69 69 Ass W010 = 69 69 69 69 69 69 69 69 69 69 69 00 00 00 00 group Ass W020 = 00 00 00 public 00 00 00 page 00 00 00 mode 00 00 00 actives Ass W030 = 00 00 00 hueOffset 00 00 00 saturation 00 00 00 brightness 00 00 00 speed Ass W040 = 00 00 00 density 00 00 00 lfo1 00 00 00 lfo2 00 00 00 lfo3 Ass W050 = 00 00 00 lfo4
Send M00 M01 M02 Send $0 $84 +U192.168.86.30:port Else If M0 != BF 7F 7F Send BF 7F 7F Send BF 7F 7F +Ddelay +inject End End End
Second question first. I imagine I was thinking that host would be a define (like an alias but different):
if load define host 192.168.1.1 end send $0 $84 +Uhost:port
Now, the first issue/question is more troublesome!
I have not encountered this before (or have had that reported) but it suspiciously sounds like MidiFire is so busy dealing with events from MIDI messages that it gets bogged down to the point of more or less crashing. It's hard to know unless I can reproduce exactly, but it sounds like there could be an event loop - either externally via the interfaces or your script is injecting an event that cause the script to eject an event in an infinite loop, which will pretty well kill the app.
I didn't look at your code closely, and I can see you're injecting albeit with a test that the trigger event is not re-triggering the inject.
My suggestion is to shove an Event Monitor on the canvas before the StreamByter and see if it gets swamped.
On the other hand it is possible there is a bug somewhere in MidiFire, but I would rather eliminate infinite event loops in your setup before I start looking into that.
Yeah there’s not THAT much data ... it is just a single midi instrument. The data Im watching is basically just a mod wheel. Also the problem was happening before i started using inject. The inject is to help with the delay loop ... if no more messages come in it still needs to send out the last recieved data. I have also used an event monitor on both ends and the inject does not seem to be triggering more than it should.
I have since tried out just streambyter in an audiobus host without midifire and that seems to last longer but still exhibits similar systems eventually ... including the save open interface being empty.
Hmmm, on testing, the define statement does not seem to work for the host.
Here is a simplified version of the code without the delay and a couple comments:
If LOAD #Define host 192.168.86.30 Alias $8888 port
# OSC Packet Data Alias L00 data Alias L00 group Alias L01 public Alias L02 page Alias L03 mode Alias L04 actives Alias L05 hueOffset Alias L06 saturation Alias L07 brightness Alias L08 speed Alias L09 density Alias L0A lfo1 Alias L0B lfo2 Alias L0C lfo3 Alias L0D lfo4 Alias L10 changed Ass data = 00 00 00 06 3E 00 7F 7F 7F 7F 00 00 00 00 Ass changed = 00 End
# Mod wheel packet ... apply to Q1-Q5 as selected by Q0 If M00 == B0 01 #Mat I0 = M01 + 4 Mat I0 = Q0 + 4 Mat LI0 = M02 * 2 Set LB0 LI0 Ass changed = 1 End
# Send OSC packet If changed == 1 Ass changed = 00