< Back to IRCAM Forum

Hobby gematria - a question on mapping

Hello, I’m trying to find a straightforward solution to the following problem: Mapping letters to numbers.

For example this short part of a poem by Enzensberger:

«Der Künstler entsagt.»
Das war früher.
«Der unglückliche Künstler.»
Ein Anachronismus.
Er hat sich gestritten,
hat uns mißtraut.

The first sentence would be: 4 5 18 11 21 14 19 20 12 5 18 5 14 20 19 1 7 20
In addition grouped as “words” 4 5 18 - 11 21 14 19 20 12 5 18 - 5 14 20 19 1 7 20

Is the solution to use “if” in combination with a kind of table? And/Or can BPFs be useful.

I think this actually is basic LISP, but I’m a bit lost, and a bit lazy. :slight_smile:

But hope you can help me out.

Best, Dagfinn

The poem by Enzensberger is really relevant for our group. :slight_smile:

Das unglückliche Ohr

«Der Künstler entsagt.»
Das war früher.
«Der unglückliche Künstler.»
Ein Anachronismus.
Er hat sich gestritten,
hat uns mißtraut.
Er ist unbrauchbar, stört.
Nicht als wäre er schwerhörig,
wie Beethoven,
taub von Donner gewisser Sonaten.
Ganz im Gegenteil.
Er hört zu gut. Er hört Stimmen.
Sie wimmeln in seinem Kopf,
bringen Hiobsbotschaften.
Die Wahrheit, eine Montage,
Jahrsehntlang überall Kork,
im Regieraum nur ein Assistent
an zweihundert Reglern.

Hinder dem Schalldichten Glas
offene Münder. Dezibel, Filter.
Es ging um Bruchteile von Sekunden.
Ein splitterndes Geräusch,
dann Leerband, weißes Rauschen.
Das war früher.
Heute brütet er von sich hin,
im leeren Studio,
ein unglückliches Ohr,
während die Kunst sich austobt
auf Auktionen und Festivals.
Die Vergangenheit,
ein unmerkliches Knacken
im Kopfhörer,
ganz dicht am Trommelfell.

Skjermbilde-2018-05-23-kl.-11.21.38.png

Hi Dagfinn! Indeed, you are incredibly lazy! Have a look at “character construction and selection” in the CL refs: https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node138.html.

Check this snippet, you’ll immediately see what’s missing to get the output you want. No?

(mapcar #’(lambda © (char-code c)) (coerce “a bold composer: dagfinn” 'list))

Thanks a lot, Anders! I will now try to find out what you actually say. I’ve found some of the elements… Now I have to try it out. I do understand the lambda concept (I hope)

And thanks for the Patterns library you gave me a while back!

(As a Norwegian I’m used to getting everything served on a platinum plate, you know. LOL)

Skjermbilde-2018-05-23-kl.-13.14.47.png

I think I understand the idea, but to execute it is the matter now. I’m I on the right track when checking character conversion?

I found a link to a book I actually have a hard copy of.

http://www.lispmachine.net/books/common_lisp_the_language.pdf

Conversions, yes, there are two of them going on here:

  1. from a string "abc" to a list of characters '(#\a #\b #\c)
  2. from a list of characters '(#\a #\b #\c) to a list of numbers '(97 98 99)

The first one can be done by ‘coerce’-ing your string to a list, ie. (coerce “abc” 'list).
The second by looping through your list of characters and collecting each characters 'char-code, either using loop or mapcar.

The char-code of e.g. #\a is typically 97, #\b 98 and so on, so you’ll have to subtract something from your output to start from 0 or 1.

If you want a patch please tell me.

Dear Dagfinn,

A while ago i have done a small library that you can find here :
https://forge.ircam.fr/p/omlibraries/downloads/172/

You can use the string->ascii method and ascii->string in order to rtanslate characters (strings) into digit and vice versa.

Have Fun

Best
K

Screenshot_2018-05-23_15-16-59.png

Hello Anders, thanks a lot! Now I do understand the concept, it was some basic knowledge in the nature of ascii that wasn’t present… If you can provide a patch that would be great!

Best, Dagfinn

Dear Karim, thanks a lot for the library. I test it now. Very cool! And it is not a way to undermine Anders’ pedagogic approach which I also appreciate. smiling

I’m working on a large piece for viola, brass band (sic) and live electronics (partly Antescofo with necessary back up.)

Three great poems were written and selected by Enzensberger. He wrote the text to Henzes’ second violin concerto, so I do have that in mind. And checking which patterns I can find in the poems.

Best, Dagfinn

Here’s a patch.

Utvalg_001.png

Hello Anders, thanks a lot! I’ve tested the patch now. This is good.

I’m afraid I wouldn’t manage to find the solution myself. So a Common LISP course at the University for me, as you suggested to learn the basics is a must.

(Perhaps time to grab some beer in Oslo?)

Best, Dagfinn

Hi, dagfinn, there is also a solution that doesn’t require any knowledge of lisp at all: In the OMTristan library, there is a patch called ll-replace, that should do exactly what you need. I think OMRuben has something equivalent, too?

Hi Michael, thanks a lot! I checked OMRuben List Tools, but couldn’t find something equivalent to OMTristan. I tried to activate OMTristan 3.3 running Open Music 6.13 (2017-12-19) but get the attached message when applying the library. (Actually, the OMIannis library doesn’t load either.) See screenshots.

Skjermbilde-2018-05-28-kl.-08.53.55.png

Yes, you have to download OMTristan 3.4, it’s I’ve never heard of OMIannis, sounds pretty interesting.

And you’re right, there doesn’t seem to be an exactly equivalent function in OMRuben, but then again, you’ve IRLRuben working for you, so there’s that.

...

Hi Michael, thanks a lot for your answer! I will download OMTristan 3.4. Best, Dagfinn

Hi Dagfinn, no problem. I actually tried out ll-replace (I hadn’t found a reason to use it before) and discovered that it only accepts a single argument, so you would have to chain 26 of them together (or more, if you’re counting umlauts :D). So Anders’ (sorry I mistook Anders for Ruben in a previous post - must have been an internal string-to-chars error) and Karim’s methods are probably more efficient.

Karim,
I had a chance to try the OMlempeltext library, using the string=>ascii function (OM 6.13 on Linux). I noticed that neither my patch (see attached) or the tutorial patch reacts well when the text is enclosed in the quotation marks. I also tried removing the quotes, but the Listener still produced this error message:

Error while evaluating the box STRING->ASCII: “text” is not a designator for an object of type character.

The only way that I was able to get it work was to space the given text wide and without the quotes: t e x t
I welcome your thoughts on this.

Also, would it be possible to know what ascii table is this conversion derived from? I briefly consulted this table: http://www.asciitable.com, but couldn’t figure out the details, including whether the characters other than letters are also taken into consideration.

Lastly, might it be possible to group the text in a textfile into sub-lists (subgroups), similar to groups of letters that form words in a sentence?

Thank you!
Zvony

ascii.omp (3.68 KB)

Dear Zvony,

omlempeltext is an old library. It is still operational, but… the tutorial (my bad) is not updated alas !!!
This is due that the textfile object, which in my opinion (and not only mine…) is not that great !.

In order to use text in this object and with omlempeltext and string->ascii :

  1. put it between double quotes as it is
  2. VERY IMPORTANT, use the textfile fourth input in mode 'value. (this is the great change from om 5.x and 6.x)
    So in order to use the tutorial, (sorry for that), create new textfile objects, (yes if you try putting the 'value option with these old textfile objects this won’t work), and copy paste your text and embed it between double quotes without forgetting the 'value mode.

Now it is important not to put spaces. A space result in a 32 ascii decimal code. It will determine a space between words.
For a complete decimal code conversion table see here :

https://www.asciitable.com/

Will post further a patch on how to group words, remove punctuation etc…

Best
K

Karim,
Many thanks for your quick reply and clarification. It’s all working much better now! Look forward to experimenting and learning more later.

Best,
Zvony