1

我正在尝试加载 MP3 和 HRTF 文件(wav),然后通过卷积产生另一个输出音频信号,但我有点卡住如何做到这一点。

sound1 = new Sound;
sound1.addEventListener (Event.COMPLETE, completeHandler);
sound1.load (new URLRequest ("test.mp3"));
channel1 = sound1.play (0, int.MAX_VALUE);

function completeHandler (event:Event):void 
  {  bytes1 = new ByteArray; 
     samples1 = new <Number> []; 
     fft1 = new FFT;
     addEventListener (Event.ENTER_FRAME, enterFrameHandler);
  }

function enterFrameHandler (event:Event):void 
  {  // get bytes of 512 samples
     bytes1.position = 0;
     sound1.extract (bytes, 1024, channel1.position * 44.1);
     // get samples of left or right channel
     bytes1.position = 0;
     while (bytes1.bytesAvailable > 0) 
       {  samples1 [int (bytes1.position / 8)] = bytes1.readFloat (); bytes1.readFloat();
       }

     // analyze samples1
     fft1.analyze (samples1);
     var limitHz:Number = 5000;
     var i:int=0;
     var n1:int = fft1.magnitudes.length * limitHz / (44100 / 2);

     // And then here I should somehow multiply the signal1*signal2?
     for (i = 0; i < n1; i++) 
       {  var sound1Mag:int = fft1.magnitudes [i];
          var sound2Mag:int = fft2.magnitudes [i];

        //......?????

       }
  }

任何帮助都感激不尽。

好的,我编辑提到第二个文件不是 wav 而是 MP3(我将 wav 转换为 MP3)

4

0 回答 0