Login / Register 0 items | $0.00 New @ KVR
Ap0C552
KVRist
 
140 posts since 15 Feb, 2012

Postby Ap0C552; Mon Jun 11, 2018 7:08 pm Midi sequencer to use system clock or sample-based timing?

I am writing a Midi sequencer that will take in a midi sequence from a file, and a map of notes to samples.
It will write out PCM audio to an audio stream.

The sequencer must have a concept of time to properly sequence events. Is it proper to use the system clock to sequence the events or use the DAC by keeping track of the samples written to the buffer?

I have been looking a midi library where the class responsible for running the midi events, has no connection to the audio stream, and thereby can not use samples written as its source of time. I thought this was incorrect.

Is it proper for a midi sequencer to be couple to the audio out/dac and use samples written as its source of time passed?

Thanks for any insight provided!!!
mystran
KVRAF
 
4888 posts since 11 Feb, 2006, from Helsinki, Finland

Postby mystran; Mon Jun 11, 2018 8:23 pm Re: Midi sequencer to use system clock or sample-based timing?

When rendering/processing audio, I'd just always count the samples for timing. If you need the current time asynchronously (eg. sending/receiving MIDI from the outside world or trying to sync some animation to the audio) then you probably want to estimate the current DAC playback position, potentially add in some latency estimate and use that. For the estimation purposes you could use a secondary clock source (eg. the system clock) to help improve the resolution beyond process buffer granularity (at least if you can't query the DAC clock directly), but as long as you got a DAC running that should usually be your master clock.
Image <- plugins | forum
Ap0C552
KVRist
 
140 posts since 15 Feb, 2012

Postby Ap0C552; Mon Jun 11, 2018 8:32 pm Re: Midi sequencer to use system clock or sample-based timing?

Thank you for the confirmation!

I will not be syncing with anything outside of the world.

Moderator: Moderators (Main)

Return to DSP and Plug-in Development