naudio / NAudio

Audio and MIDI library for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repeat one ISampleProvider by FollowedBy not work expected.

toshiya14 opened this issue · comments

var sampler = this.baseclip.GetSampler();
if (sampler == null)
{
    return null;
}

var restTime = this.Duration - this.baseclip.Duration;
while (restTime > 0)
{
    if (restTime >= this.baseclip.Duration)
    {
        sampler = sampler.FollowedBy(this.baseclip.GetSampler());
    }
    else
    {
        sampler = sampler.FollowedBy(
            this.baseclip.GetSampler().Take(TimeSpan.FromSeconds(restTime))
        );
    }
    restTime -= this.baseclip.Duration;
}
return sampler;

this.baseclip.GetSampler() would returns an ISamplerProvider from AudioFileReader.
And the duration of the source audio file is 7 seconds.

After I repeated it to 600 seconds by the codes above.
Then I use MediaFoundationEncoder.EncodeToAac with sampler.ToWaveProvider().
The result file is still with the duration of 7 seconds without repeating.