Re: MusicEventIteratorGetEventInfo void **outEventData
Re: MusicEventIteratorGetEventInfo void **outEventData
- Subject: Re: MusicEventIteratorGetEventInfo void **outEventData
- From: Philippe Wicker <email@hidden>
- Date: Tue, 4 Nov 2003 22:27:08 +0100
On Tuesday, November 4, 2003, at 09:27 PM, Craig Bakalian wrote:
Cast the info.data pointer to the pointer type indicated by the field
info.type. I've inserted in your code a skeleton of a switch statement
which does this. All types are defined in <AudioToolbox/MusicPlayer.h>.
>
Hi,
>
I am actually making a midi sequencer in objective C and Cocoa!
>
There is a problem, how does one get the data out of the pointer to a
>
point in the MusicEventIteratorGetEventInfo. Here is my objective C
>
code. I need to get at the data of the MidiEventInfo structure which
>
is wrapped in an objective C object called MidiEvent. I don't know
>
how to dereference the pointer to the pointer. I can access the
>
info.stamp and info.type and info.size.
>
>
>
#import <Foundation/Foundation.h>
>
#import <CoreMIDI/MIDIServices.h>
>
#import <AudioToolbox/AudioToolbox.h>
>
>
typedef struct
>
{
>
MusicTimeStamp stamp;
>
MusicEventType type;
>
UInt32 size;
>
void* data;
>
} MidiEventInfo;
>
>
@interface MidiEvent : NSObject
>
{
>
MidiEventInfo info;
>
}
>
-(id)initWithMidiEvent: (MidiEventInfo)val;
>
-(MidiEventInfo)info;
>
>
@end
>
>
-(NSArray *)getMidiEventsForTrack: (MusicTrack) track
>
{
>
MusicEventIterator events;
>
NewMusicEventIterator(track, &events);
>
Boolean b;
>
NSMutableArray *eventArray = [NSMutableArray array];
>
MusicEventIteratorHasNextEvent(events, &b);
>
while(b)
>
{
>
MidiEventInfo info;
>
MusicEventIteratorGetEventInfo(events, &info.stamp,
>
&info.type, (const void **) &info.data, &info.size);
switch (info.type) {
case kMusicEventType_ExtendedNote : {
ExtendedNoteOnEvent* ext_note_evt =
(ExtendedNoteOnEvent*)info.data;
// Do whatever you need with the event pointer
}
break ;
case kMusicEventType_ExtendedControl : {
ExtendedControlEvent* ext_control_evt =
(ExtendedControlEvent*)info.data;
// Do whatever you need with the event pointer
}
break ;
case kMusicEventType_ExtendedTempo : {
ExtendedTempoEvent* ext_tempo_evt =
(ExtendedTempoEvent*)info.data;
// Do whatever you need with the event pointer
}
break ;
case kMusicEventType_User : {
MusicEventUserData* user_evt = (MusicEventUserData*)info.data;
// Do whatever you need with the event pointer
}
break ;
case kMusicEventType_Meta : {
MIDIMetaEvent* meta_evt = (MIDIMetaEvent*)info.data;
// Do whatever you need with the event pointer
}
break ;
case kMusicEventType_MIDINoteMessage : {
MIDINoteMessage* note_evt = (MIDINoteMessage*)info.data;
// Do whatever you need with the event pointer
}
break ;
case kMusicEventType_MIDIChannelMessage : {
MIDIChannelMessage* channel_evt =
(MIDIChannelMessage*)info.data;
// Do whatever you need with the event pointer
}
break ;
case kMusicEventType_MIDIRawData : {
MIDIRawData* raw_data_evt = (MIDIRawData*)info.data;
// Do whatever you need with the event pointer
}
break ;
case kMusicEventType_Parameter : {
ParameterEvent* parameter_evt = (ParameterEvent*)info.data;
// Do whatever you need with the event pointer
}
break ;
default :
// Ooops, something went wrong !!!
break ;
}
>
MidiEvent *me = [[[MidiEvent alloc] initWithMidiEvent: info]
>
autorelease];
>
[eventArray addObject: me];
>
MusicEventIteratorHasNextEvent(events, &b);
>
MusicEventIteratorNextEvent(events);
>
}
>
return eventArray;
>
}
>
Craig Bakalian
>
www.eThinkingCap.com
Philippe Wicker
email@hidden
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.