Package de.sciss.io

Examples of de.sciss.io.Span


    if( stakes.isEmpty() ) return null;

    long    start  = Long.MAX_VALUE;
    long    stop  = Long.MIN_VALUE;
    Stake    stake;
    final Span  span;
   
    for( int i = 0; i < stakes.size(); i++ ) {
      stake  = (Stake) stakes.get( i );
      sortAddStake( stake, ce );
      start  = Math.min( start, stake.getSpan().start );
      stop  = Math.max( stop, stake.getSpan().stop );
    }
    span    = new Span( start, stop );
    if( ce != null ) ce.addPerform( new Edit( this, stakes, span, EDIT_ADD ));

    return span;
  }
View Full Code Here


  private Trail    t    = null;

  public MarkerStake( long pos, String name )
  {
    super( pos, name );
    span = new Span( pos, pos );
  }
View Full Code Here

  }
 
  public MarkerStake( Marker orig )
  {
    super( orig );
    span = new Span( pos, pos );
  }
View Full Code Here

    t  = null;
  }
 
  public Stake replaceStart( long newStart )
  {
    return new RegionStake( new Span( newStart, span.stop ), name );
  }
View Full Code Here

    return new RegionStake( new Span( newStart, span.stop ), name );
  }
 
  public Stake replaceStop( long newStop )
  {
    return new RegionStake( new Span( span.start, newStop ), name );
  }
View Full Code Here

    final Shape        clipOrig    = g2.getClip();
   
//    float[]          chanBuf;
    long          start      = info.span.start;
    long          totalLength    = info.getTotalLength();
    Span          chunkSpan;
    long          fullLen;
//    long          fullStop;
    int            chunkLen; // decimLen;
    float          scaleX, ampLog;
    Rectangle        r;
   
//    final float        scaleX      = (float) (view.getWidth() * stepSize) / totalLength;
   
//final float pixScale = 1072 / (view.getAmpLogMax() - view.getAmpLogMin());
//final float pixOff   = -view.getAmpLogMin();
final float pixScale = 10720 / (view.getAmpLogMax() - view.getAmpLogMin());
final float pixOff   = -view.getAmpLogMin() / 10;

    g2.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR );
   
    try {
      drawBusyList.clear(); // "must be called in the event thread"

      synchronized( bufSync ) {
        createBuffers();

long screenOffX = 0;
        while( totalLength > 0 ) {
          fullLen    = Math.min( maxLen, totalLength );
//          chunkLen  = (int) (fromPCM ? fullLen : decimHelps[ info.idx ].fullrateToSubsample( fullLen ));
          chunkLen  = (int) (decimHelps[ info.idx ].fullrateToSubsample( fullLen ));
//          decimLen  = chunkLen / info.inlineDecim;
//          chunkLen  = decimLen * info.inlineDecim;
          fullLen    = (long) chunkLen << info.shift;
//          chunkLen  = (int) (fullLen / stepSize);

//          if( fromPCM ) {
//            fullStop = fullScale.getSpan().stop;
//            if( start + fullLen <= fullStop ) {
//              chunkSpan = new Span( start, start + fullLen );
//              fullScale.readFrames( tmpBuf, 0, chunkSpan );
//            } else {
//              chunkSpan = new Span( start, fullStop );
//              fullScale.readFrames( tmpBuf, 0, chunkSpan );
//              // duplicate last frames
////              for( int i = (int) chunkSpan.getLength(), j = i - 1; i < (int) fullLen; i++ ) {
////                for( int ch = 0; ch < fullChannels; ch++ ) {
////                  sPeakP    = tmpBuf[ ch ];
////                  sPeakP[ i ]  = sPeakP[ j ];
////                }
////              }
//            }
//            decimator.decimatePCM( tmpBuf, tmpBuf2, fftBuf, 0, decimLen, info.inlineDecim );
//          } else {
////            chunkSpan = new Span( start, start + fullLen );
//            chunkSpan = new Span( start, start + fullLen );
//            readFrames( info.idx, tmpBuf2, 0, drawBusyList, chunkSpan, null);
//            if( info.inlineDecim > 1 ) decimator.decimate( tmpBuf2, tmpBuf2, 0, decimLen, info.inlineDecim );
//          }

          chunkSpan = new Span( start, start + fullLen );
         
//System.out.println( "chunkSpan = " + chunkSpan + "; chunkLen = " + chunkLen + "; fullLen = " + fullLen + "; screenOffX " + screenOffX + "; subLength " + info.sublength + "; shift " + info.shift + "; totalLen " + info.getTotalLength() );
         
          if( readFrames( info.idx, tmpBuf2, 0, drawBusyList, chunkSpan, null )) {
//          if( tempFAsync == null || tempFAsync[0] == null ) break;
//          tempFAsync[0].seekFrame( Math.min( start / stepSize, tempFAsync[0].getFrameNum() ));
//          int gaga = (int) Math.min( fullLen, Math.min( tmpBufSize2, tempFAsync[0].getFrameNum() - tempFAsync[0].getFramePosition() ));
//          tempFAsync[0].readFrames( tmpBuf2, 0, gaga);
         
            for( int ch = 0, tmpChReset = 0; ch < fullChannels; ch++, tmpChReset += modelChannels ) {
              r = view.rectForChannel( ch );
              scaleX = (float) r.width / info.getTotalLength();
  //System.out.println( " ... for ch = " + ch + "; scaleX = " + scaleX );
              for( int x = 0, off = 0; x < chunkLen; x++ ) {
                for( int y = 0, off2 = x + dataStartOff, tmpCh = tmpChReset; y < modelChannels; y++, tmpCh++, off2 -= imgW, off++ ) {
  //                ampLog = log10.calc( tmpBuf2[ tmpCh ][ x ]) * 20;
                  ampLog = log10.calc( Math.max( 1.0e-9f, tmpBuf2[ tmpCh ][ x ]));
                  data[ off2 ] = colors[ Math.max( 0, Math.min( 1072, (int) ((ampLog + pixOff) * pixScale) ))];
                }
              }
              raster.setDataElements( 0, 0, imgW, modelChannels, data );
              g2.drawImage( bufImg, r.x + (int) (screenOffX * scaleX + 0.5f), r.y, r.x + (int) ((screenOffX + fullLen) * scaleX + 0.5f), r.y + r.height, 0, 0, chunkLen, modelChannels, view );
            }
          }
          start += fullLen; // chunkLen * stepSize;
          totalLength -= fullLen; // chunkLen * stepSize;
          screenOffX += fullLen;
//          if( gaga == 0 ) totalLength = 0;
        }
      } // synchronized( bufSync )

      // System.err.println( "busyList.size() = "+busyList.size() );

      for( int ch = 0; ch < fullChannels; ch++ ) {
        r = view.rectForChannel( ch );
        g2.clipRect( r.x, r.y, r.width, r.height );
        if( !drawBusyList.isEmpty() ) {
          // g2.setColor( Color.red );
          g2.setPaint( pntBusy );
          for( int i = 0; i < drawBusyList.size(); i++ ) {
            chunkSpan = (Span) drawBusyList.get( i );
            scaleX = (float) r.width / info.getTotalLength();
            g2.fillRect( (int) ((chunkSpan.start - info.span.start) * scaleX) + r.x, r.y,
                         (int) (chunkSpan.getLength() * scaleX), r.height );
          }
        }
        // g2.setTransform(atOrig);
        g2.setClip( clipOrig );
      }
View Full Code Here

    // responsive (since it's zoomed out completely and due to the missing
    // decimation drawWaveform would take ages)
    boolean        someReady  = false;
    DecimatedStake    stake;
    int          chunkLen, discrepancy;
    Span        subSpan;
    int          readOffset, nextOffset = dataOffset;
    int          len      = (int) (readSpan.getLength() >> decimHelps[ sub ].shift );
   
    while( (len > 0) && (idx < coll.size()) ) {
      stake    = (DecimatedStake) coll.get( idx );
      subSpan    = new Span( Math.max( stake.getSpan().start, readSpan.start ),
                  Math.min( stake.getSpan().stop, readSpan.stop ));
      stake.readFrames( sub, data, nextOffset, subSpan, readyLen, busyLen );
      chunkLen  = readyLen.value() + busyLen.value();
      readOffset  = nextOffset + readyLen.value(); // chunkLen;
      nextOffset  = (int) ((subSpan.stop + startR) >> decimHelps[ sub ].shift) + dataOffset;
      discrepancy  = nextOffset - readOffset;
      len      -= readyLen.value() + discrepancy;
      if( readyLen.value() > 0 ) someReady = true;
      if( busyLen.value() == 0 ) {
        if( discrepancy > 0 ) {
          if( readOffset > 0 ) {
            for( int i = readOffset, k = readOffset - 1; i < nextOffset; i++ ) {
              for( int j = 0; j < data.length; j++ ) {
                data[ j ][ i ] = data[ j ][ k ];
              }
            }
          }
        }
      } else {
        final Span busySpan = new Span( subSpan.stop - (subSpan.getLength() * busyLen.value() / chunkLen),
                                        subSpan.stop );
        final int busyLastIdx = busyList.size() - 1;
        if( busyLastIdx >= 0 ) {
          final Span busySpan2 = (Span) busyList.get( busyLastIdx );
          if( busySpan.touches( busySpan2 )) {
            busyList.set( busyLastIdx, busySpan.union( busySpan2 ));
          } else {
            busyList.add( busySpan );
          }
View Full Code Here

    final List          stakes    = fullScale.getAll( true );
    if( stakes.isEmpty() ) return;

    final DecimatedStake    das;
    final Span          union    = fullScale.getSpan();
    final Span          extSpan;
    final long          fullrateStop, fullrateLen; // , insertLen;
    final int          numFullBuf;
    // final CacheManager cm = CacheManager.getInstance();
    final AbstractCompoundEdit  ce      = null; // XXX
    final Object        source    = null; // XXX
//    final AudioStake      cacheReadAS;
//    final AudioStake      cacheWriteAS;

    synchronized( fileSync ) {
      das = allocAsync( union );
//das.GOGO = true;
    }
    extSpan      = das.getSpan();
    // insertLen  = extSpan.getLength();
    fullrateStop  = Math.min( extSpan.getStop(), fullScale.editGetSpan( ce ).stop );
    fullrateLen    = fullrateStop - extSpan.getStart();

//    cacheReadAS    = null; // openCacheForRead( model );
//    if( cacheReadAS == null ) {
//      // cacheWriteAS = fullScale.openCacheForWrite( model,
//      // decimHelps[ 0 ].fullrateToSubsample( union.getLength() ));
//      cacheWriteAS = null; // openCacheForWrite( model, (fullrateLen + MAXCEILADD) & MAXMASK );
//      numFullBuf  = (int) (fullrateLen >> MAXSHIFT);
      numFullBuf  = (int) ((fullrateLen - fftSize + stepSize + stepSize - 1) / stepSize);
//    } else {
//      // cached files always have integer fullBufs!
//      numFullBuf  = (int) ((fullrateLen + MAXCEILADD) >> MAXSHIFT);
//      cacheWriteAS = null;
//    }

    synchronized( bufSync ) {
      createBuffers();
    }

    editClear( source, das.getSpan(), ce );
    editAdd( source, das, ce );

    threadAsync = new Thread( new Runnable() {
      public void run()
      {
final int pri = Thread.currentThread().getPriority();
//System.out.println( "pri was " + pri );
Thread.currentThread().setPriority( pri - 2 );
       
//        final CacheManager  cm          = PrefCacheManager.getInstance();
        long        pos;
        // long framesWritten = 0;
        long        framesWrittenCache  = 0;
//        boolean        cacheWriteComplete  = false;
        Span        tag2;
        int          len;
        long        time;
// WARNING: the variant with deferring the continueWrite
// does not work because we loose the bufSync and hence
// any readFrames destroys our buf. For high res analysis
// the speed gain using the outBufOff cache method is
// anyway <3%.
//        int          outBufOff  = 0;
        int          inBufOff = 0, nextLen = fftSize >> 1;
        long        nextTime      = System.currentTimeMillis() + UPDATE_PERIOD;

//        if( cacheReadAS != null ) {
//          pos = decimHelps[ 0 ].fullrateToSubsample( extSpan.getStart() ); // XXX
//        } else {
          pos = extSpan.getStart();
//        }
//        minCoarse = MAXCOARSE >> decimHelps[ 0 ].shift;

        try {
//long t1 = System.currentTimeMillis();
          for( int i = 0; (i < numFullBuf) && keepAsyncRunning; i++ ) {
            synchronized( bufSync ) {
//              if( (i % 100) == 0 ) System.out.println( "ici " + i + " / " + numFullBuf );
              len = (int) Math.min( nextLen, fullrateStop - pos );
//              if( inBufOff + len <= tmpBufSize ) {
                tag2 = new Span( pos, pos + len );
//                fullScale.readFrames( tmpBuf, inBufOff, tag2, null );
                fullScale.readFrames( tmpBuf, fftSize - nextLen, tag2, null );
//              } else { // hitting buffer boundaries
//                tag2 = new Span( pos, pos + (tmpBufSize - inBufOff) );
//                fullScale.readFrames( tmpBuf, inBufOff, tag2, null );
View Full Code Here

  throws IOException
  {
    if( DEBUG ) System.err.println( "addAllDep " + union.toString() );

    final DecimatedStake  das;
    final Span        extSpan;
    final long        fullrateStop, fullrateLen; // , insertLen;
    final int        numFullBuf;
    final double      progWeight;
    int            inBufOff = 0, nextLen = fftSize >> 1;
    long          pos;
    long          framesWritten = 0;
    Span          tag2;
//    float          f1;
    int            len;

    synchronized( fileSync ) {
      das = alloc( union );
    }
    extSpan      = das.getSpan();
    pos        = extSpan.start;
    // insertLen  = extSpan.getLength();
    fullrateStop  = Math.min( extSpan.stop, fullScale.editGetSpan( ce ).stop );
    fullrateLen    = fullrateStop - extSpan.start;
    progWeight    = 1.0 / fullrateLen;
//    numFullBuf    = (int) (fullrateLen >> MAXSHIFT);
    numFullBuf    = (int) ((fullrateLen - fftSize + stepSize + stepSize - 1) / stepSize);
//    numFullBuf    = (int) ((fullrateLen + stepSize - 1) / stepSize);

    synchronized( bufSync ) {
      flushProgression();
      createBuffers();

      for( int i = 0; i < numFullBuf; i++ ) {
        len = (int) Math.min( nextLen, fullrateStop - pos );
        tag2 = new Span( pos, pos + len );
//        fullScale.readFrames( tmpBuf, 0, tag2, ce );
        fullScale.readFrames( tmpBuf, fftSize - nextLen, tag2, null );
        if( len < nextLen ) {
          for( int ch = 0; ch < fullChannels; ch++ ) {
            for( int j = (inBufOff + len) % tmpBufSize, k = nextLen - len; k >= 0; k-- ) {
View Full Code Here

  {
    if( !Thread.holdsLock( fileSync )) throw new IllegalMonitorStateException();

    final long floorStart  = span.start / stepSize * stepSize; // & MAXMASK;
    final long ceilStop    = (span.stop + stepSize - 1) / stepSize * stepSize; // (span.stop + MAXCEILADD) & MAXMASK;
    final Span extSpan    = (floorStart == span.start) && (ceilStop == span.stop) ?
                  span : new Span( floorStart, ceilStop );
    final Span[] fileSpans  = new Span[ SUBNUM ];
    final Span[] biasedSpans = new Span[ SUBNUM ];
    long fileStart;
    long fileStop;

//System.out.println( "allocAsync( " + span + " ) --> " + extSpan );
   
    if( tempFAsync == null ) {
      // XXX THIS IS THE PLACE TO OPEN WAVEFORM CACHE FILE
      tempFAsync = createTempFiles();
    }
    synchronized( tempFAsync ) {
      for( int i = 0; i < SUBNUM; i++ ) {
        fileStart    = tempFAsync[ i ].getFrameNum();
        fileStop    = fileStart + (extSpan.getLength() >> decimHelps[ i ].shift);
        tempFAsync[ i ].setFrameNum( fileStop );
        fileSpans[ i = new Span( fileStart, fileStop );
//System.out.println( "... fileSpan =  " + fileSpans[ i ] + " ( i = " + i + "; shift = " + decimHelps[ i ].shift + " )" );
        biasedSpans[ i ] = extSpan;
      }
    }
    return new DecimatedStake( extSpan, tempFAsync, fileSpans, biasedSpans, decimHelps );
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.