Register a new Audio Format

Hello,

my problem is the following:
i want to register a new AudioFormat(mp3&aac) but i don’t know how.

i tried it with these lines of code:

1 AudioFormat* mp3 = new AudioFormat(T(“MP3”),T(".mp3"));
2 AudioFormat* aac = new AudioFormat(T(“AAC”),T(".aac"));

3 AudioFormatManager formatManager_mp3;
4 formatManager_mp3.registerFormat (mp3,false);
5 formatManager_mp3.registerFormat (aac,false);

but the compiler answers with “cannot allocate an object of type juce::AudioFormat” in the first 2 lines

AudioFormat is defined as:
AudioFormat::AudioFormat (const String & formatName, const tchar **const fileExtensions) [protected]

can anybody help me?

Thanx

You need to write your own format handlers for theese types (juce does not support mp3 nor aac out of the box)

have a look here http://www.rawmaterialsoftware.com/juceforum/viewtopic.php?t=2522

AudioFormat is an abstract base class. You’re not supposed to be trying to create instances of it directly.

You need to use a sub-class, either from JUCE, or one you’ve made yourself.

For AAC and MP3, I think you’ll need to roll your own.

http://www.rawmaterialsoftware.com/juce/api/index.html

(edit : atom already answered).

Actually, you don’t need to roll your own.
You can use the QuickTimeAudioFormat.
Still it requires to have QuickTime to be installed.

Jules, what about updating
http://www.rawmaterialsoftware.com/juce/api/index.html
with 1.46 version ?
I think QuickTimeAudioFormat is here since 1.46 but is not present on the online API.

[quote=“otristan”]Actually, you don’t need to roll your own.
You can use the QuickTimeAudioFormat.
Still it requires to have QuickTime to be installed.

Jules, what about updating
http://www.rawmaterialsoftware.com/juce/api/index.html
with 1.46 version ?
I think QuickTimeAudioFormat is here since 1.46 but is not present on the online API.[/quote]

That’s a good point!

I personally strive to avoid external dependencies like the plague, as easy deployment makes my working life bearable. As such, I always turn off QuickTime, and consequently tend not to give it any thought when it might actually be useful. :slight_smile:

Now that I see the post is in the Linux forum, I wonder if QT works on Linux…

well, there is something around… http://libquicktime.sourceforge.net/

but i think that will support .mov files only

thanx for your suggestions!!