Why is Metro in radians/sec?

I was struggling to understand why specifying a frequency of 1.0f to metro.init() caused it to have a period of well more than 1 second. I finally looked at the library code and saw that the frequency being passed in is interpreted to be radians/sec, not Hz. So when I specified a frequency of 1.0f, it resulted in a period of 6.28 sec.

I’m sure I’m not the only one being tripped up by this. Any idea why it’s coded this way?

Do you have the current version of DaisySP? As far as I can tell the metro.cpp definition here expects a frequency in Hz.

The Init function computes an increment by which to step the phase every audio frame (so that the phase moves 2 pi freq every sample_rate frames, i.e. each second).

The Process function wraps around the phase (returns a click) every 2 pi traveled by the phase, i.e. freq times per second.

Is the definition of these functions different in your code?

I am fighting with Metro.Reset(),
it seems not to do anything…

You’re absolutely right. I got confused by the 2*PI. However, it still seems to be firing slower than I was expecting.

OK, I think I have it. I’m calling metro.Process() within AudioCallBack() - as one does. However, since I’m not calling it within the inner loop (where I call oscillator.Process()) and my block size is the default 4, the sample_rate I initialized metro with needs to be 1/4 of the rate I passed to Oscillator.

Edit: Apparently I’m not good at telling the difference between being off by a factor of 4 and a factor of 2*PI.

The Reset method sets the phase to zero, i.e. resets the location of the beat. Can you provide some more context for how you’re trying to use it, and what you’re having trouble with?

Glad you figured it out - yep, you’ve gotta call all the audio-rate Process functions once per audio frame in order for the timings to work properly.

sorry for hijacking, I am retriggering my sequencer with my keyboard, and often it retriggers between the steps. so the first note comes not immediately.

I was trying with and without reset, it seems not to make a difference. what I did not try was metro.process(trig), but metro.retrig(trig) is not allowed.