< Back to IRCAM Forum

Select measures - tip

Hello, the generic function “Select” is a very practical tool that I discovered for my self the other day (after using OM for almost 20 years…). One can input both measure numbers or absolute positions in ms. OM for the most describes the first position as 0, so if one wants to operate with measure numbers as stated in the score, one has to subtract 1. Yes, it is obvious, but often the most obvious “things” are those one doesn’t take in account. (Yes, I am a violist…) Best, Dagfinn

Select-measures.omp (15.1 KB)

Hi Dagfinnkoch,

Thanks for the tip.

I agree there are some quite handy generic om objects, like om-inspect or inside that let you manipulate score objects…
And even when we inspect the code of the select function we find some other hidden lisp functions. And there are a lot of them !
Do you think there’s a documentation somewhere ?

Best

N.

Hello Nadir, thanks a lot. I didn’t know the om-inspect or inside, so I tried it now. Very handy. I haven’t thought of asking for a documentation for the hidden ones. I can imagine that one can find some through Common LISP? Perhaps Karim can help us out?

Best, Dagfinn

Hello friends,

First of all, sorry but didn’t grasp what is the problem here. But there is.
Concerning select, and specially with measures, you should not use it. It will of course “graphicaly” do what it is supposed to do, but if you play it back it will mess all the timing in the result. This is due to the fact that the MEASURE object in OM is not completely compliant (missing fondemantal data).

So if you want to mix, select, revert recombine measures starting from a voice, (even inside will not do), you should first, extract the measures using inside (inside is a generic accessing slot of most of OM’s classes and it is not a function - so no documentation). THen turn all your measures into voices. then recombine these voice/measures as you please. By doing this you will have a correct timing sequence for your end result. (i am attaching a simple pexample patch).

Best
K

OOps sorry this here is the patch…

voice-and-voices.omp (31.9 KB)

Hi Karim,

Who said there was a problem :-))

Yes I remeber that one from the cnsm sessions !

have a nice week-end

N.

Thanks a lot for the tip Karim! Very exciting to read the patch, it is way beyond my skills in programming. But therefore also inspiring to learn more.

(To be honest, I seldom use the playback ability of Open Music.)

Best, Dagfinn

Hi,

Talking programming, I would have two questions regarding some the objects that are under found in Karim’s patch:

  • What is the use of ‘clone’, exactly here? Using the self output of the object without clone would not do the same?
  • Again in this context, is there a difference between ‘inside’ and ‘get-measures’?

Thanks a lot for this workaround regarding the ‘faulty’ Measure object, very useful!

Jimmie

Hi Jimmie,

As you may have noticed, the programm is inside om-loop so the object clone which copies the voice and returns it making all its slots available inside om-loop, and thereby allowing all its parameters to go through the loop at each iteration.

As Karim pointed out : inside is a generic accessing slot of most of OM’s classes and it is not a function – so no documentation, whereas the get-measures is a function and they seem to do the same thing here…

Bye

N.

Besides you will notice when evaluating an om-inspect object connected to the self of the voice, a window ‘inspecting’ opens and among the list of components (classes I guess) you’ll find another INSIDE instance including a list of measures, and each measure includes an INSIDE class which includes groups which includes an other INSIDE class which includes chords and finally notes !

Screen-Shot-2018-09-10-at-13.32.28.png

Ok, thank you, this is really interesting!

As for ‘clone’, it’s only that I realize that the patch seems to be working the same with or without it, so I was wondering what was its specific utility…

Thank you!
Jimmie

So we need more light here…

Hi there! Just to complement a little bit Karim’s point and the overall discussion:
As you know, all OM is written in Lisp, and (almost) all Lisp can be brought graphic into an OM visual patch. Not all is completely straightforward though :slight_smile:
OM patches represent functional expressions, which to be consistent should have no side effect: you want to get the same result (modulo nondeterministic aspects of it) each time you evaluate it. To comply with this, each box should return new-allocated data for further processing (and not any reference to some data stored somewhere else).
Lisp itself is a pretty permissive functional language, and actually a lot of built-in primitives are not “pure” functions. The “inside” accessor mentioned in your previous posts (as well as all slot-accessor functions) returns the data that is inside an OM container (not a copy of it): If you take it and modify it, the original container will get modified as well.
To avoid this OM provides wrapper functions such as get-chords, etc., which perform copies of inside and return the elements “inside” an object.
The clone function just avoids any mess by copying the data coming out of a box. It should be used carefully because copies are sometimes costly, but is sometimes necessary.

Hi there! Just to complement a little bit Karim’s point and the overall discussion:
As you know, all OM is written in Lisp, and (almost) all Lisp can be brought graphic into an OM visual patch. Not all is completely straightforward though :slight_smile:
OM patches represent functional expressions, which to be consistent should have no side effect: you want to get the same result (modulo nondeterministic aspects of it) each time you evaluate it. To comply with this, each box should return new-allocated data for further processing (and not any reference to some data stored somewhere else).
Lisp itself is a pretty permissive functional language, and actually a lot of built-in primitives are not “pure” functions. The “inside” accessor mentioned in your previous posts (as well as all slot-accessor functions) returns the data that is inside an OM container (not a copy of it): If you take it and modify it, the original container will get modified as well.
To avoid this OM provides wrapper functions such as get-chords, etc., which perform copies of inside and return the elements “inside” an object.
The clone function just avoids any mess by copying the data coming out of a box. It should be used carefully because copies are sometimes costly, but is sometimes necessary.

— update: I just noticed that get-measures does not perform a copy, but I believe it should !

Thank you Jean !

Bye

N.

P.S. Now we need another ‘inside’ class to access the semantics in the container of your complement (Just kidding:)

Hi all you lispy loving folks,

Thank you Jean for your enlightenment. By the way for those you don;t know yet, Jean IS the OM guy ! so everything he states is authority !
I just want to add something for we non-specialists, and try to explain the clone issues. First of all it has nothing to do with a star wars episode (unfortunately, …:slight_smile: . Ok , now for we non-programers, let it be known, that in Common Lisp you have (among other things) two kinf of functions. Destructive and non-destructive. Most of the last ones are in OM, so tehy don’t mess up things (cf. Jean’s post). But sometuimes, it is so practical to use teh destructive feature. So what is a destructive function. It is one that will CHANGE the object, list, etc… that it calls (ie connected to in oM). So clone function will prevent this by copying the object connected to and doing "things ion the copy and NOT on the original. This is braidly what clone does.

Hope this was somehow clear. …

So after inspection, Jimmie is right, you can do without the clone thing in the patch voice2voices. None of the function AFTER clone is destructive. It was just there because it was adapted from a lisp written method i wrote that was mostly destructive…

BEst
Good Oming and lisping…

K

Hi Karim, thank you very much for your explanations!

Indeed, my OMing is suddenly turning into a humming(!) :

Maybe it’s just for me, but I can’t think of an example where a function placed after an object would alter the latter retrospectively in a given logic? Or maybe it happened in my programming and I wasn’t aware of it (or didn’t understand it this way)… Would you have a quick example at hand?

Many thanks again,
Jimmie

Here is a simple (?) example (see attached).

SORT is a “destructive” function: it modifies (sorts) in place the input list. Calling it after inside modifies the order of internal lists in the chord-seq (without notifying/updating the editor and the box display!). The contents of the chord-seq box will therefore not be the same before and after calling sort (see other chord-seq box on the left).

Capture-d’écran-2018-09-10-à-21.58.32.png

Again many thanx for Dr. Jean … (thinking about the great Dr. John that maybe some of you guys, and some of you gals know)…

One very simple example i may add, for lispers :
The setf macro. very destructive. And again very simple :

Let’s take toto as a variable. We can assign a list to toto like this :

(setf toto '(1 2 3 4))

if evaluated, this expression will return :

OM > (1 2 3 4)

Now just evaluate toto :

toto

OM > (1 2 3 4)

Now let’s use something funny, the pop macro. Just like popcorn it will remove (pop) the first elmt of any list (the car of a list). So :

(pop toto)

will return the “popped” elemt

OM > 1

Now let us “inspect” toto by just evaluating toto. this will give us :

OM > (2 3 4)

So toto changed. It was popped ! [you can repeat the pop as long as you want)…

This could illustrate a destructive proceedure in CommonLisp.

Hope this was fun and not too boring for you guys and gals !

Goodnite, and may the Lisp be with you!

:slight_smile:
K

One of my Dr John’s favorite is a version of It Don’t Mean A Thing If It Ain’t Got That Swing by Duke Ellington.

And that’s the thing you’re bringing both Of you ! Some kind of SWING !

And as Spinoza once said there are 3 kind of knowledge :

1st genre : the knowledge of EFFECTS.
2nd genre : the knowledged of CAUSES.
3rd genre : the Beatitude !!

:slight_smile:

Good night and thank you !

N.