• 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
Terrible MIDI timing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Terrible MIDI timing


  • Subject: Terrible MIDI timing
  • From: Jeremy Jurksztowicz <email@hidden>
  • Date: Sun, 18 May 2003 18:42:06 -0400

Hello,

I was playing about with CoreAudio, when I discovered the MusicPlayer facilities. I was quite glad to find this, as
I was writing a (simple) step sequencer at the time. Since I was not using the Audio Unit framework, but had my
own output system I decided to send MIDI messages to a virtual endpoint. All my code does is send MIDIRawData
messages to my virtual endpoint MIDIReadProc, which calls a step function, which increments a step variable,
sees if any "sound events" are at that step, and triggers them. However I found that the timing was very odd. At what
appears to be random increments, the timing will go off. After playing around a bit I discovered that I could increase
the frequency of these errors simply by dragging the Project Builder window around fast. So of course I assumed
that I was doing too much In the callback procedure, and replaced all my code with a simple SysBeep(30). This should
be called every beat at 120 BPM. But still the timing was off. What am I doing wrong? Below is some code illustrating
my problem.

// Setup code goes off without a hitch...

Float64 timeMultiple = 0.25;
for(unsigned int i = 0; i < 64; i ++)
{
// This is our dummy raw data variable.
MIDIRawData data;
data.length = 1;

GoodOSStatusOrThrow(MusicTrackNewMIDIRawDataEvent(_musicTrack,i*timeMult iple,&data),
"Unable to add Raw MIDI Event to track.", HERE);
}

// And make sure that the track loops forever.
struct {MusicTimeStamp loopLength; long numberOfLoops;} loopInfo = {16,0};
GoodOSStatusOrThrow(MusicTrackSetProperty(_musicTrack,kSequenceTrackProp erty_LoopInfo,&loopInfo,0),
"Error setting looping properties.", HERE);

// ...

void StepSequence::virtualEndpointProc(const MIDIPacketList *pktList, void *readProcRefCon, void *srcConnRefCon)
{
// Note that the virtual endpoint is set to receive MIDI events at their scheduled time, and does not have to do
// it's own scheduling... I think...?
static int i = 0;
if(++i % 4 == 0) { SysBeep(30); i = 0; }

// This code called my somewhat complicated step method...
//StepSequence * seq = reinterpret_cast<StepSequence*>(readProcRefCon);
//seq->step();
}

Thank You for any help/advice...
Jeremy Jurksztowicz
_______________________________________________
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.

  • Follow-Ups:
    • Re: Terrible MIDI timing
      • From: Kurt Revis <email@hidden>
  • Prev by Date: Re: AudioDeviceRead vs captureInputIOProc (in sample app Daisy)
  • Next by Date: hosting AudioUnit v2 from java
  • Previous by thread: Re: AudioUnit full name
  • Next by thread: Re: Terrible MIDI timing
  • Index(es):
    • Date
    • Thread