Пример #1
0
        private int _sequence = 3; // compressed audio packets start after the headers with sequence number 3

        private ProcessingState(
            VorbisInfo vorbisInfo,
            LookupCollection lookups,
            float[][] pcm,
            int[] window,
            int centerWindow)
        {
            _vorbisInfo   = vorbisInfo;
            _lookups      = lookups;
            _pcm          = pcm;
            _window       = window;
            _centerWindow = centerWindow;
        }
Пример #2
0
        public static ProcessingState Create(VorbisInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            var codecSetup = info.CodecSetup;

            // initialize the storage vectors. blocksize[1] is small for encode, but the correct size for decode
            var pcmStorage = codecSetup.BlockSizes[1];

            var pcm = new float[info.Channels][];

            for (var i = 0; i < pcm.Length; i++)
            {
                pcm[i] = new float[pcmStorage];
            }

            // Vorbis I uses only window type 0
            var window = new int[2];

            window[0] = Encoding.Log(codecSetup.BlockSizes[0]) - 7;
            window[1] = Encoding.Log(codecSetup.BlockSizes[1]) - 7;

            var centerWindow = codecSetup.BlockSizes[1] / 2;

            var lookups = LookupCollection.Create(info);

            return(new ProcessingState(
                       info,
                       lookups,
                       pcm,
                       window,
                       centerWindow));
        }