Re: of timestamps & midi packets
Re: of timestamps & midi packets
- Subject: Re: of timestamps & midi packets
- From: Philippe Wicker <email@hidden>
- Date: Thu, 31 Jul 2003 21:59:29 +0200
On Thursday, July 31, 2003, at 08:28 PM, Roy Lovejoy wrote:
>
thanks for the informative response..
>
>
On Thursday, July 31, 2003, at 11:06 AM, Philippe Wicker wrote:
>
>
> To determine the actual value of this clock tick call
>
> AudioGetHostClockFrequency().
>
>
>
>
would anyone happen to have a snippet of source that would convert the
>
time values found in a .mid file to MIDITimeStamp, handy?
What do you mean by "time values found in .mid file"? Do you want to do
your own parsing of a MIDI file and find the clock ticks? If this is
what you want, I don't have any code. But if you want to know the time
and duration of a midi event in a track extracted from a MIDI file you
should use the API defined in MusicPlayer.h. To walkthrough the tracks
of a MIDI sequence you can use following code (C++ style, tests of
returned code removed when not needed for the walkthrough itself):
OSStatus status ;
MusicSequence my_sequence;
NewMusicSequence(&my_sequence);
MusicSequenceLoadSMF(my_sequence, <an FSSpec* to your .mid file> );
UInt32 number_of_tracks = 0;
MusicSequenceGetTrackCount(my_sequence, &number_of_tracks);
for (UInt32 i=0; i<number_of_tracks; i++) {
MusicSequenceGetIndTrack(the_sequence, index, &the_track);
int event_count = 0 ;
MusicEventIterator the_iterator ;
status = NewMusicEventIterator(the_track, &the_iterator) ;
status = MusicEventIteratorSeek(the_iterator, 0) ;
while (1) {
// Here use following API ...
MusicEventIteratorGetEventInfo (the_iterator, <out parameters: time,
type, data,...>) ;
// ... and you have event time. To get more information about the
event, cast data using
// the type returned by MusicEventIteratorGetEventInfo.
if (status == noErr)
event_count++ ;
else if (status == -10857) {
printf ("end of track at event count %d\n", event_count) ;
break ;
}
else {
printf ("unexpected error %d at event count %d\n", status,
event_count) ;
break ;
}
MusicEventIteratorNextEvent(the_iterator) ;
}
status = DisposeMusicEventIterator(the_iterator) ;
}
>
_______________________________________________
>
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.
>
>
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.