예제 #1
0
  /**
   * Check if the OSC client is connected
   *
   * @return
   */
  public boolean isConnected() {

    if (oscClient != null) {
      return oscClient.isConnected();
    }

    return false;
  }
예제 #2
0
  /**
   * Method to disconnect from the present connected session. Ask Ardour to stop listening to our
   * observed tracks.
   */
  public void disconnect() {

    Integer[] args = new Integer[routes.size()];

    for (int i = 0; i < routes.size(); i++) {
      org.ardour.Track t = routes.get(i);
      args[i] = t.remoteId;
    }

    OSCMessage message = new OSCMessage("/routes/ignore", args);

    try {
      oscClient.send(message);
      oscClient.dispose();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
예제 #3
0
  /**
   * Send an OSC message over the OSC socket.
   *
   * @param messageUri
   */
  private void sendOSCMessage(String messageUri, Object[] args) {

    OSCMessage message;

    if (args == null || args.length == 0) {
      message = new OSCMessage(messageUri);
    } else {
      message = new OSCMessage(messageUri, args);
    }

    try {
      oscClient.send(message);
      // Log.d(TAG, "Send Message: " + message.getName());
    } catch (IOException e) {
      Log.d(TAG, "Could not send OSC message: " + messageUri);
      e.printStackTrace();
    }
  }
예제 #4
0
  /** Connect to the Ardour OSC server */
  public void connect() {

    try {

      Log.d(TAG, "Connetecting to Ardour");

      if (oscClient != null && oscClient.isConnected()) {
        disconnect();
      }

      oscClient = OSCClient.newUsing(OSCClient.UDP); // create UDP client with any free port number
      oscClient.setTarget(new InetSocketAddress(InetAddress.getByName(host), port));

      Log.d(TAG, "Starting connection...");

      oscClient
          .start(); // open channel and (in the case of TCP) connect, then start listening for
                    // replies

      Log.d(TAG, "Started. Starting listener");

      oscClient.addOSCListener(replyListener);

      Log.d(TAG, "Listening.");

      if (oscClient.isConnected()) {

        routes.clear();
        state = OscService.ROUTES_REQUESTED;

        System.out.println("OSC State: " + state);
        sendOSCMessage("/routes/list");
        // Object[] args = {1,2};
        // sendOSCMessage("/routes/gainabs", args);
      }

    } catch (UnknownHostException e) {
      Log.d(TAG, "Unknown host");
      e.printStackTrace();
    } catch (IOException e) {
      Log.d(TAG, "IO Exception");
      e.printStackTrace();
    }
  }