< Back to IRCAM Forum

Using the word pulse for notes is confusing

For example, in a 4/4 time signature you have 4 pulses (or beats) . The second pulse (beat) can contain 2 1/8 notes. They are on the same pulse, but on different positions on that pulse.

I used the function n-pulses, thinking that it would retrieve 4 pulses, the amount of beats, but instead it retrieves 5, the number of notes in the measure.

Is there a function to count the beats? Or any tip on how to create such function?

2021-06-13 11_01_39-^Patch

Using om-inspect and checking the variable “Extent” is the closest to some information about how many beats there are in a measure.

Is it possible to access that variable through input and outputs as in regular boxes?


Extent is an internal value and should not be used. The reason is that it is non related to what you are seeking.

OM is “agnostic” concerning musical style. So downbeat upbeat which are tonal metrical notions are not implemented as such. Say you have a 5/8 time signature, you can group it as 2+3 or 3+2 etc…

For your approach, i believe it is easier to program such notions starting with tree2ratio function which will give you the exact figures (rests included). Then you can determine your beats as desired. (tree2ratio is to be found in the Score->Trees menu


I’m after two things. 1-Getting the position of a note regarding a given pulse (or beat) structure given by the time signature. I’d be satisfied just to get an ordinal number so I can store it in a variable.
Using select-tree gives me a list, not a number.

2- Getting the position of a note within a single pulse (or beat) . Using tree2ratio gives me a list of durations, not positions within a beat. If I’d like to select all 1/8 notes that are on an upbeat, it would select all 1/8 notes, not the upbeat ones; say the third and fourth notes would be classified as the same, and they are not.

In the given example:
The third note is an 1/8 note. It is on the second pulse (or beat) and on the second proportion of that second pulse.
How can I get those numbers 2= second pulse and 2 = second proportion of the pulse?

It is the assimilation of notes to a time signature that makes it hard to get what I’m after.
I just need a vector of time (divided using a time signature) and a vector of notes (rhythmic durations) to manipulate. Independent vectors.
2021-06-13 16_33_21-^Patch


But what do you mean by ‘select’ each upbeat 1/8th. What do you want to do then?
ie, filter them? keep them? etc… or just have the position of these in the overall chords ?


You could re-structure the output from #'tree2ratio as a list of sublists, one per beat, consing up successive pulses until their sum is >= your beat-value. Ie. going from '(1/4 1/8 1/8 1/4 1/4 ) to '((1/4) (1/8 1/8) (1/4) (1/4)), and use positions as indices

For that you could use the #'bloodshed algorithm: OM - Merge unchanged notes, making #'same-bloodtype-p check whether the current sublist (beat) has room for this pulse, and have #'cannibal add this pulse to the current sublist.


It’s not just downbeats or upbeats that I want to select, also the position in the time signature, those who coincide with the numerator. Position order on pulses and for each one of them, subposition. What I want to do is have those position ordinal numbers to store them on variables, to classify notes.

In the same-bloodtype-p helper, should I remove both Lisp lmidic’s or replace them with something else?

For the cannibal helper, should I remove the Lisp ldur or replace it with something else?

I want to point out that unlike the post you mentioned, I use the voice object.


Maybe this is close to what you need ?:

Here is the patch:
ordinal.omp (18.6 KB)

Now it is up to you to tweak it!

1 Like

I opened the file you attached to get information (and learn) of the elements you used. The voice-voices box is dead. The onsets and chords elements the info says they are loops, so I suppose they were renamed.
The onset of a voice is in miliseconds format. And maybe the values shown in the textbox are in ms, I don’t know.

What I need is simple numbers, of positions and subpositions. I need some function that counts beats, and assign them position numbers. After that, for each beat, count subpositions and assign them subposition numbers.

b pos


Which version of OM you are using? The voice->voices is a new function introduced since version 6.18. I advise you to use the latest 6.19. And sorry, an error slipped in the patch, Here is an updated one, with your positions/subpositions you need.

ordinal-1.omp (31.3 KB)


1 Like

I don’t know how to cons up successive pulses in a situation of a quarter note on an upbeat.

cons up quarter

Open music ties the eight notes.The text on the next pic should read “The third note”.

cons up quarter tied

The output of tree2ratio is 1/4 1/8 1/4 1/8 1/4. How to cons up the second and third notes, making a sublist for that second beat, when the third note has half its value in the second beat, and the other on the third beat? Because (1/8 1/4) is more than a beat.

Also, I spent this week trying to learn this programming language and your algorithm with the patch you shared , eat adjacent chords and bloodbath. So if I learn that patch, I could change it for my needs.
I could do some sort or reverse engineering outputing the values of the boxes and functions to textfiles, so I could understand what is happening.
I couldn’t do that on the bloodbath patch and both internal helpers. I don’t know what data comes through the inputs. I suppose they are elements in a list (chord and lonset) but it wasn’t possible for me to follow the data flow, because inside bloodbath textfiles always output nil. I tried to initialize the eat adjacent chords lower chord seq box, and still couldn’t get data inside the bloodbath patch.
The most difficult part is the recursive one. Any advice on how to trace the data flow?

The situation of having a quarter note on an upbeat shows the need to differentiate the class time signature and on the other hand a class for the notes, chords, etc.

Some answers here:

What do you mean by cons? If you cons duration 2 and 3 you will end up with a doted quarter note.

Not particularly. OpenMusic can explicit exactly the rhtyhm you want, ie. quarter, eight quarter eight and quarter note (cf. patch enclosed).

Yes this is correct.

You just write this RT:

 (1 (((4 4) (2 1 2 1 2))))

And here is the patch:

ordinal-1 2.omp (12.5 KB)

For the other questions, i leave it up to Anders


Thank you for the patch. This is a “get” positions and it works fine. Now I would need a “set” positions; that is, insert a note (of any duration) on a given position.
I find it hard to do because the RT input in a voice object expects a complete list of notes.
I need something like this:
At this position, insert a note with this rhythm value.

Set posi.omp (39.9 KB)

Dear archiduque,

I find that there is something wrong in your postulate, or i am not getting what you REALLY want to achieve.

For instance, if we take the second position proposal, The question is, how are we supposed to know that the second beat will be subdivided?

So, structurally speaking, we need to know what are you intending to do by “setting” rhythm positions? Let’s suppose that in the second beat you have two levels of subdivisions. This will complicate matters, meaning that we must project subdivisions in advance. So in my opinion, if you need to “construct” rhythms starting from indices of position, you should reconsider your strategy.

In order to give you some leads, can you please first tell us what you want to do at the end. We might already have some tools for this.


It’s pretty much what I have said. Manipulate the rhythm in a melody. First, where the note will be placed. Then, what rhythm value will it have.

We will know when we put a rhythm value. It will be given, after the position is given. So I suppose it should be an algorithm like so: position + rhythm value.
And with that information there will be a RT to input in a voice object.

For example, insert any of these (1/4 1/8 1/2) on a certain position.

To clarify, the Positions and Subpositions loops shown in the image are from the ordinal-1 patch you provided, so it’s the same principle. You made two “Get” functions. What I’m after is the same but to “Set” positions and subpositions functions.

If i understand you well, you have a predefined onsets, and you want to position rhythm figures on these?

In your example, nothing shows at the start (first staff) the possibility to position an eight note on the 2 half beat. That’s why i am asking.

In general, it is good to start to define first on what basis you are working, then define afterwards the tools you need.


I don’t know if it’s correct to call them onsets(maybe onsets are measured in ms?) I call them ordinal numbers, given by the time signature. The format is exactly as your loops “Positions” and “Subpositions” inside the ordinal-1.omp file you uploaded in this thread. See the next picture for clarification.

In the example picture given before is missing any rhythm value (although I’ve written that duration will be supplied). It was just a broad approximation of what I’m after.

Position (& optional Subposition) + Rhythm value = RT?

Also, after first note insertion, don’t delete the note with new insertions.

So far I have this patch, but it’s not what I’m looking for, because the function subs-posn doesn’t differentiate between notes matching a beat and notes that are off-beat.

How SetPos.omp (21.4 KB)
pos to rtree.omp (7.1 KB)