Re: Reading midi events from device
Re: Reading midi events from device
- Subject: Re: Reading midi events from device
- From: "Jacob Ole Juul Kolding" <email@hidden>
- Date: Sun, 12 Nov 2006 14:22:25 +0100
I have implemented a program that reads events from a midi device based on Echo.cpp and the midi specs.
Now I have a problem where the callback function for reading the packages stops responding after a number of packages <50.
The number of packages recived before the callback stops is random from run to run.
The callback looks like this:
static void MyReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon)
{
while(((MidiSource*)(refCon))->processing){}
((MidiSource*)(refCon))->readingpack = true;
MIDIPacket *packet = (MIDIPacket *)pktlist->packet; // remove const (!)
for (unsigned int j = 0; j < pktlist->numPackets; ++j) {
if (packet->data[0] >= 0x80 && packet->data[0] < 0xF0){
unsigned char datapack[packet->length];
for (int i = 0; i < packet->length; ++i) {
datapack[i] = packet->data[i];
printf("X ", datapack[i]);
}
((MidiSource*)(refCon))->
packages.push_back(datapack);
}
packet = MIDIPacketNext(packet);
}
((MidiSource*)(refCon))->readingpack = false;
}
Any ideas why it stops working?
/Jacob Kolding
On 10/1/06, Kurt Revis <email@hidden> wrote:
On Sep 30, 2006, at 2:17 AM, Jacob Ole Juul Kolding wrote:
> Looking at Echo.cpp and the docs for MIDIServices was helpful.
> My question is now if there are functions for processing a midi
> packet of if that has to be done manually?
No, that part is up to you. It's not too difficult to parse MIDI
data, especially if you don't care about sysex. If you want an
example, see SMMessageParser.m in SnoizeMIDI -- specifically the
method -messagesForPacket:.
--
Kurt Revis
email@hidden
_______________________________________________
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
- Prev by Date:
kAudioOutputUnitProperty_IsRunning doesn't correspond to the audio device running When I change the default output's format (by changing from 44.1kHz to 48kHz, for example), my audio unit property listener fires with kAudioUnitProperty_StreamFormat. If I then call AudioDeviceGetCurrentTime on the corresponding audio device, I get the error kAudioHardwareNotRunningError but the kAudioOutputUnitProperty_IsRunning never fires (as a result of the device stopping). I really need to keep the time stamps returned by AudioDeviceGetCurrentTime() and those passed to my render function in sync but I'm unsure how to do that in the face of changing output formats. Actually, looking back at my logs, it looks like when the kAudioOutputUnitProperty_IsRunning fires for the first time I start the output unit, the device is still saying that it isn't running. Lastly, I'm setting kAudioOutputUnitProperty_StartTimestampsAtZero to zero but this constant doesn't appear in the 2.8 sdk s o I'm using the constant 2007, will this not work on 2.8? (I realize I asked this before in mid June, but no one answered.) If not, I need to deal with this as well. Any advice is very much appreciated. -- Steve Checkoway
- Next by Date:
Re: Reading midi events from device
- Previous by thread:
Re: kAudioOutputUnitProperty_IsRunning doesn't correspond to the audio device running
- Next by thread:
Re: Reading midi events from device
- Index(es):