< Back to IRCAM Forum

Dynamic matrix display

Hi All,

I would like to have the possibility to insert a matrix into a class-array for better visualization. I can do by hand, but I am searching for an automatic resizing according to the number of elements in each row of the matrix. I should use that for visualizing the result of K/Kh comparations between couple of Pitch-Class sets.

For example suppose to have the final result in this form:

(— 4-12 5-8 6-34)
(4-12 k- kh kh)
(5-8 kh k- --)
(6-34 kh – --)

I would like to display it into a class-array dimensions 4X4. Of course the length of the elements into result is variable, so the algorithm should have to automatically resize the class-array.

At least my problem is how to add :k slots in an automatic manner.

Many thanks in advance, ciao

Fabio

1 Like

Dear Fabio,

Can you provide a simple example and illustrate the problem you encounter here. It will be easier to send an answer.

Best
K

Is this what you are looking for?:

Here is the code:
NewFolder.zip (2.3 KB)

Best
K

Dear Karim,

You are Great! It is exactly what I needed, I have tested very fastly with a different number of sets, but I think it runs perfectly. I will have to study the function push, it is the second time that your code contain it and resolve my situation.

Thank you very much indeed, ciao

Fabio

Dear Fabio,

Glad that you found what you were looking for.
Now about “push”, it is in fact not a function but a macro. This is important to know since most macros are not “usable” graphically in Om’s graphic environment, ie as “boxes” per se. It is the case of setf, pop and so forth. But if you need to use it, i can give you a graphical example how to use it, and this using “lisp functions” like in this example. That’s the reason why we cannot replicate the function 'make-array-from-data" in a patch form.

But this is another topic other times :slight_smile:

Best regards

K

1 Like

Yes, a macro, of course. I said I must study :slight_smile:

Dear Fabio,

The push macro is just straight forward:

Considering a list:

(setf *mylist* '(1 2 3))

=> (1 2 3)

we can "push elements inside like so:

(push 4 *mylist*)

=> (4 1 2 3)

Then you have its inverse which is pop:


(pop *mylist*)

=> 4

*mylist*

=> (1 2 3)

These mechanisms are really practical :slight_smile:

Best
K