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

New Post: WaveFormat.CreateCustomFormat() cannot be accessed with an instance reference

$
0
0
I'm a bit confused as to why this is happening..

I need to create a custom WaveFormat due to AAC SBR samplerate doubling, but I'm getting the compile error below. It doesn't tell me which parameter is in question. Instead of parsing "goodframe" vars I've created local int's but still no luck.

Member 'NAudio.Wave.WaveFormat.CreateCustomFormat(NAudio.Wave.WaveFormatEncoding, int, int, int, int, int)' cannot be accessed with an instance reference; qualify it with a type name instead (CS0176)
private void InitializeADTSStream()
{
            ....
            ....
            int blockAlign = goodFrame.ChannelsOutput * (16 / 8);
            int sampleRate = goodFrame.SampleRateOutput;
            int channels = goodFrame.ChannelsOutput;
            int avgBytes = sampleRate * blockAlign;

            // WaveFormat outputWaveFormat is a global variable in the class
            outputWaveFormat = WaveFormat.CreateCustomFormat(WaveFormatEncoding.Pcm, sampleRate, channels, avgBytes, blockAlign, 16);
}
Removing "outputWaveFormat = " before "WaveFormat.CreateCustomFormat" makes no difference.

NAudio source:
        public static WaveFormat CreateCustomFormat(WaveFormatEncoding tag, int sampleRate, int channels, int averageBytesPerSecond, int blockAlign, int bitsPerSample)
        {
            WaveFormat waveFormat = new WaveFormat();
            waveFormat.waveFormatTag = tag;
            waveFormat.channels = (short)channels;
            waveFormat.sampleRate = sampleRate;
            waveFormat.averageBytesPerSecond = averageBytesPerSecond;
            waveFormat.blockAlign = (short)blockAlign;
            waveFormat.bitsPerSample = (short)bitsPerSample;
            waveFormat.extraSize = 0;
            return waveFormat;
        }

Viewing all articles
Browse latest Browse all 5831

Trending Articles



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