Package de.sciss.io

Examples of de.sciss.io.Span


    int            idx      = indexOf( span.start, true );
    if( idx < 0 )      idx      = Math.max( 0, -(idx + 2) );
    long          readOff    = span.start;
    AudioStake        source;
    int            chunkLen;
    Span          sourceSpan, subSpan;
    long          readStop  = span.start;
   
    for( int i = 0; i < channelMap.length; i++ ) {
      inBuf[ channelMap[ i ]] = outBuf[ i ];
    }
   
    while( (readStop < span.stop) && (idx < num) ) {
      source    = (AudioStake) get( idx, true );
      sourceSpan  = source.getSpan();
      readStop  = Math.min( sourceSpan.stop, span.stop );
      while( readOff < readStop ) {
        chunkLen = (int) Math.min( BUFSIZE, readStop - readOff );
        subSpan   = new Span( readOff, readOff + chunkLen );
        source.readFrames( inBuf, 0, subSpan );
        target.writeFrames( outBuf, 0, subSpan );
        readOff += chunkLen;
        setProgression( readOff - span.start, progWeight );
//if( true ) throw new IOException( "FAIL TEST" );
      }
      idx++;
    }
    if( readStop < span.stop ) {
System.err.println( "WARNING: trying to flatten beyond the trail's stop" );
      for( int ch = 0; ch < outBuf.length; ch++ ) {
        for( int i = 0; i < outBuf[ ch ].length; i++ ) {
          outBuf[ ch ][ i ] = 0f;
        }
      }
      while( readOff < span.stop ) {
        chunkLen = (int) Math.min( BUFSIZE, span.stop - readOff );
        subSpan   = new Span( readOff, readOff + chunkLen );
        target.writeFrames( outBuf, 0, subSpan );
        readOff += chunkLen;
        setProgression( readOff - span.start, progWeight );
      }
    }
View Full Code Here


    actionSilence    = new ActionSilence();
    actionTrim      = new ActionTrim();

    timeline.setRate( this, this.displayAFD.rate );
    timeline.setLength( this, this.displayAFD.length );
    timeline.setVisibleSpan( this, new Span( 0, this.displayAFD.length ));
    selectedTracks.add( this, markerTrack );
   
    blending      = new BlendingAction( timeline, null );
  }
View Full Code Here

      proc.putClientArg( "afds", descrs );
      proc.putClientArg( "doc", Session.this );
      proc.putClientArg( "asCopy", new Boolean( asCopy ));
      proc.putClientArg( "chanMap", channelMap );
      proc.putClientArg( "markers", new Boolean( saveMarkers ));
      proc.putClientArg( "span", span == null ? new Span( 0, timeline.getLength() ) : span );
      return proc;
    }
View Full Code Here

    {
      final AudioFileDescr[]      clientAFDs  = (AudioFileDescr[]) context.getClientArg( "afds" );
      final int            numFiles  = clientAFDs.length;
      final Session          doc      = (Session) context.getClientArg( "doc" );
      final boolean          saveMarkers  = ((Boolean) context.getClientArg( "markers" )).booleanValue();
      final Span            span    = (Span) context.getClientArg( "span" );
      final int[]            channelMap  = (int[]) context.getClientArg( "chanMap" );
      final AudioTrail        audioTrail  = doc.getAudioTrail();
//      final File[]          tempFs    = new File[ numFiles ];
//      final boolean[]          renamed    = new boolean[ numFiles ];
      final AudioFile[]        afs      = new AudioFile[ numFiles ];
View Full Code Here

      perform();
    }

    protected ClipboardTrackList getSelectionAsTrackList()
    {
      final Span span;
     
//      if( !bird.attemptShared( Session.DOOR_TIME | Session.DOOR_TRACKS, 250 )) return null;
//      try {
        span = timeline.getSelectionSpan();
        if( span.isEmpty() ) return null;

        return new ClipboardTrackList( Session.this );
//      }
//      finally {
//        bird.releaseShared( Session.DOOR_TIME | Session.DOOR_TRACKS );
View Full Code Here

      if( !checkProcess() ) return null;
     
      if( (insertPos < 0) || (insertPos > timeline.getLength()) ) throw new IllegalArgumentException( String.valueOf( insertPos ));
     
      final ProcessingThread    proc;
      final Span          oldSelSpan, insertSpan, copySpan, cutTimelineSpan;
      final AbstractCompoundEdit  edit;
      final Flag          hasSelectedAudio;
      final List          tis;
      final boolean        expTimeline, cutTimeline;
      final long          docLength, pasteLength, preMaxLen, postMaxLen;
      final BlendContext      bcPre, bcPost;
     
      hasSelectedAudio  = new Flag( false );
      tis          = Track.getInfos( selectedTracks.getAll(), tracks.getAll() );
      if( !AudioTracks.checkSyncedAudio( tis, mode == EDIT_INSERT, null, hasSelectedAudio )) return null;

      expTimeline      = (mode == EDIT_INSERT) && hasSelectedAudio.isSet();
      docLength      = timeline.getLength();
      pasteLength      = expTimeline ? tl.getSpan().getLength() :
        Math.min( tl.getSpan().getLength(), docLength - insertPos );
      if( pasteLength == 0 ) return null;
     
      if( mode == EDIT_INSERT ) {
        /*
         *  before paste:
         *
         *   maxRight / post   maxLeft / pre
         *
         *  |                 |              |
         *  |                 |              |
         *  |                 |              |
         *  |        A        |     B        |
         *  +-----------------+--------------+
         *                    |
         *                 insertPos
         *
         *  after paste:
         *
         *  |                 | B #$$$$# A |              |
         *  |                 |  ##$$$$##  |              |
         *  |                 | ###$$$$### |              |
         *  |        A        |####$$$$####|      B       |
         *  +-----------------+------------+--------------+
         *                    |
         *                 insertPos
         */
        // note: now the discrepancy between postMaxLen and preMaxLen is
        // limited to 100%, so pasting at the very end or beginning of
        // a doc will not produce a single sided xfade any more
        // (answering bug 1922862)
        if( insertPos < (docLength - insertPos) ) {
          postMaxLen  = Math.min( insertPos, pasteLength >> 1 );
//          preMaxLen  = Math.min( docLength - insertPos, pasteLength - postMaxLen );
          preMaxLen  = Math.min( postMaxLen << 1, Math.min( docLength - insertPos, pasteLength - postMaxLen ));
//System.out.println( "A" );
        } else {
          preMaxLen  = Math.min( docLength - insertPos, pasteLength >> 1 );
          postMaxLen  = Math.min( preMaxLen << 1, Math.min( insertPos, pasteLength - preMaxLen ));
//System.out.println( "B" );
        }
      } else {
        preMaxLen  = pasteLength >> 1// note: pasteLength already clipped to be <= docLength - insertPos !
        postMaxLen  = pasteLength - preMaxLen;
//System.out.println( "C" );
      }
      bcPre      = createBlendContext( preMaxLen, 0, hasSelectedAudio.isSet() );
      bcPost      = createBlendContext( postMaxLen, 0, hasSelectedAudio.isSet() );
//System.out.println( "D ; preMaxLen = " + preMaxLen + "; postMaxLen = " + postMaxLen + "; bcPre.getLeftLen() = " + (bcPre == null ? null : String.valueOf( bcPre.getLeftLen())) + "; bcPre.getRightLen() = " + (bcPre == null ? null : String.valueOf( bcPre.getRightLen() )) + "; bcPost.getLeftLen() = " + (bcPost == null ? null : String.valueOf( bcPost.getLeftLen() )) + "; bcPost.getRightLen() = " + (bcPost == null ? null : String.valueOf( bcPost.getRightLen() )));

//      if( bcPre != null )  System.out.println( "bcPre  : " + bcPre.getLen() + ", " + bcPre.getLeftLen() + ", "+ bcPre.getRightLen() );
//      if( bcPost != null ) System.out.println( "bcPost : " + bcPost.getLen() + ", " + bcPost.getLeftLen() + ", "+ bcPost.getRightLen() );
     
      insertSpan      = new Span( insertPos, insertPos + pasteLength );
      copySpan      = new Span( tl.getSpan().start, tl.getSpan().start + pasteLength );
      cutTimeline      = (mode == EDIT_INSERT) && !hasSelectedAudio.isSet();
      cutTimelineSpan    = cutTimeline ? new Span( docLength, docLength + pasteLength ) : null;
     
      edit      = new BasicCompoundEdit( procName );
      oldSelSpan    = timeline.getSelectionSpan();
      if( !oldSelSpan.isEmpty() ) { // deselect
        edit.addPerform( TimelineVisualEdit.select( this, Session.this, new Span() ));
      }

      proc  = new ProcessingThread( this, getFrame(), procName );
      proc.putClientArg( "tl", tl );
      proc.putClientArg( "pos", new Long( insertPos ));
View Full Code Here

      final int            mode        = ((Integer) context.getClientArg( "mode" )).intValue();
      final List            tis          = (List) context.getClientArg( "tis" );
      final AbstractCompoundEdit    edit        = (AbstractCompoundEdit) context.getClientArg( "edit" );
      final BlendContext        bcPre        = (BlendContext) context.getClientArg( "bcPre" );
      final BlendContext        bcPost        = (BlendContext) context.getClientArg( "bcPost" );
      final Span            insertSpan      = (Span) context.getClientArg( "insertSpan" );
      final Span            copySpan      = (Span) context.getClientArg( "copySpan" );
      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;
      boolean[]            trackMap;
View Full Code Here

    {
      final ProcessingThread.Client  doneAction  = (ProcessingThread.Client) context.getClientArg( "doneAction" );
      final AbstractCompoundEdit    edit    = (AbstractCompoundEdit) context.getClientArg( "edit" );
      final boolean          expTimeline  = ((Boolean) context.getClientArg( "exp" )).booleanValue();
      final long            pasteLength  = ((Long) context.getClientArg( "pasteLen" )).longValue();
      final Span            insertSpan  = (Span) context.getClientArg( "insertSpan" );
     
      if( (context.getReturnCode() == DONE) ) {
        if( expTimeline && (pasteLength != 0) ) {  // adjust timeline
          edit.addPerform( new EditSetTimelineLength( this, Session.this, timeline.getLength() + pasteLength ));
          if( timeline.getVisibleSpan().isEmpty() ) {
            edit.addPerform( TimelineVisualEdit.scroll( this, Session.this, insertSpan ));
          }
        }
        if( !insertSpan.isEmpty() ) {
          edit.addPerform( TimelineVisualEdit.select( this, Session.this, insertSpan ));
          edit.addPerform( TimelineVisualEdit.position( this, Session.this, insertSpan.stop ));
        }

        edit.perform();
View Full Code Here

      perform();
    }
   
    protected void perform()
    {
      final Span            selSpan, deleteBefore, deleteAfter;
      final BasicCompoundEdit    edit;
      final List            tis;
      Track.Info            ti;
      boolean              success  = false;

      edit      = new BasicCompoundEdit( getValue( NAME ).toString() );
     
      try {
        selSpan      = timeline.getSelectionSpan();
//        if( selSpan.isEmpty() ) return;
        tis        = Track.getInfos( selectedTracks.getAll(), tracks.getAll() );
        deleteBefore  = new Span( 0, selSpan.start );
        deleteAfter    = new Span( selSpan.stop, timeline.getLength() );

        // deselect
        edit.addPerform( TimelineVisualEdit.select( this, Session.this, new Span() ));
        edit.addPerform( TimelineVisualEdit.position( this, Session.this, 0 ));

        if( !deleteAfter.isEmpty() || !deleteBefore.isEmpty() ) {
          for( int i = 0; i < tis.size(); i++ ) {
            ti = (Track.Info) tis.get( i );
            ti.trail.editBegin( edit );
            try {
              if( !deleteAfter.isEmpty() ) ti.trail.editRemove( this, deleteAfter, edit );
              if!deleteBefore.isEmpty() ) ti.trail.editRemove( this, deleteBefore, edit );
            }
            finally {
              ti.trail.editEnd( edit );
            }
          }
        }

        edit.addPerform( new EditSetTimelineLength( this, Session.this, selSpan.getLength() ));
        edit.addPerform( TimelineVisualEdit.select( this, Session.this, selSpan.shift( -selSpan.start )));

        edit.perform();
        edit.end();
        getUndoManager().addEdit( edit );
        success = true;
View Full Code Here

      if( numFrames < 0 ) throw new IllegalArgumentException( String.valueOf( numFrames ));
      if( (pos < 0) || (pos > timeline.getLength()) ) throw new IllegalArgumentException( String.valueOf( pos ));

      final ProcessingThread     proc;
      final AbstractCompoundEdit  edit;
      final Span          oldSelSpan, insertSpan;

      proc = new ProcessingThread( this, getFrame(), getValue( NAME ).toString() );

      edit    = new BasicCompoundEdit( proc.getName() );
      oldSelSpan  = timeline.getSelectionSpan();
      insertSpan  = new Span( pos, pos + numFrames );

      if( !oldSelSpan.isEmpty() ) { // deselect
        edit.addPerform( TimelineVisualEdit.select( this, Session.this, new Span() ));
      }

      proc.putClientArg( "tis", Track.getInfos( selectedTracks.getAll(), tracks.getAll() ));
      proc.putClientArg( "edit", edit );
      proc.putClientArg( "span", insertSpan );
View Full Code Here

TOP

Related Classes of de.sciss.io.Span

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.