Exemple #1
0
int main(int argc, char** argv) {
  char * hostname = "localhost";
  if(argc > 1) {
    hostname = argv[1];
  }

  if(argc == 3) {
    lo_send(lo_address_new("18.224.0.163", ELMO_UDP_PORT), ELMO_COMMAND, "fff", 0.0f, 0.0f, 0.0f);
    lo_send(lo_address_new("18.224.0.168", ELMO_UDP_PORT), ELMO_COMMAND, "fff", 0.0f, 0.0f, 0.0f);
    return;
  }

  sqlights_light_initialize(hostname);

  initialize_elmo_light("18.224.0.163", "elmo0");
  initialize_elmo_light("18.224.0.168", "elmo1");

  struct timeval tv, tv2;
  gettimeofday(&tv, NULL);
  while(1) {
    while(0 == sqlights_lights_handle(0));
    gettimeofday(&tv2, NULL);
    if(tv2.tv_sec>tv.tv_sec || tv2.tv_usec-tv.tv_usec >= 33000) {
      update_lights();
      tv = tv2;
    }
  }
}
Exemple #2
0
void OSCPlugin::init()
{
    QSettings settings;
    QStringList defaultInputPorts;
    defaultInputPorts << "7770" << "8000" << "9000" << "9990";
    QStringList defaultOutputPorts;
    defaultOutputPorts << "7771" << "8001" << "9001" << "9991";

    for (int i = 0; i < QLCIOPLUGINS_UNIVERSES; i++)
    {
        QString key = QString("OSCplugin/Input%1/server_port").arg(i);
        QVariant value = settings.value(key);
        if (value.isValid() == true)
            m_nodes[i].m_port = value.toString();
        else
            m_nodes[i].m_port = defaultInputPorts.at(i);

        QString outAddrkey = QString("OSCplugin/Output%1/output_addr").arg(i);
        QVariant outValue = settings.value(outAddrkey);
        if (outValue.isValid() == true)
        {
            QString strAddr = outValue.toString();
            if (strAddr.contains(':'))
            {
                QStringList strList = strAddr.split(':');
                m_nodes[i].m_outAddr = lo_address_new(strList.at(0).toStdString().c_str(), strList.at(1).toStdString().c_str());
            }
            else
                m_nodes[i].m_outAddr = lo_address_new(strAddr.toStdString().c_str(), defaultInputPorts.at(i).toStdString().c_str());

            m_nodes[i].m_outAddrStr = strAddr;
        }
        else
        {
            m_nodes[i].m_outAddr = lo_address_new(NULL, defaultOutputPorts.at(i).toStdString().data());
            m_nodes[i].m_outAddrStr = QString();
        }

        // Initialize DMX values to 0
        for (int d = 0; d < 512; d++)
            m_nodes[i].m_dmxValues.append((char)0x00);

        m_nodes[i].m_serv_thread = NULL;

        /** Initialize the structure to be passed to the OSC callback */
        m_nodes[i].m_callbackInfo.input = i;
        m_nodes[i].m_callbackInfo.plugin = this;
    }
}
Exemple #3
0
int main(int argc, char *argv[])
{
    /* build a blob object from some data */
    lo_blob btest = lo_blob_new(sizeof(testdata), testdata);

    /* an address to send messages to. sometimes it is better to let the server
     * pick a port number for you by passing NULL as the last argument */
    lo_address t = lo_address_new(NULL, "7770");

    if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'q') {
      /* send a message with no arguments to the path /quit */
      lo_send(t, "/quit", NULL);
    } else {
      /* send a message to /foo/bar with two float arguments, report any
       * errors */
      if (lo_send(t, "/foo/bar", "ff", 0.12345678f, 23.0f) == -1) {
	printf("OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));
      }

      /* send a message to /a/b/c/d with a mixtrure of float and string
       * arguments */
      lo_send(t, "/a/b/c/d", "sfsff", "one", 0.12345678f, "three",
	      -0.00000023001f, 1.0);

      /* send a 'blob' object to /a/b/c/d */
      lo_send(t, "/a/b/c/d", "b", btest);

      /* send a jamin scene change instruction with a 32bit integer argument */
      lo_send(t, "/jamin/scene", "i", 2);
    }

    return 0;
}
Exemple #4
0
static int
info_prop_handler(lo_arg **argv, int argc, void *user_data,
                              info_reply_func_t cb) {
	sosc_state_t *state = user_data;
	const char *host = NULL;
	char port[6];
	lo_address *dst;

	if (argc == 2)
		host = &argv[0]->s;
	else
		host = lo_address_get_hostname(state->outgoing);

	portstr(port, argv[argc - 1]->i);

	if (!(dst = lo_address_new(host, port))) {
		fprintf(stderr, "sys_info_handler(): error in lo_address_new()");
		return 1;
	}

	cb(dst, state);
	lo_address_free(dst);

	return 0;
}
Exemple #5
0
static void *controller_thread(void *p)
{
    int last_scene = -1;
    lo_address address = lo_address_new(NULL, OSC_PORT);

    printf("THREAD\n");

    while (scene != EXITV) {
#ifdef DEBUG
        printf(". %d\n", scene);
#endif
        if (last_scene != scene) {
            last_scene = scene;
            if (last_scene > 0 && last_scene <= NUM_SCENES) {
                lo_send(address, OSC_PATH, "i", last_scene);
            }
        }
#ifdef DEBUG
        usleep(1000000);
#else
        usleep(10000);
#endif
    }

    lo_address_free(address);
#ifdef DEBUG
    printf("DONE\n");
#endif

    return NULL;
}
Exemple #6
0
int main(void) {

   // Prepare MIDI Interface Client/Port for writing MIDI data:
   MIDIClientRef midiclient;
   MIDIPortRef   midiin;
   OSStatus status;
   if (status = MIDIClientCreate(CFSTR("TeStInG"), NULL, NULL, &midiclient)) {
      printf("Error trying to create MIDI Client structure: %d\n", status);
      printf("%s\n", GetMacOSStatusErrorString(status));
      exit(status);
   }
   if (status = MIDIInputPortCreate(midiclient, CFSTR("InPuT"), myReadProc, 
         NULL, &midiin)) {
      printf("Error trying to create MIDI output port: %d\n", status);
      printf("%s\n", GetMacOSStatusErrorString(status));
      exit(status);
   }

   ItemCount nSrcs = MIDIGetNumberOfSources();
   ItemCount iSrc;
   for (iSrc=0; iSrc<nSrcs; iSrc++) {
      MIDIEndpointRef src = MIDIGetSource(iSrc);
      MIDIPortConnectSource(midiin, src, NULL);
   }
   t = lo_address_new(NULL, "7777");

   CFRunLoopRef runLoop;
   runLoop = CFRunLoopGetCurrent();
   CFRunLoopRun();

   return 0;
}
Exemple #7
0
int main()
{  
  // install signal handler
  if (signal(SIGINT, endall) == SIG_ERR)
    printf("[FAILED] to install SIGINT handle\n");

  // we're reading directly from serial
  ArduinoSerial arduino(ARDUINO_SERIAL);

  char buffer[BUFFER_S];
  memset(buffer, '\0', BUFFER_S);

  // our main loop
  while(1) 
  {
    // getLine() blocks until we get a newline or cr
    // and fills buffer with stuff
    arduino.getLine( buffer);
    printf("%s", buffer);
    
    // this message looks like "p\n"
    if( buffer[0] == 'p')
    {
      printf("got play\n");
      lo_address server = lo_address_new(SERVER, SERVER_PORT);
      lo_send(server, "/playtrigger", "");
      lo_address_free(server);;
    }
    // get rid of previous data
    memset(buffer, BUFFER_S, '\0');
  }
  return 0;
}
Exemple #8
0
void
OscCtrlServer::prop_cb(const std::string &internal_subscriber_name,
                       const std::string &quiddity_name,
                       const std::string &property_name,
                       const std::string &value,
                       void *user_data) {
  OscCtrlServer *context = static_cast<OscCtrlServer *>(user_data);

  auto it = context->osc_subscribers_.find(internal_subscriber_name);
  if (context->osc_subscribers_.end() == it)
    return;

  std::pair<std::string, std::string> address =
      context->osc_subscribers_[internal_subscriber_name];

  lo_address t = lo_address_new(address.first.c_str(),
                                address.second.c_str());

  gchar *subscriber_name =
      context->retrieve_subscriber_name(internal_subscriber_name.c_str());
  gchar *message = g_strdup_printf("/property/%s/%s/%s",
                                   subscriber_name,
                                   quiddity_name.c_str(),
                                   property_name.c_str());
  lo_send(t, message, "s", value.c_str());
  g_free(subscriber_name);
  g_free(message);
  lo_address_free(t);
}
Exemple #9
0
void SLBus::startSL()
{
	auto mainlog = spdlog::get( "main" );	
	sl_port_ = State::getInstance()->newOSCport();
	sl_target_ = lo_address_new( NULL, std::to_string( sl_port_ ).c_str() );
	std::string s_port_arg = "--osc-port=" + std::to_string( sl_port_ );
	char * port_arg = const_cast<char*>( s_port_arg.c_str() );
	std::string s_jack_client_arg = "--jack-name=sl-" + name_;
	char * jack_client_arg = const_cast<char*>( s_jack_client_arg.c_str() );
	char *arg[] = { "sooperlooper", "--discrete-io=no", "--loopcount=0",
		port_arg, jack_client_arg, NULL };
	//char *arg[] = { "sooperlooper", "--loopcount=0", port_arg, jack_client_arg, NULL };
	do {
		sl_pid_ = fork();
	} while ( ( sl_pid_ == -1 ) && ( errno == EAGAIN ) );

	switch ( sl_pid_ )
	{
	case -1:
		mainlog->error( "launching superlooper : Fork failed" );
		break;
	case 0:
		if ( execv( "/usr/bin/sooperlooper", arg ) == -1 )
		{
			mainlog->info( "launching superlooper : execv failed" );
			exit(EXIT_FAILURE);
		}
		break;
	default:
		mainlog->info( "launching superlooper pid {} on port {}", sl_pid_, sl_port_ );
		break;
	}
}
 RelayExpr() {
     // Create local relay
     relay  = new RmmApp(RELAY_PORT, "R0");
     client = new RmmApp(SOURCE_PORT, "CLIENT", MONITOR_PORT);
     
     relay->start(false);
     client->start(false);
     usleep(1e6);
     
     client->requestRegistration(SERVER_IP_VIRGINIA, RELAY_PORT);
     usleep(1e6);
     
     // ask the relay to redirect
     client->join(SERVER_IP, RELAY_PORT);
     
     usleep(1e6);
     
     lo_address target = lo_address_new(SERVER_IP, RELAY_PORT);
     lo_send_from(target, client->getserverptr(), LO_TT_IMMEDIATE, "/status", "");
     lo_address_free(target);
     
     client->setTestListener(this);
     client->changeTargetName(SERVER_NAME);
     client->addRelayConnection(SERVER_IP_VIRGINIA, RELAY_PORT);
     client->addRelayConnection(SERVER_IP_TX, RELAY_PORT);
     client->addRelayConnection(SERVER_IP_GA, RELAY_PORT);
     client->addRelayConnection(SERVER_IP_UK, RELAY_PORT);
     
     for (int a = 0; a < 1000; ++a) {
         usleep(1000);
         client->poll();
         relay->poll();
     }
 }
Exemple #11
0
mapper_receiver mapper_receiver_new(mapper_device device, const char *host,
                                    int port, const char *name, int default_scope)
{
    char str[16];
    mapper_receiver r = (mapper_receiver) calloc(1, sizeof(struct _mapper_link));
    sprintf(str, "%d", port);
    r->props.src_addr = lo_address_new(host, str);
    r->props.src_name = strdup(name);
    if (default_scope) {
        r->props.num_scopes = 1;
        r->props.scope_names = (char **) malloc(sizeof(char *));
        r->props.scope_names[0] = strdup(name);
        r->props.scope_hashes = (int *) malloc(sizeof(int));
        r->props.scope_hashes[0] = crc32(0L, (const Bytef *)name, strlen(name));;
    }
    else {
        r->props.num_scopes = 0;
    }
    r->props.extra = table_new();
    r->device = device;
    r->signals = 0;
    r->n_connections = 0;

    if (!r->props.src_addr) {
        mapper_receiver_free(r);
        return 0;
    }
    return r;
}
Exemple #12
0
int osc_send( const char *port, const char *msg, const char *format, ...)
{
	lo_address t = lo_address_new(NULL, port);
	lo_message message = lo_message_new();

	va_list args;
	va_start( args, format);

	while( *format != '\0')
	{
		switch( *format)
		{
			case 's': lo_message_add_string( message, va_arg( args, const char *)); break;
			case 'i': lo_message_add_int32( message, va_arg( args, int)); break;
			case 'f': lo_message_add_float( message, va_arg( args, double)); break;
		}

		++format;
	}

	va_end( args);
	

	if( !lo_send_message( t, msg, message))
	{
		printf("OSC error %d: %s\n", lo_address_errno(t),
		lo_address_errstr(t));
	}

	if( osc_log) osc_log_print( msg, message);
	lo_message_free( message);
	lo_address_free( t);

	return 0;
}
Exemple #13
0
int osc_init(struct twinterface *twinterface)
{
    osc = (struct osc *) malloc(sizeof(struct osc));
    osc->twinterface = twinterface;
    osc->ndeck = 0;
    
    /* start a new server on port 7770 */
    st = lo_server_thread_new("7771", error);

    /* add method that will match any path and args */
    lo_server_thread_add_method(st, "/xwax/ppm", "ibi", ppm_handler, NULL);
    
    lo_server_thread_add_method(st, "/xwax/ppm_end", "i", ppm_end_handler, NULL);

    /* add method that will match any path and args */
    lo_server_thread_add_method(st, "/xwax/track_load", "iissi", track_load_handler, NULL);

    /* add method that will match any path and args */
    lo_server_thread_add_method(st, "/xwax/position", "iff", pos_handler, NULL);

    /* add method that will match any path and args */
    lo_server_thread_add_method(st, "/xwax/scale", "i", scale_handler, NULL);    

    /* add method that will match any path and args */
    //lo_server_thread_add_method(st, NULL, NULL, generic_handler, NULL);
    
    lo_server_thread_start(st);
    
    /* Notify osc server that where at this address */
    lo_address t = lo_address_new(ADDRESS, "7770");
    lo_send(t, "/xwax/connect", "");
    printf("Sent connect message\n");

    return 0;
}
Exemple #14
0
static int notify(sosc_ipc_type_t type, sosc_device_info_t *dev)
{
	lo_address dst;
	char *path;
	int i;

	switch (type) {
	case SOSC_DEVICE_CONNECTION:
		path = "/serialosc/add";
		break;

	case SOSC_DEVICE_DISCONNECTION:
		path = "/serialosc/remove";
		break;

	default:
		return 1;
	}

	for (i = 0; i < notifications.count; i++) {
		if (!(dst = lo_address_new(
		            notifications.endpoints[i].host,
		            notifications.endpoints[i].port))) {
			fprintf(stderr, "notify(): couldn't allocate lo_address\n");
			continue;
		}

		lo_send_from(dst, srv, LO_TT_IMMEDIATE, path, "ssi",
		             dev->serial, dev->friendly, dev->port);

		lo_address_free(dst);
	}

	return 0;
}
Exemple #15
0
struct zyncoder_st *setup_zyncoder(uint8_t i, uint8_t pin_a, uint8_t pin_b, uint8_t midi_chan, uint8_t midi_ctrl, char *osc_path, unsigned int value, unsigned int max_value, unsigned int step) {
	if (i > MAX_NUM_ZYNCODERS) {
		printf("Zyncoder: Maximum number of zyncoders exceded: %d\n", MAX_NUM_ZYNCODERS);
		return NULL;
	}

	struct zyncoder_st *zyncoder = zyncoders + i;
	if (midi_chan>15) midi_chan=0;
	if (midi_ctrl>127) midi_ctrl=1;
	if (value>max_value) value=max_value;
	zyncoder->midi_chan = midi_chan;
	zyncoder->midi_ctrl = midi_ctrl;

	//printf("OSC PATH: %s\n",osc_path);
	if (osc_path) {
		char *osc_port_str=strtok(osc_path,":");
		zyncoder->osc_port=atoi(osc_port_str);
		if (zyncoder->osc_port>0) {
			zyncoder->osc_lo_addr=lo_address_new(NULL,osc_port_str);
			strcpy(zyncoder->osc_path,strtok(NULL,":"));
		}
		else zyncoder->osc_path[0]=0;
	} else zyncoder->osc_path[0]=0;

	zyncoder->step = step;
	if (step>0) {
		zyncoder->value = value;
		zyncoder->subvalue = 0;
		zyncoder->max_value = max_value;
	} else {
		zyncoder->value = value;
		zyncoder->subvalue = ZYNCODER_TICKS_PER_RETENT*value;
		zyncoder->max_value = ZYNCODER_TICKS_PER_RETENT*max_value;
	}

	if (zyncoder->enabled==0 || zyncoder->pin_a!=pin_a || zyncoder->pin_b!=pin_b) {
		zyncoder->enabled = 1;
		zyncoder->pin_a = pin_a;
		zyncoder->pin_b = pin_b;
		zyncoder->last_encoded = 0;
		zyncoder->tsus = 0;

		if (zyncoder->pin_a!=zyncoder->pin_b) {
			pinMode(pin_a, INPUT);
			pinMode(pin_b, INPUT);
			pullUpDnControl(pin_a, PUD_UP);
			pullUpDnControl(pin_b, PUD_UP);
#ifndef MCP23017_ENCODERS
			wiringPiISR(pin_a,INT_EDGE_BOTH, update_zyncoder_funcs[i]);
			wiringPiISR(pin_b,INT_EDGE_BOTH, update_zyncoder_funcs[i]);
#else
			// this is a bit brute force, but update all the banks
			mcp23017_bank_ISR(0);
			mcp23017_bank_ISR(1);
#endif
		}
	}

	return zyncoder;
}
Exemple #16
0
int main(int argc,char *argv[]) {
	srand(time(NULL));

	int quit = 0;
	int seed = rand() % 255;

	lo_address client = lo_address_new("localhost","9999");
	lo_server_thread server = lo_server_thread_new("9998",err_callback);
	lo_server_thread_add_method(server,"/client/quit","",quit_callback,(void*)&quit);
	lo_server_thread_add_method(server,NULL,NULL,all_callback,NULL);

	printf("starting osc server at %s with seed %d\n",lo_server_thread_get_url(server),seed);
	lo_server_thread_start(server);

	int k = 0;
	while (!quit) {
		if (lo_send(client,"/client/test","ii",seed,k++) < 0) fprintf(stderr,"osc client error: %s\n",lo_address_errstr(client));
		sleep(1);
	}

	printf("stopping osc server\n");
	lo_server_thread_stop(server);

	lo_server_thread_free(server);
	lo_address_free(client);
	return 0;
}
Exemple #17
0
static int osc_send_set(CSOUND *csound, OSCSEND *p)
{
    char port[8];
    char *pp = port;
    char *hh;
    //unsigned int i;

    /* with too many args, XINCODE may not work correctly */
    if (UNLIKELY(p->INOCOUNT > 31))
      return csound->InitError(csound, Str("Too many arguments to OSCsend"));
    /* a-rate arguments are not allowed */
    /* for (i = 0; i < p->INOCOUNT-5; i++) { */
    /*   if (strcmp("a", csound->GetTypeForArg(p->arg[i])->varTypeName) == 0) { */
    /*     return csound->InitError(csound, Str("No a-rate arguments allowed")); */
    /*   } */
    /* } */

    if (*p->port<0)
      pp = NULL;
    else
      snprintf(port, 8, "%d", (int) MYFLT2LRND(*p->port));
    hh = (char*) p->host->data;
    if (*hh=='\0') hh = NULL;
    p->addr = lo_address_new(hh, pp);
    p->cnt = 0;
    p->last = 0;
    csound->RegisterDeinitCallback(csound, p,
                                   (int (*)(CSOUND *, void *)) oscsend_deinit);
    return OK;
}
Exemple #18
0
static int osc_send_set(CSOUND *csound, OSCSEND *p)
{
    char port[8];
    char *pp = port;
    char *hh;

    /* with too many args, XINCODE may not work correctly */
    if (UNLIKELY(p->INOCOUNT > 31))
      return csound->InitError(csound, Str("Too many arguments to OSCsend"));
    /* a-rate arguments are not allowed */
    if (UNLIKELY(p->XINCODE))
      return csound->InitError(csound, Str("No a-rate arguments allowed"));

    if (*p->port<0)
      pp = NULL;
    else
      snprintf(port, 8, "%d", (int) MYFLT2LRND(*p->port));
    hh = (char*) p->host->data;
    if (*hh=='\0') hh = NULL;
    p->addr = lo_address_new(hh, pp);
    p->cnt = 0;
    p->last = 0;
    csound->RegisterDeinitCallback(csound, p,
                                   (int (*)(CSOUND *, void *)) oscsend_deinit);
    return OK;
}
Exemple #19
0
// Register server as available
void* DSPServer::registration(void* arg) 
{
    DSPServer* serv = (DSPServer*)arg;
    
    char host_name[256];
    gethostname(host_name, sizeof(host_name));
    
#ifdef LLVM_DSP_FACTORY
    string target = getDSPMachineTarget();
#else
    string target = "Interpreter";
#endif
    
    stringstream name_service;
    name_service << searchIP() << ":" << serv->fPort << ":" << host_name << ":" << target;
    lo_address adress = lo_address_new("224.0.0.1", "7770");
    
    while (true) {
    #ifdef WIN32
        Sleep(1);
    #else
        usleep(1000000);
    #endif
        pthread_testcancel();
        string res = name_service.str();
        lo_send(adress, "/faustcompiler", "is", getpid(), res.c_str());
    }
    
    pthread_exit(NULL);
}
Exemple #20
0
int main (int argc, char * argv[]) {
  lo_server_thread st;        // server to receive messages from
  lo_address addr;            // address to send messages to
  static struct filter ftr;   // stores data to be passed to handler
  int i, j;                   // index variables

  /* Set up the filter signature.  The signature helps us verify that things 
   * that we think are filters are actually filters. */
  srandom ((unsigned int) time (NULL));
  FILTER_SIGNATURE = random ();

  /* check for read port and write port */
  if (argc < 3)
    {
      printf ("- Missing Argument -\nUsage: oschand read_port write_port\n");
      exit (1);
    } // if

  /* start a new server and set up write port */
  st = lo_server_thread_new (argv[1], &error);
  addr = lo_address_new ("127.0.0.1", argv[2]);

  /* setup filter structure to be passed to joint handler */
  ftr.signature = FILTER_SIGNATURE;
  ftr.addr = addr;
  ftr.num_joints = argc - 3;
  ftr.joints = (char **) malloc (sizeof (char *) * ftr.num_joints);

  for (j = 0, i = 3; j < ftr.num_joints; j++, i++)
    ftr.joints[j] = argv[i];

  /* add method that will handle joints */
  lo_server_thread_add_method (st, "/joint", "sifff", joint_handler, &ftr);

  /* add method that will match the path /quit with no args */
  lo_server_thread_add_method (st, "/quit", "", quit_handler, NULL);

  lo_server_thread_start (st);

  /* wait for messages */
  while (!done)
    {
#ifdef WIN32
      Sleep (1);
#else
      usleep (1000);
#endif
    } // while

  lo_server_thread_free (st);
  lo_address_free (addr);

  return 0;
} // main
Exemple #21
0
int osc_send_vector( const char *port, const char *msg)
{
	lo_address t = lo_address_new(NULL, port);

	if( !lo_send( t, "/a/b/c" , "fff" , 10.0f, 10.0f, 10.0f))
	{
		printf("OSC error %d: %s\n", lo_address_errno(t),
		lo_address_errstr(t));
	}

	return 0;
}
Exemple #22
0
int osc_send_quit( const char *port)
{
	lo_address t = lo_address_new(NULL, port);

	if( !lo_send( t, "/quit" , ""))
	{
		printf("OSC error %d: %s\n", lo_address_errno(t),
		lo_address_errstr(t));
	}

	return 0;
}
Exemple #23
0
int osc_send_position(int d, const float position)
{
    lo_address t = lo_address_new(ADDRESS, "7770");
        
    if (lo_send(t, "/xwax/position", "if", d, position) == -1) {
#ifdef __ANDROID__
    __android_log_print(ANDROID_LOG_DEBUG, "osc.c", "OSC error %d: %s\n", lo_address_errno(t),
        lo_address_errstr(t));
#endif
    }  
    
    return 1;
}
Exemple #24
0
void	*veejay_new_osc_sender( const char *addr, const char *port )
{
	oscclient_t *osc = (oscclient_t*) vj_malloc(sizeof(oscclient_t));
	memset(osc,0,sizeof(oscclient_t));
	osc->addr = lo_address_new( addr, port );

	osc->addr_str = strdup( addr );
	osc->port_str = port ? strdup( port ) : NULL;
	veejay_msg(0,"New OSC sender Host %s, Port %s",
			osc->addr_str, osc->port_str );

	return (void*) osc;
}
Exemple #25
0
int main(int argc, char *argv[])
{
    /* an address to send messages to. sometimes it is better to let the server
     * pick a port number for you by passing NULL as the last argument */
    lo_address t = lo_address_new(NULL, "7770");
    char mode = 't';
    float x = 0.0;
    float delta = 0.1;
    int n = 0; /* slider number */

    if (argc == 2) {
        mode = argv[1][0];
        if (mode == '?' || mode == 'h' ||
                (mode != 'i' && mode != 't')) {
            printf("usage: test-client [?hti]\n");
            printf("    default (t) is triangle, (i)nteractive sends msg after each return\n");
            exit(1);
        }
    }

    printf("lo_address_new done\n");

    /* send messages to /slider with two arguments, report any
     * errors */
    while (1) {
        if (lo_send(t, "/slider", "if", n, x) == -1) {
            printf("OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));
            break;
        } else {
            printf("/slider %d %g\n", n, x);
        }
        x = x + delta;
        if (x > 1.0 - delta * 0.5) {
            x = 1.0;
            delta = -delta;
        } else if (x < -delta * 0.5) {
            x = 0.0;
            delta = -delta;
        }
        if (mode == 'i') {
            while (getchar() != '\n') ;
        } else {
            usleep(100000);
        }
    }

    printf("done calling lo_send\n");

    return 0;
}
Exemple #26
0
int main(int argc, char *argv[])
{
	lo_address t = lo_address_new(NULL, "7770");
	sleep(5);
	smallIncr = (TWOPI)/360.0;
	for (theta = TWOPI ; theta >= 0.0 ; theta = theta-smallIncr) {
		int jsVal = (int) round(sin(theta)*32767.0) ;
		if (lo_send(t, path, types, jsNum , jsAxis , jsVal) == -1) {
			printf("OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));
		}
		usleep(40000);
		printf("path=%s , types=%s argslist = %d %d %d\n",path , types , jsNum , jsAxis , jsVal) ;
	}
}
Exemple #27
0
foreign_t mk_address(term_t host, term_t port, term_t addr) { 
	char *h, *p;

	if (PL_get_chars(host, &h, CVT_ATOM | CVT_STRING)) {
		if (PL_get_chars(port, &p, CVT_INTEGER)) {
			lo_address a = lo_address_new(h,p);
			return unify_addr(addr,a);
		} else {
			return type_error(port,"integer");
		}
	} else {
		return type_error(host,"atom");
	}
}
void
AudioPluginOSCGUI::setGUIUrl(QString url)
{
    if (m_address)
        lo_address_free(m_address);

    QByteArray burl = url.toUtf8();

    char *host = lo_url_get_hostname(burl.data());
    char *port = lo_url_get_port(burl.data());
    m_address = lo_address_new(host, port);
    free(host);
    free(port);
    m_basePath = lo_url_get_path(burl.data());
}
Exemple #29
0
int main()
{  
  // install signal handler
  if (signal(SIGINT, endall) == SIG_ERR)
    printf("[FAILED] to install SIGINT handle\n");

  // we're reading directly from serial
  ArduinoSerial arduino(ARDUINO_SERIAL);

  char buffer[BUFFER_S];
  memset(buffer, '\0', BUFFER_S);

  // our main loop
  while(1) 
  {
    int velocity = -1 , id = -1;
    
    // getLine() blocks until we get a newline or cr
    // and fills buffer with stuff
    int size = arduino.getLine( buffer);
    printf("%s", buffer);
    
    // our input looks like "i 123 v 4567"
    // so that id would be 123 and velocity would be 456
    sscanf(buffer, "i %d v %d\n", &id, &velocity);
    if( id != -1 && velocity != -1)
    {
      // show what we got
      printf( "s = %d, id = %d, vel = %d\n", size, id, velocity);

      int min = 0;
      int max = NUM_VIDEOS;
      int newint = rand()%(max-min + 1) + min; 

      lo_address server = lo_address_new(SERVER, SERVER_PORT);
      lo_send(server, "/stopall", "i", velocity);
      //      lo_send(server, "/playloop", "i", id);
      /* now we're sending a random video number because we have more videos than buttons, plus dave wanted it to be random anyway */
      lo_send(server, "/playloop", "i", newint);
      lo_address_free(server);
    }
    // get rid of previous data
    memset(buffer, BUFFER_S, '\0');
  }
  return 0;
}
Exemple #30
0
int initialize_elmo_light(char * address, char * name) {
  struct elmo_light_s * handle = elmo_lights+next_handle;
  handle->addr = lo_address_new(address, ELMO_UDP_PORT);
  handle->light = sqlights_add_light(name, SQ_COLORED);
  handle->light->extra_data = (void*)next_handle;
  handle->r = 0.8;
  handle->g = 0.0;
  handle->b = 0.2;
  handle->i = 0.0;

  handle->light->onoff_handler = &elmo_onoff_handler;
  handle->light->brightness_handler = &elmo_brightness_handler;
  handle->light->rgb_handler = &elmo_rgb_handler;
  handle->light->hsi_handler = &elmo_hsi_handler;

  return next_handle++;
}