如何在C ++中将32位浮点数组写入.wav? [英] How to write 32-bit float array to .wav in C++?

查看:157
本文介绍了如何在C ++中将32位浮点数组写入.wav?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个mp3文件(立体声,44100赫兹)我用mpg123解码并得到一个32位浮点数组。现在我想把这个数组写成.wav文件并播放它。



我尝试过:



我在Java中找到了几个解决方案,但他们都使用了Java库中的工具

So I have an mp3 file (stereo, 44100 Hz) which I decoded with mpg123 and got a 32-bit float array. Now I want to write this array to .wav file and play it.

What I have tried:

I found several solutions in Java but they all used the tools from Java libraries

推荐答案

你必须理解 wave文件格式指定来编写数据。



但首先你必须知道你的float数组在wav文件中写入数据的参数。首先写一些样板信息,而不是RIFF和fmt块,其中包含附加声音数据的正确数据。



如果您遇到问题,请联系 mpg123 伙计们。
You must understand the wave file format specifikations to write the data.

But at first you must know which parameters your float array has to write the data in the wav file. First write some boilerplate information and than the RIFF and fmt chunk with correct data for the appended sound data.

If you have problem than you better contact some developers from the mpg123 folks.


这篇关于如何在C ++中将32位浮点数组写入.wav?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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