CoreAudio questions

5 posts / 0 new
Last post
bensmiley
CoreAudio questions

Post your CoreAudio questions here. I'll do my best to answer any questions I can.

nghiamas (not verified)

Hi BenSmiley
My name Nghia 23 year old, i am newbie of ios i want to create app karaoke play and highlight text .Your tutorial MidiTest is very useful for me but i dont know how to show lyric and highlight text when playing midi if can please help me.Thank you so much.

bensmiley

I'm working on a tutorial which will explain how to do this. Follow me on Twitter to get a notification of when it's ready.

John (not verified)

I would very much like to see the smallest number of lines of code necessary to play audio. For now, I just need the basic defaults:

My data consists of nothing but MIDI numbers (pitches). In other words - I'm not playing from a loaded file;
The objective-C code should be for iOS 6.0 (latest) for the iPad;
We can skip pan, volume, etc. Sound timbre could be just a General MIDI Piano (patch 1) for now.

Can someone help me out.

This is how I learn - baby steps. If I can see this code without any frills, I can slowly expand upon it.

Thanks in advance!

bensmiley

If you want to play a midi note I'm afraid that you're going to have to get to grips with Audio Units. At the most basic level you would setup a simple AUGraph. This would contain a Sampler unit connected to an IO Unit. The sampler unit is responsible for converting the midi message into an audio signal. The IO Unit sends this signal to the speakers.

After that you would need to add a sound font to the Sampler unit. The sound font contains instructions on how to convert a midi signal into the sound for a particular instrument. Once you've done this you're ready to play your midi note.

To play the note you need to use the following command to play the note:

  1. MusicDeviceMIDIEvent (sampler, midiStatus, note, velocity, 0);

I would recommend reading the my midi animation tutorial. It might seem like a lot to go through but you can ignore anything to do with playing midi files or setting up the virtual endpoint. Just focus on the code for the Audio Graph. Once the audio graph is working use the command above to play a note through the sampler.

Hope this helps!

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.