I have a little with sending the correct OSC data to the Sequencer-Prog "Reaper" via UDP.
Here's the Code :
Code: Select all
EnableExplicit
Macro CALC_ALIGNMENT(x)
(x+4) & $fffc
EndMacro
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", 0)
End
EndIf
Declare.i BuildMessage(adr.s,typeTag.s,val.f)
Enumeration
#MAINWIN
#BUTTON_SEND
EndEnumeration
#REAPER_IP = "192.168.178.21"; ->Change to your'e IP
#REAPER_PORT = 8000 ; ->Change to your'e PORT
Global winEvent.i = 0
Global ReaperID = 0
Global *message = 0
ReaperID = OpenNetworkConnection(#REAPER_IP, #REAPER_PORT, #PB_Network_UDP)
If ReaperID = 0
Debug "Unable to connect to Reaper"
End
EndIf
If OpenWindow(#MAINWIN,0,0,100,25,"OSC Test") = #False
Debug "Couldn't create Main Window!"
End
EndIf
ButtonGadget(#BUTTON_SEND,0,0,100,25,"Send to Reaper")
Repeat
winEvent = WindowEvent()
Select winEvent
Case #PB_Event_Gadget
Select EventGadget()
Case #BUTTON_SEND
If *message = 0
*message = BuildMessage("/track/1/fx/1/fxparam/1/value",",f",8.01)
EndIf
If *message <> 0
SendNetworkData(ReaperID, *message,1024)
FreeMemory(*message)
*message = 0
EndIf
EndSelect
EndSelect
Delay(1)
Until winEvent = #PB_Event_CloseWindow
CloseNetworkConnection(ReaperID)
End
Procedure.i BuildMessage(adr.s,typeTag.s,val.f)
Protected *message = AllocateMemory(256)
Protected adrAlignment.l = CALC_ALIGNMENT(Len(adr))
CopyMemory(@adr,*message,StringByteLength(adr))
CopyMemory(@typeTag,*message+adrAlignment,2)
;Make BigEndian Float
Protected tmpFloat.f = 0
PokeB(@tmpFloat+0,PeekB(@val+3))
PokeB(@tmpFloat+1,PeekB(@val+2))
PokeB(@tmpFloat+2,PeekB(@val+1))
PokeB(@tmpFloat+3,PeekB(@val+0))
CopyMemory(@tmpFloat,*message+adrAlignment+SizeOf(long),4)
ProcedureReturn *message
EndProcedure
Here is a better Description about what OSC is http://en.wikipedia.org/wiki/Open_Sound_Control
My Problem is, that the Message that I'm sending to Reaper should look like
"/track/1/fx/1/fxparam/1/value ,f 8.01"
but Reaper recieves
"/track/1/fx/1/fxparam/1/value [f] 8.01"
.
I know it's a very specific question but hopefully anyone has an anwser for my Question.
mfg Christian