Extend Advanced Audio File Services so that it can write MP3 files with lame / another codec?

I would like to use lame mp3 encoder to encode audio data on iPhone and save it to a file. I can use lame for encoding, and I can use Extended Audio File Services to record audio files. I would like to combine these two so that my code is consistent and does not use two types of code for gluing when writing audio files of different formats.

A possible solution that I can imagine is to wrap my own AudioConverter(for example, created by AudioConverterNew ) around the lame one, so that I can use this converter together with the Advanced functions of audio files , most noticeably with ExtAudioFileWrite. Can you help me implement this solution or another that allows you to write mp3 files in accordance with the API provided by iOS?

UPDATE:

After many trial errors, I am convinced that the framework AudioConverterprovided by Apple is not expanding for application developers. Therefore, I use the following work:

I created my own abstract class AudioEncoder, which declares methods for encoding audio data and writing it to a file. Then I subclassed this class AudioEncoder, one for wrapping around functions ExtAudioFileRefand one as wrapping for LAME. Now I can use these subclasses wherever I want to encode audio, but I don’t need to do this if I encode in a supported format or in a format that I added using an external library, because my encoder classes hide all API information about base encoder. If I later want to add OGG or FLAC, this will be easy because I will need to write additional subclasses AudioEncoderto wrap the corresponding OGG or FLAC library.

+4

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


All Articles