oscpack

Sonic Pi のサーバと osc で通信したい。ruby では成功。

require 'osc-ruby'                                                                           

include OSC                                                                                                     client = OSC::Client.new('localhost', 4557)   

message = OSC::Message.new('/run-code', 'sonic-pi-cli', 'play :C4') client.send(message);    

 

C++python では失敗。

import time 

from pythonosc import osc_message_builder

from pythonosc import udp_client

client = udp_client.SimpleUDPClient("localhost", 4557)        

msg = osc_message_builder.OscMessageBuilder(address="/run-code")      msg.add_arg("PYTHON")

msg = msg.build()

client.send_message(msg,"play(C4)" 

 

#include "osc/OscOutboundPacketStream.h"     

#include "ip/UdpSocket.h" 

#define ADDRESS "127.0.0.1"                                                                  

#define PORT 4557                                                                            

#define OUTPUT_BUFFER_SIZE 1024                                                              

int main(int argc, char* argv[])                                                             

{                                                                                            

       (void) argc; // suppress unused parameter warnings 

       (void) argv; // suppress unused parameter warnings        

     UdpTransmitSocket transmitSocket( IpEndpointName( ADDRESS, PORT ) );                     

     char buffer[OUTPUT_BUFFER_SIZE]; 

     osc::OutboundPacketStream p( buffer, OUTPUT_BUFFER_SIZE ); 

     p << osc::BeginBundleImmediate 

     << osc::BeginMessage( "/run-code" )

     << "sonic-pi-cli" <<  "play :C4" << osc::EndMessage

     << osc::EndBundle; 

     transmitSocket.Send( p.Data(), p.Size() );

}

Sonic Pi のサーバ側でOSC通信のログをみて比較したい。