OSC (OpenSoundControl) and PB

Just starting out? Need help? Post your questions and find answers here.
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: OSC (OpenSoundControl) and PB

Post by HeX0R »

Code: Select all

Structure _FLOAT_SWAPPER_
	StructureUnion
		b.b[4]
		f.f
	EndStructureUnion
EndStructure

*ba._FLOAT_SWAPPER_ = ?Stream
Swap *ba\b[0], *ba\b[3]
Swap *ba\b[1], *ba\b[2]
Debug *ba\f


DataSection
	Stream:
	Data.b $3D,  $B4,  $2D,  $0B
EndDataSection
Simo_na
Enthusiast
Enthusiast
Posts: 177
Joined: Sun Mar 03, 2013 9:01 am

Re: OSC (OpenSoundControl) and PB

Post by Simo_na »

Thank you HeX0R
it is correct in this syntax ?

Code: Select all

EnableExplicit

Structure myfloat
StructureUnion
b.b[4]
f.f
EndStructureUnion
EndStructure

Global Dim mydata.myfloat(4)
Global *ba.myfloat

mydata(0)\b[0]=$3D
mydata(0)\b[1]=$B4
mydata(0)\b[2]=$2D
mydata(0)\b[3]=$0B

*ba.myfloat = mydata(0)
Swap *ba\b[0], *ba\b[3]
Swap *ba\b[1], *ba\b[2]
Debug *ba\f

;DataSection
;   Stream:
;   Data.b $3D,  $B4,  $2D,  $0B
;EndDataSection
infratec
Always Here
Always Here
Posts: 7583
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: OSC (OpenSoundControl) and PB

Post by infratec »

My solution:

Code: Select all

Procedure.f GetBigEndianFloat(*Ptr.Byte)
  
  Protected Result.f, *Result.Byte, i.i
  
  *Result = @Result + 3
  
  For i = 0 To 3
    *Result\b = *Ptr\b
    *Result - 1
    *Ptr + 1
  Next i
  
  ProcedureReturn Result
  
EndProcedure


Debug GetBigEndianFloat(?Stream)


DataSection
   Stream:
   Data.b $3D,  $B4,  $2D,  $0B
EndDataSection
User avatar
Mijikai
Addict
Addict
Posts: 1517
Joined: Sun Sep 11, 2016 2:17 pm

Re: OSC (OpenSoundControl) and PB

Post by Mijikai »

Try this :)

Code: Select all

Procedure.f GetBigEndianFloat(*Pointer)
  Protected result.f
  !mov rax,[p.p_Pointer]
  !mov eax,dword[rax]
  !bswap eax
  !mov dword[p.v_result],eax
  ProcedureReturn result
EndProcedure

Debug GetBigEndianFloat(?dummy)

DataSection
  dummy:
  !db 0x3D, 0xB4, 0x2D, 0x0B
EndDataSection
infratec
Always Here
Always Here
Posts: 7583
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: OSC (OpenSoundControl) and PB

Post by infratec »

ThumpUp !!!
Simo_na
Enthusiast
Enthusiast
Posts: 177
Joined: Sun Mar 03, 2013 9:01 am

Re: OSC (OpenSoundControl) and PB

Post by Simo_na »

:shock:

Thank you
Simo_na
Enthusiast
Enthusiast
Posts: 177
Joined: Sun Mar 03, 2013 9:01 am

Re: OSC (OpenSoundControl) and PB

Post by Simo_na »

Hi

i want to send this osc compliant

/info~~~,~~~

when '~' is '00'

which in practice becomes

Size = BuildMessage(*message, "/info~~~","~~~")

In that case, the number of ~ characters accurately represent the number of Null bytes (or \0)
sent along with the command to respect the formatting imposed by the OSC protocol.

is possible to modifying the build procedure ??

Code: Select all

Procedure.i Build Message(*Buffer, adc.s, typeTag.s, val.f)


Thank you
User avatar
DannyWeijermans
User
User
Posts: 26
Joined: Thu Aug 25, 2022 10:10 pm
Contact:

Re: OSC (OpenSoundControl) and PB

Post by DannyWeijermans »

infratec wrote: Sat May 25, 2019 4:07 pm Use somethig like this after your SendNetwork stuff:

Code: Select all

Timeout = 100
*Buffer = AllocateMemory(2048, #PB_Memory_NoClear)
If *Buffer
  Repeat
    
    NetEv = NetworkClientEvent(Con)
    Select NetEv
      Case #PB_NetworkEvent_None
        Delay(10)
        Timeout - 1
      Case #PB_NetworkEvent_Data
        RcvLen = ReceiveNetworkData(Con, *Buffer, MemorySize(*Buffer))
        If RcvLen
          ShowMemoryViewer(*Buffer, RcvLen)
          Break
        EndIf
    EndSelect
    
  Until Timeout = 0
  FreeMemory(*Buffer)
EndIf
I'm testing this software in OSX:
NetEv always stays 0.
is there anything special/different for the 'Con' (connection) ?
Post Reply