# Number of beats per measure

## Recommended Posts

Does anyone know if there's a function that outputs a number of beats from every measure in an omn sequence, given the denominator? For example with the eighth-note denominator, ((-e a3f4d5 q f4d5a5) (q a3e4c5 q e4c5a5) (-e a3g4e5 h g4e5a5)) would output (3, 4, 5).

Thank you!

##### Share on other sites

violà... here's a solution...

but: you have a wrong OMN-structure in your code (-e a3f4d5 q ... => a rest followed by a pitch, i corrected it

```(setf omnlist '((-e q f4d5a5) (q a3e4c5 q e4c5a5) (-e  h g4e5a5)))

(defun countbeats (omnlist &key (denom '1/8))
(loop for i in omnlist
collect (/ (sum (abs! (flatten (omn :length i)))) denom)))

(countbeats omnlist)
=> (3 4 5)

(countbeats omnlist :denom 1/16)
=> (6 8 10)```

##### Share on other sites

@André: isnt it so, that the length value is valid until the next length value regardless if its a rest or not?

Please correct me if I'am wrong..

```(omn :length '((-e a3f4d5 q f4d5a5) (q a3e4c5 q e4c5a5) (-e a3g4e5 h g4e5a5)))
==>((-1/8 1/8 1/4) (1/4 1/4) (-1/8 1/8 1/2))```

##### Share on other sites

yes, but it's - in my opinion - not very clear like that. difference: what you see and... what you get...

i always write it like this:

'((-e e a3f4d5 q f4d5a5) (q a3e4c5 q e4c5a5) (-e e a3g4e5 h g4e5a5)))

it makes more practical sense to me

... but my functions works for BOTH

##### Share on other sites

```(setf mat '((-e a3f4d5 q f4d5a5) (q a3e4c5 q e4c5a5) (-e a3g4e5 h g4e5a5)))

(get-time-signature mat)
=> ((2 4 2) (3 4 1))

(get-time-signature mat :group :numerator)
=> (((2) 4 2) ((3) 4 1))

(get-time-signature mat :group :denominator)
=> (((1 1) 4 2) ((1 1 1) 4 1))

(get-span mat)
=> (1/2 1/2 3/4)```

##### Share on other sites

Thank you, all! This is very helpful. The AM solution gave me what I was looking for.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×

• Lessons