Package

de.sciss

osc

Permalink

package osc

Visibility
  1. Public
  2. All

Type Members

  1. final case class Bundle(timetag: Timetag, packets: Packet*) extends Packet with LinearSeq[Packet] with Product with Serializable

    Permalink
  2. trait Channel extends ConfigLike with java.nio.channels.Channel

    Permalink
  3. trait Client extends Bidi with DirectedInput with DirectedOutput

    Permalink
  4. sealed trait Dump extends AnyRef

    Permalink
  5. class Message extends Packet with LinearSeq[Any]

    Permalink
  6. sealed trait Packet extends AnyRef

    Permalink
  7. trait PacketCodec extends AnyRef

    Permalink
  8. trait Receiver extends Input

    Permalink
  9. final case class Timetag(raw: Long) extends Product with Serializable

    Permalink
  10. trait Transmitter extends Output

    Permalink
  11. sealed trait Transport extends AnyRef

    Permalink

Value Members

  1. object Bundle extends Serializable

    Permalink
  2. object Channel

    Permalink
  3. object Client

    Permalink

    This class groups together a transmitter and receiver, allowing bidirectional OSC communication from the perspective of a client.

    This class groups together a transmitter and receiver, allowing bidirectional OSC communication from the perspective of a client. It simplifies the need to use several objects by uniting their functionality. </P><P> In the following example, a client for UDP to SuperCollider server (scsynth) on the local machine is created. The client starts a synth by sending a /s_new message, and stops the synth by sending a delayed a /n_set message. It waits for the synth to die which is recognized by an incoming /n_end message from scsynth after we've registered using a /notify command.

        final Object        sync = new Object();
        final Client     c;
        final Bundle     bndl1, bndl2;
        final Integer       nodeID;
    
        try {
            c = Client.newUsing( Client.UDP );    // create UDP client with any free port number
            c.setTarget( new InetSocketAddress( "127.0.0.1", 57110 ));  // talk to scsynth on the same machine
            c.start();  // open channel and (in the case of TCP) connect, then start listening for replies
        }
        catch( IOException e1 ) {
            e1.printStackTrace();
            return;
        }
    
        // register a listener for incoming osc messages
        c.addOSCListener( new OSCListener() {
            public void messageReceived( Message m, SocketAddress addr, long time )
            {
                // if we get the /n_end message, wake up the main thread
                // ; note: we should better also check for the node ID to make sure
                // the message corresponds to our synth
                if( m.getName().equals( "/n_end" )) {
                    synchronized( sync ) {
                        sync.notifyAll();
                    }
                }
            }
        });
        // let's see what's going out and coming in
        c.dumpOSC( Channel.kDumpBoth, Console.err );
    
        try {
            // the /notify message tells scsynth to send info messages back to us
            c.send( new Message( "/notify", new Object[] { new Integer( 1 )}));
            // two bundles, one immediately (with 50ms delay), the other in 1.5 seconds
            bndl1   = new Bundle( System.currentTimeMillis() + 50 );
            bndl2   = new Bundle( System.currentTimeMillis() + 1550 );
            // this is going to be the node ID of our synth
            nodeID  = new Integer( 1001 + i );
            // this next messages creates the synth
            bndl1.addPacket( new Message( "/s_new", new Object[] { "default", nodeID, new Integer( 1 ), new Integer( 0 )}));
            // this next messages starts to releases the synth in 1.5 seconds (release time is 2 seconds)
            bndl2.addPacket( new Message( "/n_set", new Object[] { nodeID, "gate", new Float( -(2f + 1f) )}));
            // send both bundles (scsynth handles their respective timetags)
            c.send( bndl1 );
            c.send( bndl2 );
    
            // now wait for the signal from our osc listener (or timeout in 10 seconds)
            synchronized( sync ) {
                sync.wait( 10000 );
            }
            catch( InterruptedException e1 ) {}
    
            // ok, unsubscribe getting info messages
            c.send( new Message( "/notify", new Object[] { new Integer( 0 )}));
    
            // ok, stop the client
            // ; this isn't really necessary as we call dispose soon
            c.stop();
        }
        catch( IOException e11 ) {
            e11.printStackTrace();
        }
    
        // dispose the client (it gets stopped if still running)
        c.dispose();
    

    See also

    OSCServer

    Receiver

    Transmitter

  4. object Dump

    Permalink
  5. object File extends Transport with Product with Serializable

    Permalink

    XXX TODO -- this transport has not yet been implemented.

  6. object Implicits

    Permalink
  7. object Message

    Permalink
  8. object Packet

    Permalink
  9. object PacketCodec

    Permalink

    A packet codec defines how the translation between Java objects and OSC atoms is accomplished.

    A packet codec defines how the translation between Java objects and OSC atoms is accomplished. For example, by default, when an OSC message is assembled for transmission, the encoder will translate ajava.lang.Integer argument into a four byte integer with typetag 'i'. Or when a received message is being decoded, finding an atom typetagged 'f', the decoder will create a java.lang.Float out of it.

    This example sounds trivial, but the codec is also able to handle type conversions. For instance, in the strict OSC 1.0 specification, only 32bit numeric atoms are defined ('i' and 'f'). A codec with mode MODE_STRICT_V1 will reject a java.lang.Double in the encoding process and not be able to decode a typetag 'd'. A codec with mode MODE_MODEST automatically breaks down everything the 32bit, so a java.lang.Double gets encoded as 32bit 'f' and a received atom tagged 'd' becomes a java.lang.Float. Other configurations exist.

    Another important function of the codec is to specify the charset encoding of strings, something that was overseen in the OSC 1.0 spec. By default, UTF-8 is used so all special characters can be safely encoded.

    Last but not least, using the putDecoder and putEncoder methods, the codec can be extended to support additional Java classes or OSC typetags, without the need to subclass PacketCodec.

  10. object Receiver

    Permalink
  11. object ScalaOSC

    Permalink
  12. object TCP extends Net with Product with Serializable

    Permalink

    TCP as a transport for OSC.

    TCP as a transport for OSC. At the moment, packets are encoded in the OSC 1.0 format, regardless of of the configuration's packet codec. That means the 32-bit Int size followed by the actual plain packet is encoded. The OSC 1.1 draft suggests SLIP (cf. http://www.faqs.org/rfcs/rfc1055.html). This may be configurable in the future.

  13. object Timetag extends Serializable

    Permalink
  14. object Transmitter

    Permalink
  15. object Transport

    Permalink
  16. object UDP extends Net with Product with Serializable

    Permalink

Ungrouped