Examples of AudioFile


Examples of com.life.audiotageditor.model.AudioFile

    }
    AudioView audioView = (AudioView) window.getActivePage().findView(
        AudioView.ID);
    AudioModel audioModel = (AudioModel) AudioModelManager.instance()
        .getRoot();
    AudioFile audioFile = (AudioFile) audioModel.getFile(StringUtil
        .formatPath(path));
    audioView.getTreeViewer().setInput(audioFile);
    audioView.getTreeViewer().setSelection(
        new StructuredSelection(audioFile), true);
    return null;
View Full Code Here

Examples of com.life.audiotageditor.model.AudioFile

  @Override
  public String getColumnText(Object element, int columnIndex) {
    // TODO
    if (element instanceof AudioFile) {
      AudioFile audioFile = (AudioFile) element;
      AudioTag audioTag = ((AudioFileInfo) (audioFile)
          .getAudioModelInfo()).getAudioTag();
      switch (columnIndex) {
      case 0:
        return audioFile.getName();
      case 1:
        return audioTag.getTitle();
      case 2:
        return audioTag.getArtist();
      case 3:
View Full Code Here

Examples of com.life.audiotageditor.model.AudioFile

        tableItem = (TableItem) element;
      }
      if (null == tableItem) {
        return;
      }
      AudioFile data = (AudioFile) tableItem.getData();
      if (data instanceof AudioFile) {
        AudioTag audioTag = ((AudioFileInfo) (data).getAudioModelInfo())
            .getAudioTag();
        if (value.equals(ReflectUtil.getProperty(audioTag, property))) {
          return;
        }
        ReflectUtil.setProperty(audioTag, property, value.toString());
        AudioFileUtil.saveAudioFile(data.getFullPath(), audioTag);
        tableViewer.refresh();
      }
    }
View Full Code Here

Examples of de.sciss.io.AudioFile

  protected InterleavedStreamFile createTempFile( int numChannels, double rate )
  throws IOException
  {
    final AudioFileDescr afd = new AudioFileDescr();
    AudioFile af;
   
    afd.type      = AudioFileDescr.TYPE_AIFF;
    afd.channels    = numChannels;
    afd.rate      = rate;
    afd.bitsPerSample  = 32;
View Full Code Here

Examples of de.sciss.io.AudioFile

  }

  public static Session newFrom( File path, boolean createTransport, boolean createOSC )
  throws IOException
  {
    final AudioFile      af  = AudioFile.openAsRead( path );
    final AudioFileDescr  afd  = af.getDescr();
    Session          doc  = null;
    AudioTrail        at  = null;
   
    try {
// System.err.println( "readMarkers" );
      af.readMarkers();
      at          = AudioTrail.newFrom( af );
      doc          = new Session( afd, createOSC );
      doc.setAudioTrail( null, at );
//      if( createOSC ) doc.createOSC();
      if( createTransport ) doc.createTransport();
//      if( createDecimated ) {
//        doc.createDecimatedWaveTrail();
//        doc.createDecimatedSonaTrail();
//      }
      return doc;
    }
    catch( IOException e1 ) {
//      if( doc != null ) {
//        doc.dispose();
//      } else
      if( at != null ) {
        at.dispose();
      } else {
        af.cleanUp();
      }
      throw e1;
    }
  }
View Full Code Here

Examples of de.sciss.io.AudioFile

  public void oscCmd_replace( RoutedOSCMessage rom )
  {
    final RenderPlugIn  plugIn;
    final String    fileName;
    final long      startFrame;
    AudioFile      af    = null;
    int          argIdx  = 1;
    FilterDialog    filterDlg;
 
    try {
      fileName  = rom.msg.getArg( argIdx ).toString();
      argIdx++;
      if( argIdx < rom.msg.getArgCount() ) {
        startFrame  = ((Number) rom.msg.getArg( argIdx )).longValue();
      } else {
        startFrame  = 0;
      }
      af      = AudioFile.openAsRead( new File( fileName ));
      af.seekFrame( startFrame );
      plugIn    = new Replace( af );
    }
    catch( IndexOutOfBoundsException e1 ) {
      OSCRoot.failedArgCount( rom );
      return;
    }
    catch( ClassCastException e1 ) {
      OSCRoot.failedArgType( rom, argIdx );
      return;
    }
    catch( IOException e1 ) {
      if( af != null ) af.cleanUp();
      OSCRoot.failed( rom, e1 );
      return;
    }
   
    filterDlg = (FilterDialog) AbstractApplication.getApplication().getComponent( Main.COMP_FILTER );
View Full Code Here

Examples of de.sciss.io.AudioFile

    final Object[]      fileFrmtArgs  = new Object[ 5 ];
    final MessageFormat    fileFormat    = new MessageFormat( "{0}{1}{2}_R0195_T{3}_P{4}.wav", Locale.US );
    final NumberFormat    numFormat    = NumberFormat.getInstance( Locale.US );
    File          inputDir, outputDir, inputFile, outputFile;
    int            aziDeg, elevDeg;
    AudioFile        inF        = null;
    AudioFile        outF      = null;
    AudioFileDescr      inDescr, outDescr;
    File[]          fileArgs    = (File[]) context.getClientArg( "files" );

    final int progLen = 24 * 7;
    int progOff = 0;
    boolean success = false;

    try {
      numFormat.setMinimumIntegerDigits( 3 );
      numFormat.setMaximumIntegerDigits( 3 );
      numFormat.setMinimumFractionDigits( 0 );
      numFormat.setMaximumFractionDigits( 0 );
      fileFormat.setFormatByArgumentIndex( 3, numFormat );
      fileFormat.setFormatByArgumentIndex( 4, numFormat );
     
      inputDir    = fileArgs[0];
      outputDir    = fileArgs[1];
      fileFrmtArgs[0= inputDir.getAbsolutePath();
      fileFrmtArgs[1= File.separator;
      fileFrmtArgs[2= inputDir.getName();
     
      try {
        for( int azi = 0; azi < 24; azi++ ) {
          for( int elev = 0; elev < 7; elev++ ) {
            aziDeg      = ((azi + 12) * 15) % 360;
            elevDeg      = elev <= 3 ? (45 - elev * 15) : (405 - elev * 15);
            fileFrmtArgs[3= new Integer( aziDeg );
            fileFrmtArgs[4= new Integer( elevDeg );
            inputFile    = new File( fileFormat.format( fileFrmtArgs ));

            System.err.println( "Reading '"+inputFile.getName()+"' ..." );
            inF          = AudioFile.openAsRead( inputFile );
            inDescr        = inF.getDescr();
            if( inDescr.channels != 2 ) throw new IOException( "Wrong channel num. Needs to be 2, but is "+inDescr.channels );
            if( inDescr.length != 8192 ) System.err.println( "Warning, frame length should be 8192, but is "+inDescr.length );
            inF.seekFrame( IR_OFFSET );
            inF.readFrames( inBuf, 0, IR_LENGTH )// simply truncate
            inF.close();
            inF          = null;
           
            for( int ch = 0; ch < 2; ch++ ) {
              // short fade in / out
              for( int i = 1, j = 0; i < 32; i++, j++ ) {
                inBuf[ ch ][ j ] *= (float) i / 32;
              }
              for( int i = 31, j = IR_LENGTH - 32; i > 0; i--, j++ ) {
                inBuf[ ch ][ j ] *= (float) i / 32;
              }
           
              outputFile      = new File( outputDir, "hrtf" + (elev * 24 + azi) + (ch == 0 ? "l" : "r" ) + ".aif" );
              System.err.println( "Writing '"+outputFile.getName()+"' ..." );
              outDescr      = new AudioFileDescr( inDescr );
              outDescr.type    = AudioFileDescr.TYPE_AIFF;
              outDescr.channels  = 1;
              outDescr.file    = outputFile;
              outF        = AudioFile.openAsWrite( outDescr );
              outBuf[ 0 ]      = inBuf[ ch ];
              outF.writeFrames( outBuf, 0, IR_LENGTH );
              outF.close();
              outF        = null;
            }
           
            progOff++;
            context.setProgression( (float) progOff / (float) progLen );
          }
        }
        success = true;
      }
      finally {
        if( inF != null ) inF.cleanUp();
        if( outF != null ) outF.cleanUp();
      }
    }
    catch( IOException e1 ) {
      context.setException( e1 );
    }
View Full Code Here

Examples of de.sciss.io.AudioFile

      final DecimatedStake    das;
      final Span          extSpan;
      final long          fullrateStop, fullrateLen;
      final int          numFullBuf;
      final Object        enc_this  = this;
      final AudioFile        cacheReadAF;
      final AudioFile        cacheWriteAF;
 
      for( int i = 0; i < SUBNUM; i++ ) {
        this.decimHelps[ i ] = new DecimationHelp( afd.rate, decimations[ i ]);
      }
 
      synchronized( fileSync ) {
        das      = allocAsync( viewSpan );
      }
      extSpan      = das.getSpan();
 
  // XXX SWINGOSC XXX
  //    fullrateStop  = Math.min( extSpan.getStop(), fullScale.editGetSpan( ce ).stop );
      fullrateStop  = Math.min( extSpan.stop, viewSpan.stop );
      fullrateLen    = fullrateStop - extSpan.start;

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

      synchronized( bufSync ) {
        createBuffers();
      }
 
  // XXX SWINGOSC XXX   
  //    editClear( source, das.getSpan(), ce );
  //    editAdd( source, das, ce );
  decimatedStake = das;
      launched = true;
   
      threadAsync = new Thread( new Runnable() {
        public void run() {
          final int  minCoarse;
          boolean    success        = false;
          long    pos          = extSpan.getStart();
//          long    framesWrittenCache   = 0;
          boolean    cacheWriteComplete  = false;
          long    framesWritten    = 0;
          Span    tag2;
          float    f1;
          int      len, repaint    = 0;
          long    time, nextTime    = System.currentTimeMillis() + 100;
 
          minCoarse  = MAXCOARSE >> decimHelps[ 0 ].shift;

          try {
            for( int i = 0; (i < numFullBuf) && keepAsyncRunning; i++ ) {
              synchronized( bufSync ) {
                if( cacheReadAF != null ) {
                  tag2       = new Span( pos, pos + minCoarse );
                  cacheReadAF.readFrames( tmpBuf2, 0, minCoarse );
                  das.continueWrite( 0, tmpBuf2, 0, minCoarse );
                  subsampleWrite2( tmpBuf2, das, minCoarse );
                  pos        += minCoarse;
                } else {
                  tag2       = new Span( pos, pos + MAXCOARSE );
      //            fullScale.readFrames( tmpBuf, 0, tag2, ce );
                  fullScale.readFrames( tmpBuf, 0, MAXCOARSE );
//  for( int k = 0; k < tmpBuf.length; k++ ) { for( int j = 0; j < MAXCOARSE; j++ ) { tmpBuf[ k ][ j ] = 0.125f; }}
                  subsampleWrite( tmpBuf, tmpBuf2, das, MAXCOARSE, cacheWriteAF );
                  pos        += MAXCOARSE;
//                  framesWrittenCache += minCoarse;
                }
                framesWritten += MAXCOARSE;
              }
              time = System.currentTimeMillis();
              if( time >= nextTime ) {
                readProgress = (float) ((double) framesWritten / (double) fullrateLen);
                nextTime = time + 100;
                if( asyncManager != null ) asyncManager.dispatchEvent( new AsyncEvent( enc_this, AsyncEvent.UPDATE, time ));
  // XXX SWINGOSC XXX
                repaint = (repaint + 1) % 20;
                if( repaint == 0 ) {
                  needsImageUpdate = true;
                  repaint();
                }
              }
            }
 
            if( (cacheReadAF == null) && keepAsyncRunning ) { // cached files always have integer fullBufs!
              len = (int) (fullrateStop - pos);
              if( len > 0 ) {
                synchronized( bufSync ) {
                  tag2 = new Span( pos, pos + len );
    // XXX SWINGOSC XXX
    //              fullScale.readFrames( tmpBuf, 0, tag2, null );
                  if( fullScale.getFramePosition() != tag2.start ) {
                    fullScale.seekFrame( tag2.start );
                  }
                  fullScale.readFrames( tmpBuf, 0, (int) tag2.getLength() );
                  for( int ch = 0; ch < fullChannels; ch++ ) {
                    f1 = tmpBuf[ ch ][ len - 1 ];
                    for( int i = len; i < MAXCOARSE; i++ ) {
                      tmpBuf[ ch ][ i ] = f1;
                    }
                  }
                  subsampleWrite( tmpBuf, tmpBuf2, das, MAXCOARSE, cacheWriteAF );
                  pos        += MAXCOARSE;
                  framesWritten  += MAXCOARSE;
//                  framesWrittenCache += minCoarse;
                }
              }
            }
            cacheWriteComplete = true;
            if( cacheWriteAF != null ) cm.addFile( cacheWriteAF.getFile() );
            success  = true;
          }
          catch( IOException e1 ) {
  // XXX SWINGOSC XXX
  //          System.err.println( e1 );
//            System.out.println( e1 );
            e1.printStackTrace( System.out );
          }
          finally {
            if( cacheReadAF != null ) cacheReadAF.cleanUp();
            if( cacheWriteAF != null ) {
              cacheWriteAF.cleanUp();
              if( !cacheWriteComplete ) { // indicates process was aborted ...
                final File f = createCacheFileName();
                if( (cm != null) && (f != null) ) {    // ... therefore delete incomplete cache files!
                  cm.removeFile( f );
                }
View Full Code Here

Examples of de.sciss.io.AudioFile

  {
    final File      f      = createCacheFileName();
    if( f == null ) return null;
   
    final String    ourCode    = "EisK"; // AbstractApplication.getApplication().getMacOSCreator();
    AudioFile      cacheAF    = null;
    AudioFileDescr    afd;
    boolean        success    = false;
    byte[]        appCode;
    AudioFileCacheInfo  infoA, infoB;

    try {
      if( !f.isFile() ) return null;
      cacheAF      = AudioFile.openAsRead( f );
      cacheAF.readAppCode();
      afd        = cacheAF.getDescr();
      appCode      = (byte[]) afd.getProperty( AudioFileDescr.KEY_APPCODE );
      if( ourCode.equals( afd.appCode ) && (appCode != null) ) {
        infoA    = AudioFileCacheInfo.decode( appCode );
        if( infoA != null ) {
          infoB  = new AudioFileCacheInfo( fullScale, model, fullScale.getFrameNum() );
          if( !infoA.equals( infoB )) {
            return null;
          }
        }
      } else {
        return null;
      }
      success = true;
      return cacheAF;
    }
    finally {
      if( !success ) {
        if( cacheAF != null ) {
          cacheAF.cleanUp();
        }
      }
    }
  }
View Full Code Here

Examples of entagged.audioformats.AudioFile

        if (this.audioPane == null) {
            this.audioPane = new JScrollPane();
            DefaultListModel audioModel = new DefaultListModel();
            Iterator it = this.audioFiles.iterator();
            while (it.hasNext()) {
                AudioFile current = (AudioFile) it.next();
                audioModel.addElement(current.getName() + " "
                        + getLength(current.getLength()));
            }
            JList list = new JList(audioModel);
            list.setEnabled(false);
            list.setCellRenderer(new AudioRenderer());
            audioPane.setViewportView(list);
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.