Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: new wave provider based on I/O pipelines #1158

Open
wldevries opened this issue May 22, 2024 · 0 comments
Open

Proposal: new wave provider based on I/O pipelines #1158

wldevries opened this issue May 22, 2024 · 0 comments

Comments

@wldevries
Copy link

wldevries commented May 22, 2024

All current building blocks of NAudio are built on or inspired by Stream and it's interface. There are several advantages of using a more modern approach, which is why I propose building blocks based on I/O pipelines.

public interface IWavePipeProvider
{
    WaveFormat Format { get; }
    PipeReader Reader { get; }
}

One advantage that spoke to me is that PipeWriter allows you to push data through. This allowed me to easily build a theremin like block with mouse input without having to worry about buffers. Backpressure is provided by pausing the writer on calls to its FlushAsync. Other advantage are better explained on the documentation page linked above that the API of pipelines or in its announcement blog post

Interoperability with current IWaveProvider can be achieved by converting PipeReader to a Stream. Ideally this would be an extension method similar to ToWaveProvider and ToSampleProvider.

WavePipeProvider generator = new();
RawSourceWaveStream waveStream = new(generator.Reader.AsStream(), generator.Format);

Similarly Channels could be a good fit as a modern variant of ISampleProvider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant