Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: Playback plays at 50% speed with AAC files

$
0
0
I'm a bit confused as to all this interface and abstract data transfer/direction.

AacFileReader.cs : WaveStream
to
MfAacFrameDecompressor.cs : MediaFoundationTransform, IAacFrameDecompressor
to
MediaFoundationResampler.cs : MediaFoundationTransform (abstract)


As far as I see it:

MediaFoundationTransform reads from the sourceProvider which is AacFileReader's ( AacFileReader's WaveStream.Read()? ), so theoretically I simply read directly from the original file stream correct?

MediaFoundationTransform reads the raw AAC file, transforms the data, and sends it back through AacFileReader's WaveStream IWaveProvider

But all I am getting is constant static as if the data sent back is just the raw aac data. I assume the data is being read twice, from the WaveOut device and also from MFTransform.

So instead what I should do is interface MfAacFrameDecompressor with IWaveProvider and supply MfAacFrameDecompressor as the sourceProvider in MFTransform as the middle man?

So confused lol. Perhaps I should just create a MediaFoundationDecoder class without IWaveProvider using the same calls as ACMDecoder to keeps things simple.


AacFileReader.cs Read():
        public override int Read(byte[] sampleBuffer, int offset, int numBytes)
        {
            
            if(isUsingMediaFoundation)
                {
                    // initially reads from position 0 at the start
                    return aacStream.Read(sampleBuffer, offset, numBytes); 
            }
                            
            // For ACM Decoder
            int bytesRead = 0;
            lock (repositionLock)
            {
                if (decompressLeftovers != 0)
                {
                     ... rest of the function as in Mp3FileReader basically unchanged

Viewing all articles
Browse latest Browse all 5831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>