Package de.sciss.jcollider

Examples of de.sciss.jcollider.Server


    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 ) {
            f.write( synthPhasor.newMsg( nrtGrpInput, new String[] {
              "i_aInBf",           "rate",   "i_aPhBs"          }, new float[] {
              bufsDisk[ 0 ].getBufNum(), realRate, busPh.getIndex() }));
          }
         
        } else {
          time = (nrtClock * DISKBUF_SIZE_HM / sourceRate) + 0.1// a bit beyond that spot to avoid rounding errors
        }
      }
     
      time = span.getLength() / sourceRate;
//System.err.println( "time = "+time );
      f.setTime( time );
      f.write( nrtGrpRoot.freeMsg() );
      for( int i = 0; i < bufsDisk.length; i++ ) {
        f.write( bufsDisk[ i ].freeMsg() );
      }
     
      f.close();
//      f.dispose();
      f = null;

      try {
        rom.replyDone( 1, new Object[0] );
      }
      catch( IOException e11 ) {
        OSCRoot.failed( rom, e11 );
      }
    }
    catch( ClassCastException e1 ) {
      OSCRoot.failedArgType( rom, argIdx );
    }
    catch( IndexOutOfBoundsException e1 ) {
      OSCRoot.failedArgCount( rom );
    }
    catch( IOException e1 ) {
//      rom.replyFailed( rom, e1 );
      e1.printStackTrace();
      try {
        rom.replyFailed( 1 );
      }
      catch( IOException e11 ) {
        OSCRoot.failed( rom, e11 );
      }
    }
    finally {
      if( nrtServer != null ) nrtServer.dispose();
      if( f != null ) f.dispose();
    }
  }
View Full Code Here


          throw new IllegalArgumentException( "Illegal protocol : " + so.getProtocol() );
        }
      }
   
      // loopback is sufficient here
      server  = new Server( AbstractApplication.getApplication().getName(),
                  new InetSocketAddress( "127.0.0.1", serverPort ), so );
//      for( int i = 0; i < collListeners.size(); i++ ) {
//        server.addListener( (ServerListener) collListeners.get( i ));
//      }
      server.addListener( this );
View Full Code Here

        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;
View Full Code Here

    ggOutputConfig.setPreferences( audioPrefs, PrefsUtil.KEY_OUTPUTCONFIG );
    ggAudioBox.setPreferences( audioPrefs, PrefsUtil.KEY_AUDIOBOX );
    audioBoxListener = new ActionListener() {
      public void actionPerformed( ActionEvent e )
      {
        final Server server = superCollider.getServer();
        if( (server != null) && server.isRunning() ) {
          final JOptionPane op = new JOptionPane( getResourceString( "optionDlgAudioBoxReboot" ), JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION );
          if( BasicWindowHandler.showDialog( op, getWindow(), null ) == 0 ) {
            superCollider.reboot();
          }
        }
View Full Code Here

    ggVolume.setVolumeLinear( superCollider.getVolume() );
  }

  private void startMeters()
  {
    final Server        s      = superCollider.getServer();
    final ServerOptions      so      = superCollider.getServerOptions();
    final int          numOutputBusChannels;
    final int[]          channels;
    final Group          mg      = superCollider.getMasterGroup();
 
    if( (s == null) || (oCfg == null) || (mg == null) ) return;

    channels        = new int[ oCfg.mapping.length ];
    numOutputBusChannels  = so.getNumOutputBusChannels();
    for( int ch = 0; ch < channels.length; ch++ ) {
      if( oCfg.mapping[ ch ] < numOutputBusChannels ) {
        channels[ ch ] = oCfg.mapping[ ch ];
      } else {
        channels[ ch ] = -1;
      }
    }
   
    try {
      if( grpMeters == null ) {
        grpMeters = Group.basicNew( s );
        final OSCBundle bndl = new OSCBundle();
        bndl.addPacket( grpMeters.addBeforeMsg( mg ));
        grpMeters.setName( "CtrlRmMeters" );
        NodeWatcher.newFrom( s ).register( grpMeters );
        s.sendBundle( bndl );
      }
      lmm.setGroup( grpMeters );
      lmm.setInputs( s, channels );
    }
    catch( IOException e1 ) {
View Full Code Here

TOP

Related Classes of de.sciss.jcollider.Server

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.