绝对初学者指南与C / C ++的音频工作吗? [英] Absolute beginners guide to working with audio in C/C++?

查看:139
本文介绍了绝对初学者指南与C / C ++的音频工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直好奇的音频转换软件,但我从来没有见过从一个初学者点适当解释如何编写一个简单的程序,一个MP3文件转换例如,为WAV。我不要求任何所涉及的复杂的算法,只是一个小例子使用一个简单的库。因此搜索,我想出了几个名字,包括:

I've always been curious about audio conversion software, but I have never seen a proper explanation from a beginners point of view as to how to write a simple program that converts for example, a mp3 file to a wav. I'm not asking about any of the complex algorithms involved, just a small example using a simple library. Searching on SO, I came up with several names including:


  • 拉梅

  • 的合成工具包

  • 的OpenAL

  • 的DirectSound

但我无法找到任何这些库的简单例子。通常我不介意通过万吨code涉水,但在这里我绝对没有对学科知识,所以我总是觉得我在黑暗中拍摄我

But I'm unable to find a straightforward example of any of these libraries. Usually I don't mind wading through tons of code, but here I have absolutely no knowledge about the subject and so I always feel like I'm shooting in the dark.

人在这里有上转换使用任何这些库的声音文件一个简单的例子/教程?我的问题是专门针对C / C ++,因为这些是两种语言,我正在学习,所以我想继续关注他们。

Anyone here have a simple example / tutorial on converting a sound file using any of these libraries? My question is specifically directed towards C/C++ because those are the two languages I'm currently learning and so I'd like to continue to focus on them.

修改:有一件事我忘了提:我是一个* NIX系统上

Edit: One thing I forgot to mention: I'm on a *NIX system.

推荐答案

感谢大家的答复!我有点拼凑在一起,以成功建立一个小工具,一个AIFF / WAV /等文件转换成MP3文件。人们似乎在这个问题上有些兴趣,所以在这里我做什么,一步一步:

Thanks everyone for the responses! I sort of cobbled them together to successfully make a small utility that converts a AIFF/WAV/etc file to an mp3 file. There seems to be some interest in this question, so here it what I did, step by step:

第1步:
下载和詹姆斯·莫里斯的建议安装 libsndfile 库。这个库非常容易使用 - 它唯一的缺点是它不能与MP3文件的工作。

Step 1: Download and install the libsndfile library as suggested by James Morris. This library is very easy to use – its only shortcoming is it won't work with mp3 files.

第二步:
看自带的libsndfile的examples文件夹中,找到generate.c。这给任何非MP3文件转换为各种文件格式的一个很好的工作的例子。这也给后面libsndfile电源的一瞥。

Step 2: Look inside the 'examples' folder that comes with libsndfile and find generate.c. This gives a nice working example of converting any non-mp3 file to various file formats. It also gives a glimpse of the power behind libsndfile.

第3步:
从generate.c借款code,我创建的只是一个音频文件转换为.wav文件C文件。这里是我的code: http://pastie.org/719546

第四步:
下载并安装 LAME EN codeR 。这将同时安装了libmp3lame库和跛命令行实用工具。

Step 4: Download and install the LAME encoder. This will install both the libmp3lame library and the lame command-line utility.

第五步:
现在,你可以仔细阅读LAME的API或者只是叉和放大器; Exec的一个过程瘸子你的WAV文件转换为MP3文件。

Step 5: Now you can peruse LAME's API or just fork & exec a process to lame to convert your wav file to an mp3 file.

第六步:衬托出香槟和鱼子酱

如果有一个更好的方法(我敢肯定有),要做到这一点,请让我知道。我个人从来没有见过一个一步一步的路线图是这样,所以我想我把它放在那里。

If there is a better way (I'm sure there is) to do this, please let me know. I personally have never seen a step-by-step roadmap like this so I thought I'd put it out there.

这篇关于绝对初学者指南与C / C ++的音频工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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