Package de.sciss.jcollider

Examples of de.sciss.jcollider.Bus


  public void oscCmd_createNRTFile( RoutedOSCMessage rom )
  {
    final SynthDef[]    defs;
    final Buffer[]      bufsDisk;
    final Synth[]      synthsBufRd;
    final Bus        busInternal, busPh;
    final Span        span        = doc.timeline.getSelectionSpan();
    final AudioTrail    at          = doc.getAudioTrail();
    final long        nrtPlayOffset    = span.start;
    final Span[]      bufSpans      = new Span[ 1 ];
    final Group        nrtGrpRoot, nrtGrpInput;
    final Synth        synthPhasor;
    final float        realRate;
    final float        interpolation;
    final double      nrtServerRate;
    final float        rate        = 1.0f;
    Server          nrtServer      = null;
    NRTFile          f          = null;
    int            argIdx        = 1;
    int            audioBusOffset, bufferOffset; //, controlBusOffset;
    OSCBundle        bndl;
    double          time        = 0.0;
    boolean          even;
    int            nrtClock;
    long          pos          = nrtPlayOffset;
   
    if( ct == null ) {
//      rom.replyFailed( rom, new IOException( "No routing context" ));
      try {
        rom.replyFailed( 1 );
      }
      catch( IOException e11 ) {
        OSCRoot.failed( rom, e11 );
      }
    }
 
    try {
      f        = NRTFile.openAsWrite( new File( rom.msg.getArg( argIdx ).toString() ));
      argIdx++;
      audioBusOffset  = ((Number) rom.msg.getArg( argIdx )).intValue();
      argIdx++;
//      controlBusOffset= ((Number) rom.msg.getArg( argIdx )).intValue();
      argIdx++;
      bufferOffset  = ((Number) rom.msg.getArg( argIdx )).intValue();
      argIdx++;
      nrtServerRate    = ((Number) rom.msg.getArg( argIdx )).doubleValue();
     
      nrtServer      = new Server( "nrt" );
     
      f.write( SuperColliderClient.getInstance().loadDefsMsg() );
     
      defs      = createInputDefs( ct.chanMaps ); // ct.numInputChannels
      if( defs != null ) {
        for( int i = 0; i < defs.length; i++ ) {
          f.write( defs[ i ].recvMsg() );
        }
      }

//      sourceRate      = doc.timeline.getRate();
//      serverRate      = server.getSampleRate();
      srcFactor      = sourceRate / nrtServerRate;
      realRate      = (float) (rate * srcFactor);
      interpolation    = realRate == 1.0f ? 1f : 3f;
   
      nrtGrpRoot        = Group.basicNew( nrtServer );
      f.write( nrtGrpRoot.addToHeadMsg( nrtServer.getDefaultGroup() ));
      nrtGrpInput      = Group.basicNew( nrtServer );
      f.write( nrtGrpInput.addToTailMsg( nrtGrpRoot ));

      synthsBufRd        = new Synth[ ct.numFiles ];
      busInternal        = new Bus( nrtServer, kAudioRate, audioBusOffset, ct.numInChans );
      audioBusOffset       += busInternal.getNumChannels();
      busPh        = new Bus( nrtServer, kAudioRate, audioBusOffset );
      audioBusOffset       += busPh.getNumChannels();
      bufsDisk        = new Buffer[ ct.numFiles ];
      for( int i = 0; i < ct.numFiles; i++ ) {
        bufsDisk[ i ]    = new Buffer( nrtServer, DISKBUF_SIZE, ct.chanMaps[ i ].length, bufferOffset++ );
        f.write( bufsDisk[ i ].allocMsg() );
      }

      for( int i = 0; i < ct.numFiles; i++ ) {
        synthsBufRd[ i = Synth.basicNew( "eisk-input" + ct.chanMaps[ i ].length, nrtServer );
      }
      synthPhasor  = Synth.basicNew( "eisk-phasor", nrtServer );

      for( nrtClock = 0, even = true;; nrtClock++, even = !even ) {
        if( even ) {
          pos = nrtClock * DISKBUF_SIZE_HM - DISKBUF_PAD + nrtPlayOffset;
        } else {
          pos = nrtClock * DISKBUF_SIZE_HM + nrtPlayOffset;
        }
        if( pos >= span.stop ) break;
        f.setTime( time );
//System.err.println( "clock = "+clock+"; pos = "+pos+"; time = "+time );
        bndl        = new OSCBundle( time );
//        if( pos >= DISKBUF_PAD ) {
        if( pos < 0 ) {
          for( int i = 0; i < bufsDisk.length; i++ ) {
            bndl.addPacket( bufsDisk[ i ].fillMsg( 0, DISKBUF_PAD * bufsDisk[ i ].getNumChannels(), 0.0f ));
          }
          pos += DISKBUF_PAD;
        }
//          bufSpans[ 0 ] = new Span( pos - DISKBUF_PAD, pos - DISKBUF_PAD + DISKBUF_SIZE_H );
        bufSpans[ 0 ] = new Span( pos, pos + DISKBUF_SIZE_H );
        at.addBufferReadMessages( bndl, bufSpans, bufsDisk, even ? 0 : DISKBUF_SIZE_H );
        f.write( bndl );
       
        if( nrtClock == 0 ) {
          for( int i = 0, off = 0; i < ct.numFiles; i++ ) {
            f.write( synthsBufRd[ i ].newMsg( nrtGrpInput, new String[] {
              "i_aInBf",                 "i_aOtBs",                    "i_aPhBs",            "i_intrp" }, new float[] {
              bufsDisk[ i ].getBufNum(), busInternal.getIndex() + off, busPh.getIndex(), interpolation }
            ));
            off += ct.chanMaps[ i ].length;
          }

          if( ct.numFiles > 0 ) {
View Full Code Here


      } else {
        OSCRoot.failedArgValue( rom, argIdx );
        return;
      }
      argIdx++;
      final Bus    b;
      final Server  s  = server;
      if( s != null ) {
        b = Bus.alloc( s, rate, rom.msg.getArgCount() > argIdx ?
          ((Integer) rom.msg.getArg( argIdx )).intValue() : 1 );
      } else {
        b = null;
      }
      if( b != null ) {
        final Integer idx = new Integer( b.getIndex() );
        mapOSCBusses.put( idx, b );
        rom.replyDone( 1, new Object[] { idx });
      } else {
        rom.replyFailed();
      }
View Full Code Here

  }

  public void oscCmd_freeBus( RoutedOSCMessage rom )
  {
    try {
      final Bus b = (Bus) mapOSCBusses.remove( rom.msg.getArg( 1 ));
      if( b != null ) {
        b.free();
      } else {
        OSCRoot.failed( rom.msg, OSCRoot.getResourceString( "errOSCBusNotFound" ));
      }
    }
    catch( IndexOutOfBoundsException e1 ) {
View Full Code Here

TOP

Related Classes of de.sciss.jcollider.Bus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.