播放流音频数据(C#) [英] Playing streamed audio data (C#)

查看:602
本文介绍了播放流音频数据(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C#开发可以播放流音频数据的Windows应用程序.基本上,我将有一个负责播放不同音频文件的客户端应用程序.当前,我正在从客户端应用程序中,从文件头中提取硬件配置参数,然后将通过网络流式传输文件数据(PCM流).

I an trying to develop a windows application using C# that can play streamed audio data. Basically, I will have a client application that is responsible for playing different audio files. Currently, from the client application, I am extracting the hardware config param from the file header and then will stream the file data (PCM stream) over network.

因此可以使用从客户端发送的硬件配置参数来配置实际的硬件(在服务器端),然后将文件数据流提供给它,以便它可以播放音频数据.

So is it possible to use the hardware config params sent from client to configure the actual hardware (on the server end) and then give it the file data stream to it so that it can play the audio data.

在搜索的同时,我了解了NAudio. NAudio能够做到这一点吗?对我而言,更好的选择是使用Directsound APIS切换到nativ C/C ++代码.

While searching, I got to know about NAudio. Is NAudio capable of doing this stuff or the better option for me would be to switch to nativ C/C++ code using Directsound APIS.

更新: 通过配置硬件,我的意思是设置与音频播放有关的参数.这些参数包括sample rate(例如:44100 Hz),number of channels(例如:立体声),storage format(例如:16位小尾数)等.

update: By configuring hardware, I mean setting the param related to audio playback. These param would include sample rate (eg: 44100 Hz), number of channels (eg: stereo), storage format (eg: 16 bit little endian) etc.

我的客户端应用程序在Linux上,并且我已经植入了一个ALSA驱动程序,该驱动程序可以拦截PCM流和hw_params配置,然后将它们发送到服务器.

My client application is on Linux and I have planted an ALSA driver that intercepts PCM stream and hw_params configuration and then send them to server.

更新结束

谢谢.

推荐答案

如果您查看最新NAudio代码,您将在NAudioDemo示例应用程序中看到两个播放流音频的示例.一个是基本的聊天应用程序,它通过UDP发送压缩的语音,另一个则播放流式MP3网络广播.建议您查看一下,然后尝试示例应用程序以查看它是否满足您的需求.

If you look at the latest NAudio code, you will see there are two examples in the NAudioDemo sample app that play streaming audio. One is a rudimentary chat application that sends compressed voice via UDP, the other plays streaming MP3 internet radio. I'd suggest you have a look at that and try the sample app to see if it meets your needs.

这篇关于播放流音频数据(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆