Package de.sciss.io

Examples of de.sciss.io.AudioFileDescr


  protected AudioFile[] createTempFiles()
  throws IOException
  {
    // simply use an AIFC file with float format as temp file
    final AudioFileDescr proto  = new AudioFileDescr();
    final AudioFile[] tempFiles  = new AudioFile[ SUBNUM ];
    AudioFileDescr afd;
    proto.type          = AudioFileDescr.TYPE_AIFF;
    proto.channels        = decimChannels;
    proto.bitsPerSample      = 32;
    proto.sampleFormat      = AudioFileDescr.FORMAT_FLOAT;
    // proto.bitsPerSample = 8;
    // proto.sampleFormat = AudioFileDescr.FORMAT_INT;
    try {
      for( int i = 0; i < SUBNUM; i++ ) {
        afd        = new AudioFileDescr( proto );
        afd.file    = IOUtil.createTempFile();
        afd.rate    = decimHelps[ i ].rate;
        tempFiles[ i = AudioFile.openAsWrite( afd );
      }
      return tempFiles;
View Full Code Here


 
    InterleavedStreamFile  iff;
    float[][]        frameBuf  = new float[ 1 ][];
    File          dir      = new File( (File) options.get(
                        XMLRepresentation.KEY_BASEPATH ), SUBDIR );
    AudioFileDescr      afd;
   
    if( !dir.isDirectory() ) IOUtil.createEmptyDirectory( dir );
   
    afd          = new AudioFileDescr();
    afd.type      = AudioFileDescr.TYPE_AIFF;
    afd.channels    = 1;
    afd.rate      = 1000.0f// XXX
    afd.bitsPerSample  = 32;
    afd.sampleFormat  = AudioFileDescr.FORMAT_FLOAT;
    afd.file      = new File( dir, getName() + SUFFIX_DISTANCE );
    iff          = AudioFile.openAsWrite( afd );
           
    frameBuf[ 0 ]    = distanceTable;
    iff.writeFrames( frameBuf, 0, distanceTable.length );
    iff.truncate();
    iff.close();

    afd          = new AudioFileDescr( afd );
    afd.file      = new File( dir, getName() + SUFFIX_ROTATION );
    iff          = AudioFile.openAsWrite( afd );
     
    frameBuf[ 0 ]    = rotationTable;
    iff.writeFrames( frameBuf, 0, rotationTable.length );
View Full Code Here

  throws IOException
  {
    int        trnsIdx;
    RenderInfo    info  = new RenderInfo();
    boolean      success = false;
    AudioFileDescr  afd    = new AudioFileDescr();
    AudioFileDescr  afd2;
   
    context.moduleMap.put( KEY_RENDERINFO, info );
    info.outLength    = context.getTimeSpan().getLength();
    info.progLen    = info.outLength << 1;    // arbit.
    info.progOff    = 0;
   
    // request all trajectories and
    // create temporary files for them
    afd.type      = AudioFileDescr.TYPE_AIFF;
    afd.channels    = 2;
    afd.rate      = context.getSourceRate();
    afd.bitsPerSample  = 32;
    afd.sampleFormat  = AudioFileDescr.FORMAT_FLOAT;

    try {
      info.tempFiles = new File[ source.numTrns ];
      info.iffs    = new InterleavedStreamFile[ source.numTrns ];
      for( trnsIdx = 0; trnsIdx < source.numTrns; trnsIdx++ ) {
        info.tempFiles[ trnsIdx = IOUtil.createTempFile();
        afd2            = new AudioFileDescr( afd );
        afd2.file          = info.tempFiles[ trnsIdx ];
        info.iffs[ trnsIdx ]    = AudioFile.openAsWrite( afd2 );
        source.trajRequest[ trnsIdx ] = true;
      }
      success = true;
View Full Code Here

  throws IOException
  {
    int          trnsIdx, i, j, blockBufSize;
    RenderInfo      info    = (RenderInfo) context.moduleMap.get( KEY_RENDERINFO );
    Number        num;
    AudioFileDescr    afd;
    long        startPos;
    boolean        success    = false;
 
    try {
      // ---------- Consumer part ----------
View Full Code Here

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

    int        trnsIdx, i;
    RenderInfo    info  = new RenderInfo();
    ConsumerContext consc;
    boolean      success = false;
    Object      o;
    AudioFileDescr  afd    = new AudioFileDescr();
    AudioFileDescr  afd2;

    mainHost        = (RenderHost) context.getHost();
   
    context.moduleMap.put( KEY_RENDERINFO, info );
    info.outLength      = context.getTimeSpan().getLength();
    info.progLen      = info.outLength << 1;    // arbit.
    info.progOff      = 0;
    info.apply[ 0 ]      = ggApplyX.isSelected();
    info.apply[ 1 ]      = ggApplyY.isSelected();
    o            = ggMode.getSelectedItem();
    info.polar        = o instanceof StringItem ?
                  ((StringItem) o).getKey().equals( modes[ MODE_POLAR ].getKey() ) : false;
//    info.polar        &&= info.applyX || info.applyY; // if both are bypassed no need to convert

//    if( info.polar ) {
      info.centerX    = ggCenterX.getNumber().floatValue();
      info.centerY    = ggCenterY.getNumber().floatValue();
//    }
    info.convBuf      = new float[ source.numTrns ][];

    // requests
    for( trnsIdx = 0; trnsIdx < source.numTrns; trnsIdx++ ) {
      source.trajRequest[ trnsIdx ]   = true;
    }
    info.source      = new RenderSource( source.numTrns, source.numRcv );
    afd.type      = AudioFileDescr.TYPE_AIFF;
    afd.channels    = source.numTrns;
    afd.rate      = context.getSourceRate();
    afd.bitsPerSample  = 32;
    afd.sampleFormat  = AudioFileDescr.FORMAT_FLOAT;
   
    for( i = 0; i < 2; i++ ) {
      info.contexts[ i = new RenderContext( this, context.getReceivers(),
                    context.getTransmitters(), context.getTimeSpan(),
                    context.getSourceRate() );
      info.contexts[ i ].setOption( RenderContext.KEY_CONSUMER, this );
      info.tempFiles[ i ] = IOUtil.createTempFile();
      afd2        = new AudioFileDescr( afd );
      afd2.file      = info.tempFiles[ i ];
      info.iffs[ i ]    = AudioFile.openAsWrite( afd2 );
      consc        = new ConsumerContext();
      consc.iff      = info.iffs[ i ];
      consc.convBuf    = info.convBuf;
View Full Code Here

  private AudioFile[] createTempFiles()
    throws IOException
  {
    // simply use an AIFC file with float format as temp file
    final AudioFileDescr proto  = new AudioFileDescr();
    final AudioFile[] tempF    = new AudioFile[ SUBNUM ];
    AudioFileDescr afd;
    proto.type          = AudioFileDescr.TYPE_AIFF;
    proto.channels        = decimChannels;
    proto.bitsPerSample      = 32;
    proto.sampleFormat      = AudioFileDescr.FORMAT_FLOAT;
    try {
      for( int i = 0; i < SUBNUM; i++ ) {
        afd            = new AudioFileDescr( proto );
        afd.file        = File.createTempFile( "swing", null, null );
        afd.file.deleteOnExit();
        afd.rate        = decimHelps[ i ].rate;
        tempF[ i ]        = AudioFile.openAsWrite( afd );
      }
View Full Code Here

      freeBuffers();
      freeTempFiles();
     
      fullScale            = AudioFile.openAsRead( new File( path ));
      deleteFullScale          = deleteWhenDisposed;
      final AudioFileDescr  afd    = fullScale.getDescr();
     
      fullChannels  = afd.channels;
      decimChannels  = fullChannels * modelChannels;
      startFrame    = Math.max( 0, Math.min( afd.length, startFrame ));
      numFrames    = Math.max( 0, Math.min( afd.length - startFrame, numFrames ));
View Full Code Here

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

  throws IOException
  {
    final File          f      = createCacheFileName();
    if( f == null ) return null;

    final AudioFileDescr    afd      = new AudioFileDescr();
    final String        ourCode    = "EisK"; // AbstractApplication.getApplication().getMacOSCreator();
    final AudioFileCacheInfo  info;

    afd.type      = AudioFileDescr.TYPE_AIFF;
    afd.bitsPerSample  = 32;
    afd.sampleFormat  = AudioFileDescr.FORMAT_FLOAT;
    afd.rate      = decimHelps[ 0 ].rate; // getRate();
    afd.appCode      = ourCode;

    cm.removeFile( f );    // in case it existed
    afd.channels    = fullScale.getChannelNum() * modelChannels;
    afd.file      = f;
    info        = new AudioFileCacheInfo( fullScale, model, fullScale.getFrameNum() );
    afd.setProperty( AudioFileDescr.KEY_APPCODE, info.encode() );
    return AudioFile.openAsWrite( afd );
  }
View Full Code Here

TOP

Related Classes of de.sciss.io.AudioFileDescr

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.