How to play 16-bit pcm array programmatically [closed]

不打扰是莪最后的温柔 提交于 2019-12-13 15:26:58

问题


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


回答1:


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/



来源:https://stackoverflow.com/questions/20310571/how-to-play-16-bit-pcm-array-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!