How to analyze BPM AAC file or any library to convert AAC to MP3

I am an iphone developer and am developing one Mac app now. This is my first Mac project.

I need to analyze BPM song files. I did this job for MP3 using the FMOD and SoundTouch libraries.

But I also have to parse AAC (M4A), but this library does not support AAC format.

I tried to find the library for AAC (M4A), and I did not understand anything. Thus, if we could convert this AAC file to an MP3 file programmatically in cocoa, then we could analyze the bpm of this file.

I tried to find the conversion of AAC to Mp3 in cocoa, and I got the FAAC library, but there is no documentation for integrating with cocoa and it's too complicated.

Does anyone know of any other library for analyzing BPM for AAC in a cocoa project.

Thanks a lot.

+4
source share
1 answer

How do you use SoundTouch? Do you pass sound samples to the SoundTouch library as you read them? Or do you create a soundstretch utility and transfer the sound as a file or at least a channel?

I am not familiar with SoundTouch, but it looks like it wants PCM audio as input, so you are probably already converting to PCM. If you want to transfer sound samples to SoundTouch as you receive them, you can decode using 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 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 need to link to the FAAD library

Or, if you are following the command line route, maybe something like this:

 ffmpeg -i <input_file> raw.wav 

raw.wav can then be passed to soundstretch

0
source

Source: https://habr.com/ru/post/1300731/


All Articles