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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public void Setup() { _adpcmStream = GenerateAudio.GenerateAdpcmEmpty((int)(_sampleRate * LengthSeconds), 1, _sampleRate); }