如何分析 AAC 文件或任何将 AAC 转换为 MP3 的库的 BPM

发布于 2024-08-20 09:20:19 字数 396 浏览 7 评论 0原文

我是一名 iphone 开发人员,现在正在开发一款 mac 应用程序。这是我在 mac 平台上的第一个项目。

我必须分析歌曲文件的 BPM。我已经使用 FMOD 和 SoundTouch 库为 MP3 完成了这项工作。

但我还必须分析 AAC (M4A ),但该库不支持 AAC 格式。

我尝试在库中搜索 AAC(M4A),但没有找到任何内容。因此,如果我们可以在 cocoa 中以编程方式将此 AAC 文件转换为 MP3 文件,那么我们就可以分析该文件的 bpm。

我尝试在 cocoa 中搜索将 AAC 转换为 Mp3,我得到了 FAAC 库,但没有任何与 cocoa 集成的文档,而且它太复杂了。

有谁知道可可项目中用于分析 AAC 的 BPM 的任何其他库。

非常非常感谢。

I am iphone developer and developing one mac application now. This is my first project ever in mac platform.

I have to analyze the BPM of the songs files. I have done this work for MP3 using FMOD and SoundTouch library.

But i have to analyze for AAC (M4A ) also but this library doesn't support to AAC format.

I tried to search library for AAC(M4A) and i did not get any thing for that. So we if could convert this AAC file to MP3 file by programatically in cocoa then we could analyze the bpm of that file.

I tried to search for converting AAC to Mp3 in cocoa and i got FAAC library but there is no any documentation for integrating with cocoa and its too complex.

Does anyone know about any other library for analyze BPM for AAC in cocoa project.

Many Many Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁吢 2024-08-27 09:20:19

您目前使用 SoundTouch 的情况如何?您在阅读音频样本时会将其传递到 SoundTouch 库吗?或者您是否生成 soundstretch 实用程序并将音频作为文件或通过管道传递?

我不熟悉 SoundTouch,但看起来它需要 PCM 音频作为输入,因此您可能已经转换为 PCM。如果您想在收到音频样本时将其传递给 SoundTouch,您可以使用类似这样的方法使用 FAAC 进行解码

#include <stdio.h>
#include <inttypes.h>
#include <faac.h>
#include <neaacdec.h>

#define SAMPLE_SIZE 2 //2 bytes, or 16bits per samle.

int AACDecode(uint8_t *aacData, size_t aacBytes, uint32_t sampleRate, unsigned char channels)
{
    NeAACDecHandle decoder = NeAACDecOpen();
    NeAACDecConfigurationPtr config = NeAACDecGetCurrentConfiguration(decoder);
    NeAACDecFrameInfo info;
    uint8_t *decoded = NULL;
    uint8_t *readPtr = aacData;
    int consumed = 0;

    //If the AAC data is wrapped in ADTS, you don't need the next 2 lines
    //If it's not wrapped in ADTS, you need to know sampleRate, and object type
    //Object type is one of LOW, MAIN, SSR, LTP
    config->defObjectType = LOW;
    config->defSampleRate = sampleRate;
    //If SoundTouch wants it in something other than siged 16bit LE PCM, change this
    config->outputFormat = FAAD_FMT_16BIT;
    if (!NeAACDecSetConfiguration(decoder, config))
    {
        printf("unable to set config\n");
        return 0;
    }

    if (NeAACDecInit(decoder, (unsigned char *)aacData, aacBytes, &sampleRate, &channels) < 0)
    {
        printf("unable to init\n");
        return 0;
    }

    do
    {
        decoded = (char *)NeAACDecDecode(decoder, &info, readPtr, aacBytes);
        if (info.samples > 0)
        {
            size_t decodedBytes = (size_t)info.samples * SAMPLE_SIZE;
            //Pass <decodedBytes> of PCM data, pointed to by <decoded> to soundTouch
        }

        consumed += info.bytesconsumed;
        readPtr += info.bytesconsumed;
    } while (info.error == 0 && consumed < aacBytes);

    NeAACDecClose(decoder);
    return 1;
}

您需要链接到 FAAD 库

或者如果您要使用命令行路径,可能是这样的:

ffmpeg -i <input_file> raw.wav

raw.wav 然后可以传递给 soundstretch

How are you currently using SoundTouch? Do you pass audio samples to the SoundTouch library as you read them? Or do you spawn the soundstretch utility and pass the audio as a file or though a pipe?

I'm not familiar with SoundTouch, but it looks like it wants PCM audio as input, so you're probably already converting to PCM. If you wanted to pass samples of audio to SoundTouch as you receive them, you could decode with FAAC using something like this

#include <stdio.h>
#include <inttypes.h>
#include <faac.h>
#include <neaacdec.h>

#define SAMPLE_SIZE 2 //2 bytes, or 16bits per samle.

int AACDecode(uint8_t *aacData, size_t aacBytes, uint32_t sampleRate, unsigned char channels)
{
    NeAACDecHandle decoder = NeAACDecOpen();
    NeAACDecConfigurationPtr config = NeAACDecGetCurrentConfiguration(decoder);
    NeAACDecFrameInfo info;
    uint8_t *decoded = NULL;
    uint8_t *readPtr = aacData;
    int consumed = 0;

    //If the AAC data is wrapped in ADTS, you don't need the next 2 lines
    //If it's not wrapped in ADTS, you need to know sampleRate, and object type
    //Object type is one of LOW, MAIN, SSR, LTP
    config->defObjectType = LOW;
    config->defSampleRate = sampleRate;
    //If SoundTouch wants it in something other than siged 16bit LE PCM, change this
    config->outputFormat = FAAD_FMT_16BIT;
    if (!NeAACDecSetConfiguration(decoder, config))
    {
        printf("unable to set config\n");
        return 0;
    }

    if (NeAACDecInit(decoder, (unsigned char *)aacData, aacBytes, &sampleRate, &channels) < 0)
    {
        printf("unable to init\n");
        return 0;
    }

    do
    {
        decoded = (char *)NeAACDecDecode(decoder, &info, readPtr, aacBytes);
        if (info.samples > 0)
        {
            size_t decodedBytes = (size_t)info.samples * SAMPLE_SIZE;
            //Pass <decodedBytes> of PCM data, pointed to by <decoded> to soundTouch
        }

        consumed += info.bytesconsumed;
        readPtr += info.bytesconsumed;
    } while (info.error == 0 && consumed < aacBytes);

    NeAACDecClose(decoder);
    return 1;
}

You'd need to link against the FAAD library

Or if you're going the command-line route, maybe something like this:

ffmpeg -i <input_file> raw.wav

raw.wav could then be passed to soundstretch

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文