MIDI player/synthesizer library for the iPhone - iphone

Does anyone know if there is a free/cheap MIDI player/synthesizer library that I can incorporate into my iPhone application?
As I understand it the iPhone doesn't have native support for MIDI playback.
To work around this limitation I've created a bank of .caf sound samples that I playback myself but I'd really like to improve the implementation and use MIDI if possible.
Any advice would be greatly appreciated.

Since 10 october of 2011, that is since iOS5, Apple has started delivering basic API for midi files playback. The API is called MusicPlayer along with MusicSequence Check this out :
https://developer.apple.com/library/ios/#documentation/AudioToolbox/Reference/MusicPlayerServices_Reference/Reference/reference.html#//apple_ref/doc/uid/TP40009301-CH1-SW1
By setting up an appropriate Audio Unit Processing Graph you can output the sound you like.

Look at TiMidity++; it looks like something that should be portable to the iPhone platform.
TiMidity++ is a software synthesizer. It can play MIDI files by converting
them into PCM waveform data; give it a
MIDI data along with digital
instrument data files, then it
synthesizes them in real-time, and
plays. It can not only play sounds,
but also can save the generated
waveforms into hard disks as various
audio file formats. TiMidity++ is a
free software, distributed under the
terms of GNU general public license.
Many people have ported TiMidity++ into various platforms; FreeBSD,
NetBSD, many Linux distributions,
Windows (and/or Cygwin environment),
and Mac OS are known to have their own
versions.

There is a commercial library available from Crimson Technology
Crimson Technology Library
I have never used it so I can't vouch for it's quality.

This is a library I've used for MIDI synthesis in Android:
https://code.google.com/p/android-midi-lib/
Although it can't be used for iOS, I think you(and anyone who's interested) can still take a look at the implementation of the MIDI file format(i.e. how bytes are written to a .mid file) and possibly implement a MIDI library yourself.

Related

Sound Effect Library/Extension for OpenAL (running on iOS)?

I want to do some DSP effect processing, create effect like flanger, echo, etc.
Could it be done via OpenAL? Or should I use enterely different framework/library?
Since iOS 5.0 some of the DSP effects are natively supported by OpenAL.
For example, reverb is supported with emulation for more than 10 different spaces (Small/Medium/Large Room, Medium/Large Hall, Plate, Medium/Large Chamber, Cathedral and several variations).
You can find a good reference implementation in the ObjectAL wrapper. The repository is available at https://github.com/kstenerud/ObjectAL-for-iPhone
Grab the source from this repository, load "ObjectAL.xcodeproj" and run the ObjectALDemo target on any iOS 5.0 device (should also work on the simulator). This will give you a good starting point and feeling of what the reverb effect is capable of. I personally recommend taking advantage of the ObjectAL library instead of working with OpenAL directly.
Good luck with your project!
Just write your own audio library. iOS devices don't have hardware acceleration for OpenAL. It isnt particularly difficult to do, and then you can also use apples audio units (some of which are hardware accelerated).

Converting Videos for iPhone/iPad (mp4)

I know this isn't quite a programming question but it's very closely related to iPhone/iPad development.
What's a good software (preferably with a GUI) for converting videos to iPhone/iPad compatible mp4s? My videos are mostly mpg, avi, mov.
Handbrake will do a great job, its free, its open source, and it is on Windows, Linux, and Macintosh.
I know it takes file inputs from any source on Windows (I'm not sure on Mac, but I'm pretty sure its the same on Mac).
Handbrake is my favorite tool for this job. Free and Multiplatform.
Integrates with all of the appropriate preset for iPhone / iPod / iPhone 4
Just for note: I use ffmpeg library to convert all my media. Yes, it doesn't have UI but it supports probably almost all the video/audio formats you need + it's very easy to use it with scripts when you want to convert a big amount of media.

Simple embeddable MidiSynth for iOS?

I have a guitar diagram app for Android that I am porting to iOS. Android has a embedded midi synthesizer (sonivox), so I can generate midi files and let Android handle the playback.
Is there a way to do this on iOS? Or are there very lightweight embeddable synths for iOS?
Since iOS 5 there's now the AUSampler audio unit for which you can load a sound bank (apple preset and soundfonts) and then control the sampler/synth via MIDI messages.
Seee this example app:
https://developer.apple.com/library/ios/#samplecode/LoadPresetDemo/Listings/ReadMe_txt.html
It works great!
Update: My answer is out-of-dated. #lukebuehler's answer is much appropriate.
If you don't mind non-opensource solution, try FMOD. Being a commercial audio engine for games, fmod equips a simple MIDI synth. I've tried the free evaluation version. It plays GM MIDI files correctly on my iPhone 3G.
If what you want is not just a SMF file player, you want a full function GS/GM softsynth, which can response individual midi events in realtime. You can try the midisynth from CrimsonTech. Its license fee is fair. Crimsontech provides several demo apps in the appstore. Besides, it also provides an evaluation SDK for free. You don't need to pay a penny for the license until you're really going to publish your app.
I don't think MIDI support in iOS 4.2 allows playback of MIDI data from the phone itself. It is merely for sending and receiving MIDI commands to other MIDI devices.
From the recent iOS 4.2 docs, it seems that you can use the MIDI support to send MIDI commands to other devices for playback. You can also receive commands from other devices and make changes to these commands, or to save it in a file. However I can't find any support to actually play MIDI file from the phone directly. Someone please correct me if I'm wrong (I wish I'm wrong!!).
There is MIDI support in iOS 4.2. If it is the same as what OS X provides then trhere will also be a basic synth included. Check it out.

Audio/video file formats that support embedded markers and comments/annotations?

I am looking at creating an app for OS X and/or iOS that allows the user to arbitrarily embed markers into the audio at various intervals during the audio recording process. It would be nice to have a single file that could contain this information, but may or may not be efficient or feasible. I suppose it is similar to what YouTube annotations allows.
Requirements:
Ability to insert markers at certain time points of an audio recording
Ability to save a name for the marker as well as a brief description
This is for audio created by the app I'm working on, so is not for importing audio from other sources for markup.
-- snip --
EDIT: Maybe MP4 + XMP?
EDIT2: Has anyone tried using custom XMP fields with Audio or Video on the iOS platform? On the Mac platform? I have downloaded the XMP Toolkit from Adobe (which has an Xcode project) - but it is a touch out of my comfort zone. From a high level it appears pretty straightforward, but anyone with experience with the XMP Toolkit have any thoughts?
As is suggested in an answer below, does anyone have experience with alternative solutions such as QuickTime with chapter markers? Pros and Cons to various approaches?
After thinking about it, it would be nice to do something that supports both audio and video formats, even if initially the current requirement is audio only.
EDIT3 (cleanup):
So, just to close the loop here. I ended up digging into the iOS 4.0 APIs for AVAsset, AVMetadataItem, et al in the AV Foundation Framework. Still have not completed the project, but it appears these APIs will satisfy the requirement without the need for an external library.
have you read up on the CAF format?
basically, it functions as a wrapper for many audio formats, and allows you to embed all sorts of data (as well as user defined data). it may be an option since interchange is not an issue (in your case).
The CAF File Specification
You might consider MPEG-4 or QuickTime formats with a chapter track.

Lossy compressed format to raw PCM on iPhone

I want to start with an audio file of a modest filesize, and finish with an array of unsigned chars that can be loaded into OpenAL with alBufferData. My trouble is the steps that happen in the middle.
I thought AAC would be the way to go, but according to Apple representative Rincewind (circa 12/08):
Currently hardware assisted compression formats are not supported for decode on iPhone OS. These formats are AAC, MP3 and ALAC.
Using ExtAudioFile with a client format set generates PERM errors, so he's not making things up.
So, brave knowledge-havers, what are my options here? Package the app with .wav's and just suck up having a massive download? Write my own decoder?
Any links to resources or advice you might have would be greatly appreciated.
Offline rendering of compressed audio is now possible, see QA1562.
While Vorbis and the others suggested are good, they can be fairly slow on the iPhone as there is no hardware acceleration.
One codec that is natively supported (but has only a 4:1 compression ratio) is ADPCM, aka ima4. It's handled through the ExtAudioFile interface and is only the tiniest bit slower than loading .wav's directly.
There are some good open source audio decoding libraries that you could use:
mpg123
FAAC
Both are licensed under LGPL, meaning you can use them in closed source applications provided modifications to the library, if any, are open sourced.
You could always make your wave files mono and hence cut your wave file size in half. But that might not be the best alternative for you
Another option for doing your own decoding would be Ogg Vorbis. There's even a low-memory version of their library for integer processors called "Tremor".