private int GenerateStereoSamples(SamplePair[] samples) { int sampleIndex = 0; while (sampleIndex < samples.Length) { //ensure that the correct block is loaded uint targetSamplePos = currentSamplePos; if (samplesLeftInBlock <= 0 && loadedBlock == strm.nBlock - 1) { if (strm.loop) { targetSamplePos = strm.loopPoint; } else { OnComplete(); return(sampleIndex); } } int targetBlock = (int)(targetSamplePos / strm.blockSamples); if (loadedBlock != targetBlock) { LoadBlock(targetBlock); } //fastforward the block if needed while (currentSamplePos < targetSamplePos) { StepSamplePos(); } //decode the samples for (; sampleIndex < samples.Length; ++sampleIndex) { if (samplesLeftInBlock <= 0) { break; } samples[sampleIndex] = new SamplePair( decoders[0].GetSample(), decoders[1].GetSample() ); StepSamplePos(); } } return(sampleIndex); }
public SamplePair GenerateSamplePair() { SamplePair samplePair = new SamplePair(); foreach (var chan in channels) { samplePair += chan.GenerateSample(); } samplePair.Left = Remap.Clamp(samplePair.Left, -0x80000, 0x7FFF); samplePair.Right = Remap.Clamp(samplePair.Right, -0x80000, 0x7FFF); return(samplePair); }