# Splitting material into bars (sublists)

## Recommended Posts

Dear all,

Is it possible to split a given list of lengths (or omn) into sublists (bars) according to a given sequence of time signatures? That would be very useful for all sorts of operations. e.g., imposing a meter on unmetered music generated by whatever algorithm; metric shift where some note or rest is added at the beginning of a rhythm, but the metric structure is kept the same and all notes/rests move "to the right" as necessary etc.

Here is an example of what such a function could do.

;; the hypothetic function gen-bar expects a list of time signature forms (or bar durations as ratios) and a (flat) list of lengths or OMN. It returns the lengths/OMN split into sublists according to the time signatures.

```(gen-bar '((3 4 2)) '(1/4 1/4 1/8 1/8 1/2 1/4))
-> ((1/4 1/4 1/8 1/8) (1/2 1/4))```
```(gen-bar '((3 4 2))  '(1/4 1/4 1/2 1/8 1/8 1/4))
->  ((1/4 1/4 1/4 tie) (1/4 1/8 1/8 1/4))```

The hypothetical gen-bar is quasi an inversion of the existing function get-time-signature.

Such functionality seems so basic considering the OMN representation that perhaps something like this is already there and I simply cannot find it?

Thanks!

Best,

Torsten

##### Share on other sites

Minor addition for clarity: split-lengths does not what I am after.

##### Share on other sites

OMN-TO-TIME-SIGNATURE is the function you are looking for:

```(setf time-signatures '((1 4 1) (3 4 2) (4 4)))

(setf omn1 '(-q q c5 p eb4 h gb4 q gb5 p a4 f
c5 q c6 p eb5 gb5 q gb6 p a5 c6))

(omn-to-time-signature omn1 time-signatures)
=> ((-q) (q c5 p eb4 gb4 tie) (q gb4 p gb5 a4 f)
(q c5 f c6 p eb5 gb5) (q gb6 p a5 c6))```

##### Share on other sites

Brilliant! Thanks for the quick response.

T

## 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