Group Admins

  • Profile picture of Karim
  • Profile picture of Jean

OpenMusic

Public Group active 1 hour, 15 minutes ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

Select measures – tip

Author 5 Subscribed Users |
Profile photo of Dagfinn Koch
DagfinnKoch

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

September 6, 2018 at 08:27 #27645
Profile photo of nadir B.
nadir B.

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.

September 9, 2018 at 12:54 #27711
Profile photo of Dagfinn Koch
DagfinnKoch

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

September 9, 2018 at 14:17 #27712
Profile photo of Karim
Karim

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

September 9, 2018 at 14:42 #27713
Profile photo of Karim
Karim

OOps sorry this here is the patch…

September 9, 2018 at 14:44 #27716
Profile photo of nadir B.
nadir B.

Hi Karim,

Who said there was a problem :-))

Yes I remeber that one from the cnsm sessions !

have a nice week-end

N.

September 9, 2018 at 15:04 #27719
Profile photo of Dagfinn Koch
DagfinnKoch

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

September 10, 2018 at 11:38 #27729
Profile photo of Jimmie
Jimmie

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

September 10, 2018 at 11:58 #27730
Profile photo of nadir B.
nadir B.

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.

September 10, 2018 at 12:21 #27731
Profile photo of nadir B.
nadir B.

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 !

Attachments:
  1. Screen-Shot-2018-09-10-at-13.32.28

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

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

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

September 10, 2018 at 12:33 #27732
Profile photo of Jimmie
Jimmie

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

September 10, 2018 at 12:39 #27735
Profile photo of nadir B.
nadir B.

So we need more light here…

September 10, 2018 at 12:53 #27736
Profile photo of Jean
Jean

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 :)
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 !

September 10, 2018 at 13:28 #27738
Profile photo of nadir B.
nadir B.

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:)

September 10, 2018 at 13:44 #27739
Profile photo of Karim
Karim

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, …:-) . 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

September 10, 2018 at 15:43 #27740
Profile photo of Jimmie
Jimmie

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

September 10, 2018 at 20:34 #27741
Profile photo of Jean
Jean

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).

Attachments:
  1. Capture-d’écran-2018-09-10-à-21.58.32

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

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

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

September 10, 2018 at 21:06 #27742
Profile photo of Karim
Karim

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!

:-)
K

September 10, 2018 at 21:32 #27745
Profile photo of nadir B.
nadir B.

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

:-)

Good night and thank you !

N.

September 10, 2018 at 21:49 #27746
Profile photo of Jimmie
Jimmie

Ok, wow. thank you, this is good to know!

Here is an ’empirical’ test I’ve just done, since I didn’t know about the ‘sort’ function. Yet, I already knew sort-list, so I tried both, and you can see in the attached image that while ‘sort’ is destructive, as already said, sort-list is not (what you have in the two bottom chord-seqs are the direct results of the sorting functions, showing that even if sorting is performed in that direction, only ‘sort’ is destructive retrospectively).

Maybe it’s an example of something that has already been said, that is: that most OM functions have been made to prevent from ‘destructiveness’? It’s a nice attention in any case :)

I learned something today about it, thank you!

Jimmie

Attachments:
  1. Capture-d’écran-2018-09-10-à-16.46.56

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

  2. Capture-d’écran-2018-09-10-à-16.46.56

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

September 10, 2018 at 21:54 #27747
Profile photo of Jean
Jean

Yes: sort-list is basically a non-destructive version of sort, which copies the list (but not its individual elements) before to operate (+ has an option to sort the list recursively).

September 10, 2018 at 23:51 #27750
Profile photo of nadir B.
nadir B.

Hi Karim,

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)

I’ve applied your ‘appetizer’ example and I’ve noticed that the evaluation of toto after ‘popcorning’ it do not echo OM > (2 3 4)

In fact, toto is becoming (pop toto)… cf. img caps

N.

Attachments:
  1. Screen-Shot-2018-09-11-at-21.40.58

    Screen-Shot-2018-09-11-at-21.40.58.png

  2. Screen-Shot-2018-09-11-at-21.40.58

    Screen-Shot-2018-09-11-at-21.40.58.png

September 11, 2018 at 20:48 #27770
Profile photo of Karim
Karim

Dear Nadir,

yes that’s the point. If you pop it all the way you will end up with nil .
So just replay it once in this sequence :

1) (setf toto ‘(1 2 3 4))
2) eval just toto
3) (pop toto) [JUST ONCE !!!]
4) eval toto (just the toto variable !)

September 11, 2018 at 23:41 #27781
Profile photo of Karim
Karim

ADDENDUM ,,,,


Don’t use the mini listener.
Do the following here :

select new from file (menu file of the listener)

you will have a text file.

type as a first line :

(in-package :om)

save your file as xxx.lisp , or whatever .lisp

Then type your code, and do your evals in .lisp file. It could be that the mini “evaluator” in the listener re-initiazlizes itself. Dont know, i don’t use it …

September 11, 2018 at 23:48 #27782

You must be logged in to reply to this topic.

Log in now