Examples of AudioTrail


Examples of de.sciss.meloncillo.io.AudioTrail

      final boolean          cutTimeline      = ((Boolean) context.getClientArg( "cut" )).booleanValue();
      final Span            cutTimelineSpan    = (Span) context.getClientArg( "cutSpan" );
      final long            delta        = insertPos - tl.getSpan().start;
      Track.Info            ti;
      Trail              srcTrail;
      AudioTrail            audioTrail;
//      Transmitter            trns;
      boolean[]            trackMap;
      boolean              isAudio, isTrns, pasteAudio;

//System.out.println( "paste to:" );
//Track.debugDump( tis );

      for( int i = 0; i < tis.size(); i++ ) {
        ti    = (Track.Info) tis.get( i );
        if( ti.selected ) {  // ----------------- selected tracks -----------------
          try {
            ti.trail.editBegin( edit );
// EEE
//            isAudio  = ti.track instanceof AudioTrack;
isAudio = false;
            isTrns    = ti.tracks.get( 0 ) instanceof Transmitter;
            srcTrail  = tl.getSubTrail( ti.trail.getClass(), ti.trackIndex );
         
            if( isAudio ) {
              pasteAudio = (srcTrail != null) && (((AudioTrail) srcTrail).getChannelNum() > 0);
            } else if( isTrns ) {
              pasteAudio = (srcTrail != null);
            } else {
              pasteAudio = false;
            }
           
            if( mode == EDIT_INSERT ) {
              ti.trail.editInsert( this, insertSpan, edit );
              if( cutTimeline ) ti.trail.editRemove( this, cutTimelineSpan, edit );
            } else if( pasteAudio || ((mode == EDIT_OVERWRITE) && !(isAudio || isTrns)) ) { // Audio needs to be cleared even in Mix mode!
              ti.trail.editClear( this, insertSpan, edit );
            }
           
            if( pasteAudio ) {
              audioTrail  = (AudioTrail) ti.trail;
              trackMap  = tl.getChannelMap( srcTrail );
             
              final int[] trackMap2 = new int[ audioTrail.getChannelNum() ];
              for( int j = 0, k = 0; j < trackMap2.length; j++ ) {
                if( ti.channelMap[ j ]) {  // target track selected
                  for( ; (k < trackMap.length) && !trackMap[ k ] ; k++ ) ;
                  if( k < trackMap.length ) {  // source track exiting
                    trackMap2[ j ] = k++;
                  } else if( tl.getTrackNum( ti.trail.getClass() ) > 0 ) {    // ran out of source tracks, fold over (simple mono -> stereo par exemple)
                    for( k = 0; !trackMap[ k ] ; k++ ) ;
                    trackMap2[ j ] = k++;
                  } else {
                    trackMap2[ j ] = -1;    // there aren't any clipboard tracks ....
                  }
                } else {              // target track not selected
                  trackMap2[ j ] = -1;
                }
              }
              if( !audioTrail.copyRangeFrom( (AudioTrail) srcTrail, copySpan, insertPos, mode, this, edit, trackMap2, bcPre, bcPost )) return CANCELLED;

            } else if( (ti.tracks.size() == 1) && (tl.getTrackNum( ti.trail.getClass() ) == 1) ) {
              ti.trail.editAddAll( this, srcTrail.getCuttedRange(
                copySpan, true, srcTrail.getDefaultTouchMode(), delta ), edit );
            }
View Full Code Here

Examples of de.sciss.meloncillo.io.AudioTrail

      final float[][]      buf      = new float[ 2 ][ 4096 ];
      final BasicCompoundEdit  edit    = (BasicCompoundEdit) context.getClientArg( "edit" );
      final List        collNewTrns  = (List) context.getClientArg( "trns" );
      final int        num      = collNewTrns.size();
      Transmitter        trns;
      AudioTrail        at;
      long          progress  = 0;
      double          d1;
      Span          span    = (Span) context.getClientArg( "span" );
//      TrackSpan        ts;
      float          f1, f2;
      AudioStake        as;
      int            chunkLen;
     
      if( span.isEmpty() ) return DONE;
     
      try {
        for( int i = 0; i < num; i++ ) {
          d1    = ((double) i / (double) num - 0.25) * Math.PI * -2;
//          f1    = (float) (0.25 * (2.0 + Math.cos( d1 )));
//          f2    = (float) (0.25 * (2.0 + Math.sin( d1 )));
          f1    = (float) (0.5 * Math.cos( d1 ));
          f2    = (float) (0.5 * Math.sin( d1 ));
          for( int j = 0; j < 4096; j++ ) {
            buf[0][j] = f1;
            buf[1][j] = f2;
          }
          trns  = (Transmitter) collNewTrns.get( i );
          at    = trns.getAudioTrail();
//          ts    = at.beginInsert( span, edit );
          as    = at.alloc( span );
          for( long framesWritten = 0, frames = span.getLength(); framesWritten < frames; ) {
            chunkLen = (int) Math.min( 4096, frames - framesWritten );
//            at.continueWrite( ts, buf, 0, j );
            as.writeFrames( buf, 0, new Span( span.start + framesWritten, span.start + framesWritten + chunkLen ));
            framesWritten += chunkLen;
          }
//          stakes.add( as );
          at.editBegin( edit );
          try {
            at.editAdd( this, as, edit ); // EEE should undy the stake alloc!!!
          } finally {
            at.editEnd( edit );
          }
//          at.finishWrite( ts, edit );
          progress++;
          context.setProgression( (float) progress / (float) num );
        }
View Full Code Here

Examples of de.sciss.meloncillo.io.AudioTrail

    float[][]            inTrnsFrames, outTrnsFrames;
    int                minBlockSize, maxBlockSize, prefBlockSize;
    int                i, numTrns, numRcv, trnsIdx, rcvIdx, readLen, writeLen;
    Transmitter            trns;
    AudioTrail            at;
    boolean[]            trnsRequest;
    Object              val;
    long              readOffset, remainingRead, remainingWrite;
    Set                newOptions;
    String              className;
    boolean              success    = false// pessimist bitchâ„¢
   
    // --- resampling related ---
    int            inOff, inTrnsLen, outTrnsLen;
    int            fltLenI    = 0;
    int            overlapLen  = 0;
    int            overlapOff  = 0;
    int            trnsInside  = 0;
    Resampling        rsmp    = null;
    double          rsmpFactor  = 1.0;
    double          inPhase    = 0.0;
    double          newInPhase  = 0.0;
    double          fltLen    = 0.0;
    float[][][]        trnsOverlaps= null;

    // --- init ---

    readOffset    = context.getTimeSpan().getStart();
    numRcv      = context.getReceivers().size();
    numTrns      = context.getTransmitters().size();
    source      = new RenderSource( numTrns, numRcv );

    try {
      if( !invokeProducerBegin( pt, context, source, plugIn )) return FAILED;
      remainingRead    = context.getTimeSpan().getLength();
      newOptions      = context.getModifiedOptions();
      if( newOptions.contains( RenderContext.KEY_MINBLOCKSIZE )) {
        val        = context.getOption( RenderContext.KEY_MINBLOCKSIZE );
        minBlockSize  = ((Integer) val).intValue();
      } else {
        minBlockSize  = 1;
      }
      if( newOptions.contains( RenderContext.KEY_MAXBLOCKSIZE )) {
        val        = context.getOption( RenderContext.KEY_MAXBLOCKSIZE );
        maxBlockSize  = ((Integer) val).intValue();
      } else {
        maxBlockSize  = 0x7FFFFF;
      }
      if( newOptions.contains( RenderContext.KEY_PREFBLOCKSIZE )) {
        val        = context.getOption( RenderContext.KEY_PREFBLOCKSIZE );
        prefBlockSize  = ((Integer) val).intValue();
      } else {
        prefBlockSize   = Math.max( minBlockSize, Math.min( maxBlockSize, 1024 ));
      }
      assert minBlockSize <= maxBlockSize : "minmaxblocksize";
     
      if( newOptions.contains( RenderContext.KEY_TARGETRATE )) {
      // ---- prepare resampling ----
        val        = context.getOption( RenderContext.KEY_TARGETRATE );
        rsmpFactor    = ((Double) val).doubleValue() / (double) context.getSourceRate();
        className    = classPrefs.get( KEY_RESAMPLING, null );
        if( className == null ) {
          className   = NearestNeighbour.class.getName(); // RSMP_ITEMS[ 0 ].getKey();
          showMessage( JOptionPane.WARNING_MESSAGE, app.getResourceString( "errResamplingClass" ) +
                  " : " + val.toString() );
        }
        try {
          rsmp    = (Resampling) Class.forName( className ).newInstance();
        }
        catch( InstantiationException e1 ) {
          pt.setException( e1 );
          return FAILED;
        }
        catch( IllegalAccessException e2 ) {
          pt.setException( e2 );
          return FAILED;
        }
        catch( ClassNotFoundException e3 ) {
          pt.setException( e3 );
          return FAILED;
        }
        finally {
          if( rsmp == null ) {
            showMessage( JOptionPane.ERROR_MESSAGE,
                   app.getResourceString( "errResamplingClass" ) + " : " + className );
          }
        }
       
        fltLen      = rsmp.getWingSize( rsmpFactor );
        fltLenI      = (int) fltLen + 1;
        inOff      = fltLenI;
        overlapLen    = fltLenI << 1;
        if( rsmpFactor > 1.0 ) {
          outTrnsLen  = prefBlockSize;
          i      = (int) (outTrnsLen / rsmpFactor);
          inTrnsLen   = i + overlapLen;
        } else {
          inTrnsLen   = Math.max( prefBlockSize, fltLenI + overlapLen );
          i      = inTrnsLen - overlapLen;
          outTrnsLen  = (int) (i * rsmpFactor) + 1;
        }
        overlapOff    = inTrnsLen - overlapLen;
        trnsInside    = inTrnsLen - fltLenI - fltLenI;
        trnsOverlaps  = new float[ numTrns ][2][ overlapLen ];
        inTrnsFrames  = new float[2][ inTrnsLen ];
        outTrnsFrames   = new float[2][ outTrnsLen ];
        remainingWrite  = (long) (remainingRead * rsmpFactor + 0.5);
//System.err.println( "fltLen "+fltLen+"; inOff "+inOff+"; overlapLen "+overlapLen+"; inTrnsLen "+inTrnsLen+"; outTrnsLen "+outTrnsLen+"; rsmpFactor "+rsmpFactor );
      } else {
        inTrnsLen    = prefBlockSize;
        outTrnsLen    = inTrnsLen;
        inTrnsFrames  = new float[2][ inTrnsLen ];
        outTrnsFrames   = inTrnsFrames;
        inOff      = 0;
        remainingWrite  = remainingRead;
      }

      // --- responding to RenderSource requests ---
      trnsRequest      = new boolean[ numTrns ];   // all false by default
     
      for( trnsIdx = 0; trnsIdx < numTrns; trnsIdx++ ) {
        if( source.trajRequest[ trnsIdx ]) {
          source.trajBlockBuf[ trnsIdx = new float[ 2 ][ outTrnsLen ];
          trnsRequest[ trnsIdx ]      = true;
        }
        for( rcvIdx = 0; rcvIdx < numRcv; rcvIdx++ ) {
          if( source.senseRequest[ trnsIdx ][ rcvIdx ]) {
            source.senseBlockBuf[ trnsIdx ][ rcvIdx ] = new float[ outTrnsLen ];
            trnsRequest[ trnsIdx ]    = true;
          }
        }
      }

      // --- rendering loop ---

      while( isRunning() && remainingWrite > 0 ) {
        readLen        = (int) Math.min( inTrnsLen - inOff, remainingRead );
        source.blockSpan  = new Span( readOffset, readOffset + readLen );
        if( rsmp != null ) {
          inPhase      = newInPhase;
          writeLen    = (int) Math.min( Math.ceil( (trnsInside - inPhase) * rsmpFactor ), remainingWrite );
        } else {
          writeLen    = readLen;
        }
        source.blockBufLen  = writeLen;

        for( trnsIdx = 0; trnsIdx < numTrns; trnsIdx++ ) {
          if( !trnsRequest[ trnsIdx ]) continue;
         
          // --- read transmitter trajectory data ---
          trns    = (Transmitter) context.getTransmitters().get( trnsIdx );
          at      = trns.getAudioTrail();
//          at.read( source.blockSpan, inTrnsFrames, inOff );
          at.readFrames( inTrnsFrames, inOff, source.blockSpan );
          for( i = inOff + readLen; i < inTrnsLen; i++ ) {
            inTrnsFrames[0][i] = 0.0f;    // zero pad in the end
            inTrnsFrames[1][i] = 0.0f;    // XXX actually the last sample should be repeated!
          }
         
View Full Code Here

Examples of de.sciss.meloncillo.io.AudioTrail

  public boolean consumerBegin( RenderContext context, RenderSource source )
  throws IOException
  {
    final ConsumerContext  consc;
    Transmitter        trns;
    AudioTrail        at;
   
    consc      = new ConsumerContext();
    consc.edit    = new CompoundSessionObjEdit( this, context.getTransmitters(), Transmitter.OWNER_TRAJ,
                            null, null, "Filter" );
//    consc.bs    = new BlendSpan[ source.numTrns ];
    consc.as    = new AudioStake[ source.numTrns ];
    consc.bc    = root.getBlending()// XXX THREAD XXX
//    if( consc.bc != null ) consc.srcBuf = new float[ 2 ][ 4096 ];
    context.setOption( KEY_CONSC, consc );

    for( int trnsIdx = 0; trnsIdx < source.numTrns; trnsIdx++ ) {
      if( !source.trajRequest[ trnsIdx ]) continue;
     
      trns        = (Transmitter) context.getTransmitters().get( trnsIdx );
      at          = trns.getAudioTrail();
//      consc.bs[ trnsIdx ]  = at.beginOverwrite( context.getTimeSpan(), consc.bc, consc.edit );
      consc.as[ trnsIdx= at.alloc( context.getTimeSpan() );
    }
   
    return true;
  }
View Full Code Here

Examples of de.sciss.meloncillo.io.AudioTrail

   */
  public boolean consumerFinish( RenderContext context, RenderSource source )
  throws IOException
  {
    Transmitter        trns;
    AudioTrail        at;
    int            trnsIdx;
    ConsumerContext      consc   = (ConsumerContext) context.getOption( KEY_CONSC );

    for( trnsIdx = 0; trnsIdx < source.numTrns; trnsIdx++ ) {
      if( !source.trajRequest[ trnsIdx ]) continue;

      trns        = (Transmitter) context.getTransmitters().get( trnsIdx );
      at          = trns.getAudioTrail();
      at.editBegin( consc.edit );
      at.editClear( this, consc.as[ trnsIdx].getSpan(), consc.edit );
      at.editAdd( this, consc.as[ trnsIdx], consc.edit );
      at.editEnd( consc.edit );
//      at.finishWrite( consc.bs[ trnsIdx], consc.edit );
    }

    consc.edit.perform();
    consc.edit.end(); // fires doc.tc.modified()
View Full Code Here

Examples of de.sciss.meloncillo.io.AudioTrail

  public boolean consumerRender( RenderContext context, RenderSource source )
  throws IOException
  {
    ConsumerContext      consc   = (ConsumerContext) context.getOption( KEY_CONSC );
    Transmitter        trns;
    AudioTrail        at;
    int            trnsIdx;

    for( trnsIdx = 0; trnsIdx < source.numTrns; trnsIdx++ ) {
      if( !source.trajRequest[ trnsIdx ]) continue;

      trns        = (Transmitter) context.getTransmitters().get( trnsIdx );
      at          = trns.getAudioTrail();
      if( consc.as[ trnsIdx ] == null ) {
        context.getHost().showMessage( JOptionPane.ERROR_MESSAGE,
          AbstractApplication.getApplication().getResourceString( "renderEarlyConsume" ));
        return false;
      }
     
      if( consc.bc != null ) {
        final long blendLen = consc.bc.getLen()// EEE getLen?
        final long interpOff = source.blockSpan.start - context.getTimeSpan().start;
        final long fadeOutOff = context.getTimeSpan().getLength() - blendLen;
        if( (consc.srcBuf == null) || (consc.srcBuf[ 0 ].length < source.blockBufLen) ) {
          consc.srcBuf = new float[ 2 ][ source.blockBufLen ];
        }
        at.readFrames( consc.srcBuf, 0, source.blockSpan );
        if( interpOff < blendLen ) {
          consc.bc.blend( interpOff, consc.srcBuf, 0, source.trajBlockBuf[ trnsIdx ], 0, source.trajBlockBuf[ trnsIdx ], 0, source.blockBufLen );
        }
        if( (interpOff + source.blockBufLen) > fadeOutOff ) {
          consc.bc.blend( interpOff - fadeOutOff, source.trajBlockBuf[ trnsIdx ], 0, consc.srcBuf, 0, source.trajBlockBuf[ trnsIdx ], 0, source.blockBufLen );
View Full Code Here

Examples of de.sciss.meloncillo.io.AudioTrail

    if( pos < 0 ) return;
   
    try {
      for( int trnsIdx = 0; trnsIdx < numTrns; trnsIdx++ ) {
        final Transmitter  trns  = (Transmitter) collTrns.get( trnsIdx );
        final AudioTrail  at    = trns.getAudioTrail();
        at.readFrames( trnsBuf, 0, new Span( pos, pos + 1 ));
        rt_trnsLocX[ trnsIdx = trnsBuf[ 0 ][ 0 ];
        rt_trnsLocY[ trnsIdx = -trnsBuf[ 1 ][ 0 ];
      }
    }
    catch( IOException e1 ) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.