Converting or exporting audio files - objective-c

I am looking for a way to convert or export an audio file that would be either in MP3 or M4A format, to any of the following file formats: WMA, MP3, AIF, or OGG. I am aware of PCM, which is a CAF File, but Unity does not support this file. I cannot use AFConvert or anything similar with the iOS SDK in Xcode.

You should definitely use CoreAudio. Especially the ExtFileReader C API. Apple has sample codes for an offline conversion example on how to use this. (Can't post the link, because it is behind authentication.)

Here try this link if you haven't:-
http://developer.apple.com/library/ios/#samplecode/iPhoneExtAudioFileConvertTest/Listings/ExtAudioFileConvert_cpp.html
It has a C++ class to perform audio conversion. A good look at the project will help you in understanding the concepts to some extent.
you can also refer to this PDF:
http://izotope.fileburst.com/guides/iZotope_iOS_Audio_Programming_Guide.pdf
The rough idea is that you need to understand the basics of each file format and set the various audio properties to save PCM or LPCM in to a specific format. For mp3 you do not get an encoder from apple but only a decoder as per my knowledge. But AAC or WAV formats can b used easily for the same purpose. for MP3 Lame encoder and decoder can be used but im not sure how to use it.
I hope it will help you achieve what u want.

Related

Compile pbtxt into binarypb

I'm playing around with Mediapipe and I'm trying to better understand how the graph works and what is the input/output of the different calculators.
If I understand correctly, the .pbtxt files are just plain-text instructions that describe how each calculator should interact with the rest of the calculators. These files are compiled into .binarypb files, which are fed to Mediapipe.
For example, this .pbtxt file got compiled into this .binarypb file.
I have a few questions:
I saw https://viz.mediapipe.dev/ , which seems to be Mediapipe's playground. That playground seems to be compiling the text in the textarea on the right. If that is correct, how does it do it? Is there any documentation I can read about it? How are .pbtxt compiled into .binarypb?
I'm especially interested in the web capabilities of mediapipe and I'd like to create a small POC using both face-mesh and depth-to-iris features. Unfortunately, there isn't a "solution" for the second one, but there is a demo in Mediapipe's viz claiming depth-to-iris web support (the demo doesn't seem to be working correctly though). If I were able to create a .pbtxt with a pipeline containing the features that I'm interested into, how would I ¿compile? the .wasm and .data files required to deploy the code to the web?

using assimp_cmd to dump fbx model file and render

I want to parse the FBX model files with assimp, firstly, I need to generate some *.json which including the whole FBX model file information, and then rendering it through webGL in browser.
So far, I know we can dump the information of a fbx file, it will generate a .assxml or a *.assbin, it seems that the generated file inlucding all the information of a FBX model file. I wonder if it's possible that I can converting the *.assxml or *.assbin to *.json as above mentioned.
Please check https://github.com/assimp/assimp2json to solve this. There are plans to integrate this into assimp, but time is a really critical resource. So help is welcome :-).
Kim

Normalize Audio File obj-c

Is there a library function to normalize a sound file? I have searched around but could not find any.
I would like to be able to normalize a sound file and setting that into the sound file so it only needs to be done once rather than on the fly.
Can this be done with Core-Audio?
Yes it can be done, but not with a single function call.
The functionality you want is not in fact CoreAudio, but rather in ExtendedAudioFile.h - part of the AudioToolbox framework. This is available for both iOS and MacOSX. I can attest for this being rather hard to find.
Functions of interest in this header are ExtAudioFileOpenURL(), ExtAudioFileRead() and ExtAudioFileWrite().
In outline what you do:
Use ExtAudioFileOpenURL() to open the input file
Use ExtAudioFileGetProperty() with propertyId kExtAudioFileProperty_FileDataFormat to obtain an AudioStreamBasicDescription describing the file.
Possibly set the ASBD to get the format you want. AudioToolBox on MacOSX seems rather more amenable to this than on iOS.
Calculate an allocate a buffer large enough to hold the entire audio file
Read the entire file with ExtAudioFileRead() - NB: this call might not read it all in one go - operating in much the same was as POSIX read()
Perform normalisation
Use ExtAudioFileCreateWithURL() to create the output file
Use ExtAudioFileWrite() to write the normalised samples out.
Dispose of both audio files.
The documentation links to several example projects that can act as donors of working code. You'll find doing normalisation much easier with the samples as floats, but in iOS, I could never get the conversion to work automatically, so you might have to format convert yourself.

uploading a compiled program to a C51 microcontroller

I'm trying to upload a compiled program to a microcontroller.. well my problem is not in programming or uploading things.. my problem is what to upload u.u
The program is in C and was compiled with SDCC.
The mcu is an AT89S8252 by ATMEL.
I built a simple parallel port programmer following MCU protocols for serial programming as stated in its datasheet.
So far so good.. but.. what shoud I upload to the mcu??
when compiling, SDCC generates a lot of text reports.. and then an .ihx.. I suspect I should not upload this file directly but post-process it in some way to get the actual raw bytes to upload??
any help will be highly appreciated =)
Is the .ihx file an Intel hex format file by any chance ? If it is you don't have too much more work to do before you can put your programmer to work. Intel hex format is just a specialized text format. Google Intel hex format to find what it looks like. There's a page on Wikipedia for example. Compare that to your .ihx file. If you get a match you should be able to find something to convert it to a raw binary format, ready to push down to your MCU. If you can't, you should be able to write something to do the job in an hour or so, it's very simple. I could possibly email you a tool I have written previously if you are really stuck. Good luck.
Your .ihx file is an Intel hex file I reckon. That, or the similar Motorola S-record format, is usually a good format for programmer software to read. Those formats contain the data to program, as well as the address that the data should be written to. It is more useful than a binary file, which contains no address information.
What software are you using to drive the parallel programmer, and does it accept Intel hex format or Motorola S-record files? Or, do you mean you're writing your own?
You can open an Intel hex file in a text editor and make some sense of its contents. There are many references that explain the format. E.g. Intel HEX in Wikipedia.

Surefire way of determining the codec of a media file

I'm looking for a surefire way of determining the codec used in an audio or video file. The two things I am currently using are the file extension (obvious), and the mime type as determined by running `file -ib' on the file.
This doesn't seem to get me all the way there: loads of formats are `wrapper' formats that hide the exact codec used within -- for example, '.ogg' files can internally use the Vorbis, Speex, or FLAC codecs. Their MIME type is also usually hidden under 'application/ogg' or similar.
The `file' program is apparently able to tell me which codec is used, but it returns this as human-readable prose:
kb.ogg: Ogg data, Vorbis audio, stereo, 44100 Hz, ~0 bps
and as such it is dodgy to use programmatically.
What I'm essentially asking is: is there a script out there (any language) that can wade through these wrapper formats and tell me what the meat of the file is made of?
ffmpeg includes a library called libavformat that can open and demux pretty much any media format. Obviously that's more than you actually need, but I don't think you can find anything else that's quite as complete. I've used it myself with great success. Take a look at this article for an introduction. There's also bindings for these libraries for some common scripting languages, such as python.
(If you don't want to build something using the library, you can probably use the regular ffmpeg binary.)
You can always use your own magic file, copied and modified from the pre-installed magic file, and change the return string so that it can be easily parsed by your program.
See:
http://linux.die.net/man/1/file
http://linux.die.net/man/5/magic