Ejemplo n.º 1
0
        public void AdpcmSampleCountIsCorrectAfterLooping(int sampleCount, bool looping, int loopStart, int loopEnd)
        {
            IAudioFormat adpcm = GenerateAudio.GenerateAdpcmEmpty(sampleCount, 1, 48000)
                                 .WithLoop(looping, loopStart, loopEnd);

            Assert.Equal(sampleCount, adpcm.SampleCount);
        }
Ejemplo n.º 2
0
        public void AdpcmDataLengthIsCorrectAfterLooping(int sampleCount, bool looping, int loopStart, int loopEnd)
        {
            GcAdpcmFormat adpcm = GenerateAudio.GenerateAdpcmEmpty(sampleCount, 1, 48000)
                                  .WithLoop(looping, loopStart, loopEnd);

            Assert.Equal(SampleCountToByteCount(sampleCount), adpcm.Channels[0].GetAdpcmAudio().Length);
        }
Ejemplo n.º 3
0
 public void Setup()
 {
     _adpcm = GenerateAudio.GenerateAdpcmEmpty((int)(_sampleRate * LengthSeconds), ChannelCount, _sampleRate);
     _brstm = new BrstmWriter().GetFile(_adpcm);
     _dsp   = new DspWriter().GetFile(_adpcm);
     _idsp  = new IdspWriter().GetFile(_adpcm);
 }
Ejemplo n.º 4
0
        public void AdpcmDataLengthIsCorrectAfterAlignment(int sampleCount, bool looping, int loopStart, int loopEnd, int alignment)
        {
            GcAdpcmFormat adpcm = GenerateAudio.GenerateAdpcmEmpty(sampleCount, 1, 48000)
                                  .WithAlignment(alignment)
                                  .WithLoop(looping, loopStart, loopEnd);

            int extraSamples = Helpers.GetNextMultiple(loopStart, alignment) - loopStart;

            Assert.Equal(SampleCountToByteCount(loopEnd + extraSamples), adpcm.Channels[0].GetAdpcmAudio().Length);
        }
Ejemplo n.º 5
0
        public void AdpcmLoopIsCorrectAfterUnalignment(int sampleCount, bool looping, int loopStart, int loopEnd, int alignment)
        {
            IAudioFormat adpcm = GenerateAudio.GenerateAdpcmEmpty(sampleCount, 1, 48000)
                                 .WithAlignment(alignment)
                                 .WithLoop(looping, loopStart, loopEnd)
                                 .WithAlignment(0);

            Assert.Equal(loopStart, adpcm.LoopStart);
            Assert.Equal(loopEnd, adpcm.LoopEnd);
        }
Ejemplo n.º 6
0
        public void LoopsProperlyAfterDecoding(int sampleCount, bool looping, int loopStart, int loopEnd)
        {
            GcAdpcmFormat adpcm = GenerateAudio.GenerateAdpcmEmpty(sampleCount, 1, 48000)
                                  .WithLoop(looping, loopStart, loopEnd);

            IAudioFormat pcm = adpcm.ToPcm16();

            Assert.Equal(looping, pcm.Looping);
            Assert.Equal(loopStart, pcm.LoopStart);
            Assert.Equal(loopEnd, pcm.LoopEnd);
        }
Ejemplo n.º 7
0
        public void AdpcmLoopIsCorrectAfterAlignment(int sampleCount, bool looping, int loopStart, int loopEnd, int alignment)
        {
            IAudioFormat adpcm = GenerateAudio.GenerateAdpcmEmpty(sampleCount, 1, 48000)
                                 .WithAlignment(alignment)
                                 .WithLoop(looping, loopStart, loopEnd);

            int extraSamples = Helpers.GetNextMultiple(loopStart, alignment) - loopStart;

            Assert.Equal(loopStart + extraSamples, adpcm.LoopStart);
            Assert.Equal(loopEnd + extraSamples, adpcm.LoopEnd);
        }
Ejemplo n.º 8
0
        public void CreateAlignmentReplacePreviousWhenLoopChanges(int multiple, int loopStart, int loopEnd)
        {
            var sampleCount = 100;

            var(adpcm, coefs) = GenerateAudio.GenerateAdpcmEmpty(sampleCount);
            var previous = new GcAdpcmAlignment(multiple, loopStart, loopEnd, adpcm, coefs);

            var builder = new GcAdpcmChannelBuilder(adpcm, coefs, sampleCount)
                          .WithLoop(true, loopStart + 1, loopEnd + 1)
                          .WithPrevious(null, null, previous);

            builder.LoopAlignmentMultiple = multiple;
            var alignment = builder.GetAlignment();

            Assert.NotEqual(previous, alignment);
        }
Ejemplo n.º 9
0
        public void CreateAlignmentWithNoPrevious(int multiple, int loopStart, int loopEnd)
        {
            var sampleCount = 100;

            var(adpcm, coefs) = GenerateAudio.GenerateAdpcmEmpty(sampleCount);

            var builder = new GcAdpcmChannelBuilder(adpcm, coefs, sampleCount)
                          .WithLoop(true, loopStart, loopEnd);

            builder.LoopAlignmentMultiple = multiple;
            var alignment = builder.GetAlignment();

            Assert.Equal(multiple, alignment.AlignmentMultiple);
            Assert.Equal(loopStart, alignment.LoopStart);
            Assert.Equal(loopEnd, alignment.LoopEnd);
        }
Ejemplo n.º 10
0
        public void CreateAlignmentWithPrevious(int multiple, int loopStart, int loopEnd)
        {
            int sampleCount = 100;

            (byte[] adpcm, short[] coefs) = GenerateAudio.GenerateAdpcmEmpty(sampleCount);
            var previous = new GcAdpcmAlignment(multiple, loopStart, loopEnd, adpcm, coefs);

            GcAdpcmChannelBuilder builder = new GcAdpcmChannelBuilder(adpcm, coefs, sampleCount)
                                            .WithLoop(true, loopStart, loopEnd)
                                            .WithPrevious(null, null, previous);

            builder.LoopAlignmentMultiple = multiple;
            GcAdpcmAlignment alignment = builder.GetAlignment();

            Assert.Equal(previous, alignment);
        }
Ejemplo n.º 11
0
        public void GetLoopContextWithPrevious(bool isSelfCalculated, bool ensureSelfCalculated)
        {
            short num         = 20;
            var   sampleCount = 100;

            var(adpcm, coefs) = GenerateAudio.GenerateAdpcmEmpty(sampleCount);
            var previous = new GcAdpcmLoopContext(num, num, num, num, isSelfCalculated);

            var builder = new GcAdpcmChannelBuilder(adpcm, coefs, sampleCount)
                          .WithLoop(true, num, sampleCount)
                          .WithPrevious(null, previous, null)
                          .PrepareForBuild();

            builder.EnsureLoopContextIsSelfCalculated = ensureSelfCalculated;
            var context = builder.GetLoopContext();

            Assert.Equal(previous, context);
        }
Ejemplo n.º 12
0
        public void CreateLoopContextWithNoPrevious(short predScale, short hist1, short hist2, int loopStart, bool isSelfCalculated)
        {
            var sampleCount = 100;

            var(adpcm, coefs) = GenerateAudio.GenerateAdpcmEmpty(sampleCount);

            var builder = new GcAdpcmChannelBuilder(adpcm, coefs, sampleCount)
                          .WithLoop(true, loopStart, sampleCount)
                          .WithLoopContext(loopStart, predScale, hist1, hist2, isSelfCalculated);

            builder.AlignedLoopStart = loopStart;

            var context = builder.GetLoopContext();

            Assert.Equal(predScale, context.PredScale);
            Assert.Equal(hist1, context.Hist1);
            Assert.Equal(hist2, context.Hist2);
            Assert.Equal(loopStart, context.LoopStart);
            Assert.Equal(isSelfCalculated, context.IsSelfCalculated);
        }
Ejemplo n.º 13
0
        public void GetLoopContextReplacePrevious(short expected, int loopStart, bool isSelfCalculated, bool ensureSelfCalculated)
        {
            short num         = 20;
            short numLarge    = 25;
            var   sampleCount = 100;

            var(adpcm, coefs) = GenerateAudio.GenerateAdpcmEmpty(sampleCount);
            var previous = new GcAdpcmLoopContext(num, num, num, num, isSelfCalculated);

            var builder = new GcAdpcmChannelBuilder(adpcm, coefs, sampleCount)
                          .WithPrevious(null, previous, null)
                          .WithLoop(true, loopStart, sampleCount)
                          .WithLoopContext(numLarge, numLarge, numLarge, numLarge, isSelfCalculated)
                          .PrepareForBuild();

            builder.EnsureLoopContextIsSelfCalculated = ensureSelfCalculated;
            var context = builder.GetLoopContext();

            Assert.Equal(expected, context.PredScale);
            Assert.Equal(expected, context.Hist1);
            Assert.Equal(expected, context.Hist2);
            Assert.Equal(loopStart, context.LoopStart);
        }
Ejemplo n.º 14
0
 public void Setup()
 {
     _adpcmStream = GenerateAudio.GenerateAdpcmEmpty((int)(_sampleRate * LengthSeconds), 1, _sampleRate);
 }