Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OSC commands with numbers
#1
Trying to use Indy to send OSC (open sound control) messages to a Behringer X32 mixer. If the message is just text, it works fine. The issue is a message of the format "/ch/01/mix/fader ,f .3". The .3 needs to be sent as 4 bytes. What needs to go out is "3E 99 99 9A". What the idudpclient sends is "3E 3F 3F 3F". The same problem exists for .4 (3E CC CC CD vs. 3E 3F 3F 3F). Once you get to .5 and greater, things work again because the second byte is smaller. e.g. .5 = 3F 00 00 00 > 3F 00 00 00, .6 = 3F 19 99 9A > 3F 19 3F 3F).

I'm using Indy 10 and Delphi Rio. Here is the sending subroutine. I've commented out several different approaches, all of which give the same result.

procedure TCPForm1.OSCSendMsg;
var
  OutValueStr: String;
  I: Integer;
  J: Tbytes;
  B1: TIdbytes;
begin
  If Length(CommandStr) > 0 then begin
    OscCommandStr := PadStr(CommandStr);        //convert CommandStr to OSC string
    If TypeStr='' then OscCommandStr := OscCommandStr+','+#0+#0+#0;
    If Length(TypeStr) = 1 then begin
      If TypeStr='i' then Begin    // Parameter is an integer
              I := swapendian(IValue);              //change to big endian
              OscCommandStr := OscCommandStr+','+TypeStr+#0+#0+IntToCharStr(I);
              OutValueStr  := IntToStr(IValue);
            end;
      If TypeStr='f' then Begin    // Parameter is a float (real)
              I := swapendian(PInteger(@FValue)^);  //typecast & change to big endian
              //I := htonl(PInteger(@FValue)^);  //typecast & change to big endian
              //J := MakeOSCFloat(FValue);
              OscCommandStr := OscCommandStr+','+TypeStr+#0+#0+IntToCharStr(I);
              //OscCommandStr := OscCommandStr+','+TypeStr+#0+#0+char(J[0])+char(J[1])+char(J[2])+char(J[3]);
              OutValueStr  := FloatToStr(FValue);
            end;
    end;
  //IdUDPClient2.Send(OSCCommandStr,IndyTextEncoding_UTF8);
  //IdUDPClient2.Send(OSCCommandStr);
  B1 := toBytes(OSCCommandStr);
  IdUDPClient2.SendBuffer(B1);
  if loglevel>0 then logwrite('OSC= '+ hexstr(OSCCommandStr));
  Wait(UDPtime);
//  if loglevel>0 then logwrite('OSC '+ OSCCommandStr);
  end;
end;


function  TCPForm1.IntToCharStr(I : Integer) : String;
var
  CharStr : String;
  MyArray: array [0..3] of Byte;
  J: Integer;
begin
  For J :=0 to 3 do MyArray[J] := 0;
  Move(I, MyArray, 4);  //typeset conversion from integer to array of byte
  CharStr := '';
  For J :=0 to 3 do    //convert array of byte to string
    CharStr := CharStr+char(MyArray[J]);
  IntToCharStr := CharStr;
end;


Any insight you can share would be welcome. Thank you.
..Dave
Reply


Messages In This Thread
OSC commands with numbers - by davidbaxter - 11-01-2019, 03:04 PM
RE: OSC commands with numbers - by rlebeau - 11-01-2019, 10:37 PM
RE: OSC commands with numbers - by davidbaxter - 11-02-2019, 02:39 AM
RE: OSC commands with numbers - by rlebeau - 11-04-2019, 05:13 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)