How to play 16-bit pcm array programmatically [clo

2019-07-16 16:10发布

I have a short[] array filled with 16-bit pcm values.

I want to be able to play it without adding any header, and without saving any files to my memory.

I know that I might need a class that gives parameters like bit rate and stuff like that - but I want to do it all in my program without and files.

I am working in C#.

Thanks ahead, Ofek

标签: c# audio pcm
1条回答
男人必须洒脱
2楼-- · 2019-07-16 16:39

Install CSCore through nuget. Then write all your shorts into a memorystream (you can use the binarywriter to do that). After that use the CSCore.Codecs.RAW.RawDataReader to create an audiosource from your memorystream by specifing the format (16 bit, pcm, samplerate, channelcount). After that you can use for example the CSCore.SoundOut.WasapiOut class to playback the stream. You can take a look at the little sample on codeplex (bottom of the page). http://cscore.codeplex.com/

查看更多
登录 后发表回答