Re: How to get a MIDIPacket into a MusicTrack
Re: How to get a MIDIPacket into a MusicTrack
- Subject: Re: How to get a MIDIPacket into a MusicTrack
- From: Doug Wyatt <email@hidden>
- Date: Mon, 6 Feb 2006 09:53:58 -0800
On Feb 5, 2006, at 23:38, Peter Stewart wrote:
Hi,
I am writing a simple program so I can quickly play some notes on
my keyboard and save them to a file, just a way to learn CoreMIDI..
I am wondering if there is a simple way to "pipe" a MIDIEndpointRef
into a MusicTrack, or an easy way to add each MIDIPacket to a
MusicTrack. Do I have to "parse" each MIDIPacket and turn it into a
MIDINoteMessage, MIDIChannelMessage, etc. Or is there a simpler
way? Originally I was adding them all as MIDIRawData (thinking
"well its raw data coming in, this should take raw data going out")
but that is for Sysex messages..
You're correct, you need to parse the packets and create the events
explicitly.
Also my MIDI files all seem to end up being 4:11:xx long, what am I
doing wrong here? Is it a timestamp thing? I am converting
MIDITimeStamp to MusicTimeStamp, using AudioConvertHostTimeToNanos
(), I am not sure if this is correct though as I don't really know
what MusicTimeStamp is measured in.
From MusicPlayer.h:
// A MusicSequence contains an arbitrary number of tracks (MusicTrack)
// each of which contains time-stamped (in units of beats)
If you are recording new tracks while the music player is playing,
and you are sure to call this while playing, you could call:
extern OSStatus
MusicPlayerGetBeatsForHostTime( MusicPlayer inPlayer,
UInt64 inHostTime,
MusicTimeStamp *outBeats)
since a MIDITimeStamp is a host time.
Doug
--
Doug Wyatt
Core Audio, Apple
_______________________________________________
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