예제 #1
0
        private void ReduceBitsPerSample24Mash2(ConvertParams args, DataSubChunk toDsc)
        {
            var mash = new NoiseShaperMash[mFsc.numChannels];

            for (int ch = 0; ch < mFsc.numChannels; ++ch)
            {
                mash[ch] = new NoiseShaperMash(args.newQuantizationBitrate);
            }

            int bytesPerFrame = mFsc.numChannels * mFsc.bitsPerSample / 8;
            int numFrames     = toDsc.data.Length / bytesPerFrame;

            int readPos  = 0;
            int writePos = 0;

            // 1サンプル遅延するので…。
            for (int i = 0; i < numFrames + 1; ++i)
            {
                for (int ch = 0; ch < mFsc.numChannels; ++ch)
                {
                    int sample = 0;

                    if (i < numFrames)
                    {
                        sample   = mash[ch].Filter24(ReadSampleValue24(toDsc, readPos));
                        readPos += mFsc.bitsPerSample / 8;
                    }
                    else
                    {
                        sample = mash[ch].Filter24(0);
                    }

                    if (1 <= i)
                    {
                        WriteSampleValue24(toDsc, writePos, sample);
                        writePos += mFsc.bitsPerSample / 8;
                    }
                }
            }
        }
예제 #2
0
        private void ReduceBitsPerSample24Mash2(ConvertParams args, DataSubChunk toDsc)
        {
            var mash = new NoiseShaperMash[mFsc.numChannels];
            for (int ch=0; ch < mFsc.numChannels; ++ch) {
                mash[ch] = new NoiseShaperMash(args.newQuantizationBitrate);
            }

            int bytesPerFrame = mFsc.numChannels * mFsc.bitsPerSample / 8;
            int numFrames = toDsc.data.Length / bytesPerFrame;

            int readPos = 0;
            int writePos = 0;

            // 1サンプル遅延するので…。
            for (int i=0; i < numFrames + 1; ++i) {
                for (int ch=0; ch < mFsc.numChannels; ++ch) {
                    int sample = 0;

                    if (i < numFrames) {
                        sample = mash[ch].Filter24(ReadSampleValue24(toDsc, readPos));
                        readPos += mFsc.bitsPerSample / 8;
                    } else {
                        sample = mash[ch].Filter24(0);
                    }

                    if (1 <= i) {
                        WriteSampleValue24(toDsc, writePos, sample);
                        writePos += mFsc.bitsPerSample / 8;
                    }
                }
            }
        }