• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MusicSequencerUserCallback - calling objective-c method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MusicSequencerUserCallback - calling objective-c method


  • Subject: Re: MusicSequencerUserCallback - calling objective-c method
  • From: Simone Tellini <email@hidden>
  • Date: Wed, 8 Dec 2010 22:03:46 +0100

Il giorno 08/dic/2010, alle ore 21.57, GW Rodriguez ha scritto:

> So I was putting together a basic app that needs to use the user event, ergo it needs to use the callback function.  I would like to have the callback function call a obj-c method, but I cant seem to do this.  I even tried changed the file to .mm and all I get are errors.
>
> Can someone bestow their experience and knowledge on my as to how to call a obj-c method in a c++ function?
>

use something like this:

void MyCallback( void *clientData, MusicSequence sequence, MusicTrack track,
                                 MusicTimeStamp eventTime, const MusicEventUserData *eventData,
                                 MusicTimeStamp startSliceBeat, MusicTimeStamp endSliceBeat )
{
        MyObjCClass		*myObj = reinterpret_cast< MyObjCClass *>( clientData );
	const MyEventData     *event = reinterpret_cast<const MyEventData *>( eventData );

        [myObj doSomethingWithMyEventData: event];
}

Then set it up with:

	MusicSequenceSetUserCallback( sequence, MyCallback, myObj );

where myObj is an instance of MyObjCClass

Remember to use -performSelectorOnMainThread:withObject:waitUntilDone: to execute anything that has to do with UI stuff, or that needs to be run in the main thread for any reason, because the callback is executed in a background thread.

--
Simone Tellini
http://www.tellini.org



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >MusicSequencerUserCallback - calling objective-c method (From: GW Rodriguez <email@hidden>)

  • Prev by Date: Re: MusicSequencerUserCallback - calling objective-c method
  • Next by Date: Re: kAudioFilePropertyAudioDataPacketCount Broken for WAV files in iOS 4.2(.1)?
  • Previous by thread: Re: MusicSequencerUserCallback - calling objective-c method
  • Next by thread: RE: MusicSequencerUserCallback - calling objective-c method
  • Index(es):
    • Date
    • Thread