English 中文(简体)
How to analyze the BPM of AAC file or any library for converting AAC to MP3
原标题:

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.

问题回答

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
");
        return 0;
    }

    if (NeAACDecInit(decoder, (unsigned char *)aacData, aacBytes, &sampleRate, &channels) < 0)
    {
        printf("unable to init
");
        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





相关问题
Audio format for stream recording: FLV or mp4?

I m capturing microphone (speech) input and publishing it on a flash server. I want this content to eventually be able to be streamed on iPhones as well as in the browser, so I m wondering if I should ...

AAC header and other info in iPhone

I m building an iPhone Application that records sound. I make use of Audio Queue Services, and everything works great for the recording. The thing is, I m using AudioFileWritePackets for file ...

Can t correctly stream x264 video to mobile via RTSP

I m creating mobile version of YouTube-like website. And i m going to use Darwin Streaming Server for streaming low-res clips compressed with x264 and NeroAAC and hinted with MP4Box. When i m playing ...

How to develop an AAC converter for Linux?

I am a beginner developer want to develop a MP3 to AAC converter for Linux. But I don t know how to start as I havn t done any development in Linux before. I am using Ubuntu 10.04. Can anyone tell me ...

Flash/Flex: play embedded AAC audio?

Is it possible to play an embedded AAC file in Flash/Flex somehow? I know you can playback embedded MP3 files, but I hear that you can t do that with AAC. Anyone know any sneaky ways to get around ...

Encode audio to aac with libavcodec

I m using libavcodec (latest git as of 3/3/10) to encode raw pcm to aac (libfaac support enabled). I do this by calling avcodec_encode_audio repeatedly with codec_context->frame_size samples each ...

read or write ratings from AAC file

I m trying to figure out how to read the "ratings" from an AAC file on Windows 7. This data is somehow persisted in the file as the Windows 7 shell and WMP can read / write the ratings. In MP3 the ...

热门标签