在.net中播放音频/ C# [英] Playing Audio in .Net / C#

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

问题描述

我多年的一个经验丰富的程序员MFC,谁更近几年一直在发展目标C为Mac和iOS应用程序的商业 - 我试图让与.NET和C#来加速(如我M很快将被要求将我的商业应用程序之一,从Mac到PC)。

I'm an experienced MFC programmer of many years, who for the more recent years has been developing commercial apps in Objective C for Mac and iOS - I'm trying to get up to speed with .Net and C# (as I'm soon going to be required to convert one of my commercial apps from Mac to PC).

我现在已经工作我的方式,通过一对夫妇的书籍,作为一个练习获得更多熟悉的.Net(和C#)我已经决定要一展身手的转换我没有商业应用之一为净一个学习锻炼和一切都进展顺利(接口工作,数据结构都不错),但我需要能够播放音频。

I've now worked my way through a couple of books and as an exercise to get more familiar with .Net (and C#) I've decided to have a go at converting one of my none commercial apps to .Net as a learning exercise and all is going well (interface is working, data structures all good) but I need to be able to play audio.

我的Mac应用程序产生的一系列数学公式的音频 - 想象一个波发生器​​ - 不太一样,但相似。在Mac我产生16位带符号的原始音频的音频,使用核心音频设置音频输出路由,然后得到时是必需的音频路由(这样我就可以动态生成音频)音频的一个新的缓冲区回调

My Mac app generates audio from a series of mathematical formula - imagine a wave generator - not quite the same but similar. On the Mac I generate the audio as 16 bit signed raw audio, use Core Audio to setup audio output routing and then get a callback whenever a new buffer of audio is required for the audio routing (so I can generate the audio on the fly).

我需要做同样的在PC上。不幸的是我找到MSDN文档成为不能见树不见林为有文档这样的大量案例。我能找到的类,可以让我加载和播放MP3 / WAV等文件,但我需要生成音频实时。任何人都可以点我在正确的方向找到的东西,因为它扮演他们,会让我充满动态缓冲区?

I need to do the same on the PC. Unfortunately I find MSDN documentation to be a case of "Can't see the wood for the trees" as there is such a vast amount of documentation. I can find classes that will let me load and play mp3/wav etc files, but I need to generate the audio realtime. Can anyone point me in the right direction to find something that will allow me to fill buffers on the fly as it plays them?

THX

推荐答案

我用的中的良好效果的几个项目这个样本。它基本上是一个.NET包装为的Windows波形音频API 使用的P / Invoke
其他选择:

I have used this sample in several projects with good results. It is basically a .Net wrapper for Windows Waveform Audio API using P/Invoke. Other choices:

  • NAudio
  • Sound Player class from .Net framework

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

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