None of them seem to be completely in BPM-sync if I test them against a metronome inside Ableton Live, and they booth appear (at least to my untrained ear) to start sounding “loose/untight” the more samples I playback at once.
Has anybody experienced anything similar when trying to make a music sequencer?
Any hints / tips for alternatives / etc much appreciated!
both ofxSequencer and the example you point out in ofxMaxim seem to use the system clock (ofGetElapsedTime*) to calculate the timing. that’s not correct for sound where the clock should come from the sound card instead of the cpu so the tick is always in sync with the sound. to get the time from the sound card you can use the sound callback in OF to get the current tick and use the sound settings to calculate the current time:
Being relatively new to OF and not having much experience with low level audio stuff, I have had some nasty encounters with void ofApp::audioOut producing really really (!) loud noise when not set properly.
I just want to play back samples, not do any low level audio output with the hazard of damaging my or other peoples ears.
How do I best use the ofApp::audioOut to keep track of time, without the risk of loud noises?
(Sorry if this is a slightly different question, and thanks again for you help!)
Are you using Windows? if not you could try using ofxPDSP, it manages the audio output callback for you and its internal sequencer is sample accurate, but you have to make your own classes for step sequencing if you don’t want to simply write sequences inside the source code (you write sequences as inlined arrays).
( I still have to make libaudiodecoder work on Windows for sample file loading )
you can also do buffer.set(0) but you usually want to generate your sound using the same callback that is used to calculate the time. you can attach 2 or more different listeners for the sound stream and that’s still ok since the call will happen one after another but trying to use the audioOut callback for timing and for example ofSoundPlayer to playback sounds will probably not be as accurate although might be better than using the system clock
I was in doubt if commenting here or opening another thread.
I’m trying to make a master midi clock in a software, and already tried ofxBPM and ofxMSABpmTapper, which uses the high resolution mach_clock
but they both drift from time to time, in reference to other instruments.
I’ve started to write my own bpm class but it drifts anyway.
should I use audioOut for dealing with BPM, even when not using anything audio on OFW?
or just another thread? float precision is enough when using seconds as the standard unit?
i don’t know if has something related/useful to this, but I remember another addon called ofxThreadedMidiPlayer…
When I tried to trig midi sequences with it, I remember some drifts when minimizing the window or swapping between programs…
hey @dimitre, I am trying to sync my ofApp to the Ableton BPM. Did you tryed some successful addon like ofxBPM or ofxMSABpmTapper? I played too with ofxSequencer but I am not sure that the sync is working fine… Any idea of what to use? Maybe some MTC clock time syncro…?
Yeah in fact you can use midi messages to sync ableton clock with yours.
Roughly it sends 24 midi messages per beat (or 48, not so sure), so if you parse them you can make any midi device (Ableton included) control your BPM.
I’ll edit this post if I find more information. message is this one
Hello @arturo, I’ve finally implemented successfully a steady timer coming from the audio clock, as in your example.
In fact it is best with very low buffer size, like 32. using 512 buffers it is more erratic than ofGetElapsedTimef()
I’ve made this bpm counter which is working OK, checking with an external device. I’m only puzzled by variations in intervals but it is probably floating point imprecision, or maybe beating between the audio buffer and bpm intervals.
My ideal audio buffer size now is 32. lower than this and I’ve got overflow/underflow, higher and it gets imprecise.
I’ve decided to use double all around, including a modulus function.
Any improvement ideas will be very welcome.