Norns Beatclock - how to get 32 beats (also calculating bpm)?

Using beatclock… I want to double the number of steps in a beat or measure. I believe the default is 16 and I’d like to have 32

so there’s this in the library:

  i.steps_per_beat = 4
  i.beats_per_bar = 4

If I double steps_per_beat (make it 8) I get the result I want, but then incoming clock is 1/2 and outgoing clock is doubled.

beats_per_bar does not seem to change anything for me. I don’t really understand what that’s supposed to be doing.

Bonus question

How do I calculate the incoming bpm (to show on display) when using external clock? Am I dense or is this missing from the Beatclock lib?

1 Like

…and here I go finding what might be the answer right after posting.

Does ticks_per_step have to half if I double steps_per_beat?

(Still curious about how to get incoming bpm value.)

The two both have to be set yes, I’ve done it like this in the past.

And I’m not aware of a way to get the incoming external clock BPM directly from the lib (I think you’d need to time the advances in your script).

1 Like

this is your key line

self.metro.time = 60/(self.ticks_per_step * ( self.steps_per_beat / 4 ) * self.bpm)

The beats per bar is neither here nor there - doesn’t effect anything and isn’t used in any calculation

Measuring the incoming BPM:

The midi clock is the midi code 248 sent every 24PPQ (pulses per quarter note) which is represented as a ‘tick’ inside beatclock (so you as the defaults stand you get 6 ticks per step_per_beat)

You will have to time them as they come in and work it out. I’ve been planning on coming back to this for Kria as well as incorporating Ableton Link at some point (and manual stepping) but if you do the work for something else I will happily ‘borrow’ it :slight_smile:

1 Like

I got about that far and gave up for tonight. Wasn’t sure how to measure timing from lua.

no - there is only a second clock as far as I can see . which obviously isn’t high enough resolution. I’m also not entirely convinced by the “solidity” of the Lua clock when I was running it against Ableton/digitakt for testing sync. My feeling was that I wanted to move the whole lot into C (and add Ableton link while I was at it) (which is a whole rabbit hole since Norns as it stands doesn’t easily allow for C extensions for lua I don’t believe - although they are fairly straight forward).

The metros do obviously run at higher resolution so you could make your own clock to time against

Re: Link - have you seen this:

There’s also this clock coroutines thing but I can’t quite wrap my head around that yet.

1 Like

I hadn’t - but cool that looks good

Thanks for this little feed, I think I have been misunderstanding BeatClock for a while now.

In Midi clock is there then a ‘one’ to signal the beginning of a measure? This has been the thing escaping my knowledge while I’ve been trying to get external instruments to sync not only in tempo, but in measures.

There is the SPP signal - midi 242 with data bytes indicating the beats since the start of the song. You only get this occasionally depending on the device sending. Basically whenever you get this set your own position and keep it updated as you move your own clock (using the midi 248’s).

Beatclock doesn’t have any support for this but would be easy to add in

1 Like

Cool thank you. So no go for now with Beatclock to send that data.

Then can I ask another ignorant question, The initial question was how to make Beatclock do 32 beats instead of 16; why might you want to do this? Right now in my little patch I have the length of my sequence controlled by an array, and it steps forward at the speed of my Beatclock. In this case it doesn’t matter (as far as I can tell) how many beats there are, so when would it? Or should I start taking a closer look at my code!

Code if interested :

I’ve forked beatclock (ie copied it and renamed it :wink: ) in my projects for the moment - lets me mess about with it to suit myself

It’s dead easy to add in the midi support for other messages

I presume that overtime Norns will take any interesting changes back into the fold or implement the things people need

the docs are terse on this, but time(), from norns utilities, should return two values: seconds, and microseconds. its actual accuracy should be good to, i dunno, 10s of microseconds? (it’s just gettimeofday().) if this isn’t working for some reason lmk.

sure, as you say it’s easy to send messages. i think i’ve suggested elsewhere to just send Song Start from the param handler or whatever turns on midi clock in the script. i don’t actually know if this is a universal requirement (should be baked into beatclock directly) or if there could just be a more convenient extension to beatclock allowing to send more arbitrary midi stuff on state changes.

that’s true, other than pulling them into matron. but the C/lua interface could be cleaner, and if there is a hunger for plugins then we can think about plugins in a later version.


given that a) the Song stuff is pretty simple (the simplicity of midi is why, I’m sure, it has stood the test of time) and b) it’s the only bit really missing my vote would be to add it in

1 Like

i’m looking now, and seems that we are sending 0xfb (Continue) when the clock is started.
[ ]

are you suggesting to change this to 0xfa (Start)? wouldn’t that have different behavior?

it seems to me like we should have explicit start and continue, or add an optional argument to start.

anyways feel free to open an issue or pull request. (i’m probably the wrong person to be discussing it tbh.)

the SSP message is different and on top of those but anyway…

yeah - that’s were I was going with this - it’s not urgent (for me)

well, right… SPP is different and i guess that seems less low-level?

clock sources don’t always send SPP, and a device handling Start should be equivalent to handling SPP=0 and then Continue. so that is what beatclock assumes you will do if you want to reset position each time the clock starts.

anyways here’s the issue so that would be the place to hash out what would be the best defaults or how to conveniently extend the API.

[ ]

FWIW, song position messages are handled with helpers in the current midi core (I added that a long time ago)

Doesn’t this depend on what’s sending? e.g. Anushri has three different PPQ settings…

the midi spec says that - the machine might work internally at a different PPQ for sure but midi things will be expecting 24

1 Like