如何写浮点值数组音频文件中的Core Audio? [英] How to write array of float values to audio file in Core Audio?

查看:422
本文介绍了如何写浮点值数组音频文件中的Core Audio?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现使用核心音频线性卷积,我有算法实现和工作,但我想,它的输出写入到一个.wav音频文件。这里是code的算法...

I am trying to implement linear convolution using Core Audio, I have the algorithm implemented and working, but I am trying to write the output of this into a .wav audio file. Here is the code for the algorithm...

    //Create array containing output of convolution (size of array1 + array2 - 1)
float *COutput;

COutput = (float *)malloc(((size1+size2)-1)* sizeof(float));

int sizeOutput = ((size1 + size2)-1);


//Convolution Algorithm!!!

for (i=0; i<sizeOutput; i++) {

    COutput[i]=0;

    for (j=0; j<sizeCArray1; j++) {

        if (((i-j)+1) > 0) {
            COutput[i] += CArray1[i - j] * CArray2[j];
        }

    }

}

我需要在COutput可以浮点值(一个标准数组彩车)写入的音频文件。我是正确的假设,我需要这些浮点值的AudioBufferList内开始发送到AudioBuffer?或者是有这样做的一个简单的方法?

I need to write the float values within COutput (a standard array of floats) into an audio file. Am I right in assuming I need to send these float values to an AudioBuffer within an AudioBufferList initially? Or is there a simple way of doing this?

任何帮助或指导非常感谢!

Many thanks for any help or guidance!

推荐答案

免费DiracLE时间伸缩库(的http://狄拉克.dspdimension.com )具有实用性code可以转换ABLS(AudioBufferLists)成浮点阵列和反之亦然为榜样code的一部分。看看他们EAFRead和EAFWrite类,他们是你在寻找什么。

The free DiracLE time stretching library ( http://dirac.dspdimension.com ) has utility code that converts ABLs (AudioBufferLists) into float arrays and vice-versa as part of their example code. Check out their EAFRead and EAFWrite classes, they're exactly what you're looking for.

这篇关于如何写浮点值数组音频文件中的Core Audio?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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