PortMIDI calls the time_proc on every call to Pm_Write() as well as to 
timestamp input. If calling Pa_GetStreamTime is too expensive, the 
alternatives are to simply update a variable with the current stream 
time on each audio callback or write. If this only happens every few 
milliseconds or even less often due to large buffers, then you could 
save (stream_time - real_time) and then estimate the current stream_time 
as (stream-time - real_time) + get_current_real_time().

-Roger

Jerzy Gangi wrote:
> Thanks Roger!
>
> I missed "time_proc is a pointer to a procedure that returns time in
> milliseconds." Cool, so that will work just fine. This function should
> return an integer, I assume, not a float because the remainder is
> negligible in MIDI-timing land.
>
> I'll have to see how often PM queries for the current time in
> milliseconds. You're not suggesting I use Pa_GetStreamTime when the
> callback happens, are you?    Wouldn't this add a substantial overhead
> to query the audio device so frequently? If this is the case then the
> PA audio callback would have nothing to do with MIDI, other than to
> give a starting command to the sequence to commence when the first
> buffer is requested. As you suggested, however, it's best to be 100%
> independent of the sample rate and buffer size for many reasons. It
> appears a callback-based timing routine would be best to avoid, then.
> All of my thinking was centered around that, and I find your
> alternative to be much easier, and well... Port Music-y.
>
> I look forward to syncing this up using the method you've described.
> If nothing else, its way easier than what I was trying. I'll shoot you
> an email with how it works.
>
> -Jerzy
>
>   
_______________________________________________
media_api mailing list
media_api@create.ucsb.edu
http://lists.create.ucsb.edu/mailman/listinfo/media_api

Reply via email to