With the release of iOS 4.0 the iPhone, iPad, and iPod Touch can now take advantage of the powerful MIDI protocol. For games that allow the user to generate their own sounds and music, or for a game that wants a cool retro sound without a large memory footprint, MIDI synthesization is the tool for the job. In this recipe, we will create a MIDI synthesizer using the great MobileSynth library.
Link the AudioToolbox
framework to your project. Now, execute the following code:
#import "MIDISampleGenerator.h" static const int kWhiteKeyNumbers[] = { 0, 2, 4, 5, 7, 9, 11 }; static const int kWhiteKeyCount = sizeof(kWhiteKeyNumbers) / sizeof(int); static const int kBlackKey1Numbers[] = { 1, 3 }; static const int kBlackKey1Count = sizeof(kBlackKey1Numbers) / sizeof(int); static const int kBlackKey2Numbers[] = { 6, 8, 10 }; static const int kBlackKey2Count = sizeof...