Weird Psym behavior

I’m trying to figure this one out:

Pdef(\x, Pbind(\midinote, Pn(60, 1)))
Psym(Pseq([\x], inf).trace).play
// plays one note in a loop
// post screen displays:
// x
// x
// x
// …

fine so far, however when I try:

Pdef(\a, Pbind(\midinote, Pn(60, 1)))
Psym(Pseq([\a], inf).trace).play
// no note plays
// post screen displays
// 9
// 9
// 9
// …

In general \a-\g don’t play notes, and display numbers instead of what I would
expect, the name of the symbol. So what’s going on here?

                Thank You For Your Attention

I think you have to use it inside a Pdef, this works:

Pdef(\a, Pbind(\midinote, Pn(60, 3)))
Pdef(\b, Pbind(\midinote, Pn(62, 2)))
Pdef(\play, Psym(Pseq([\a, \b, \a, \b]).trace)).play

It doesn’t work for me. No notes come out, and the trace is:

9
11
9
11

When I substitute x for a, and y for b, notes come out and the trace is
x
y
x
y
as expected

(Btw: Code tags please!)

I just tested and this does not happen on my machine. So it isn’t standard class library behavior. That means it’s an extension.

The fact that it’s only a-g is suggestive, as these are the names of the white keys on the piano.

It looks to me like someone wrote an extension, maybe in a quark or maybe not, to translate symbols (beginning with?) a-g into semitones – note also that A is 9 semitones above C.

The problem, of course, is that symbols are used for many reasons, many of them incompatible with the idea of pitch specification. A pitch-translator extension needs to tell the difference between these cases. (This extension breaks not only Psym but perhaps also control bus mapping symbols.)

Probably they put the translation into Symbol:embedInStream, applying to every symbol that is ever returned from a pattern, for any reason. This, as you found, has nasty side effects and I’d definitely not recommend doing it that way.

A better approach would be to edit the default event prototype keys that translate pitches, and add the symbol logic there – so that the translation is done not in every context, but only in the context where it’s needed.

hjh

I think you’re right, seeing as \c gives 0. I’m not sure what you mean by ‘code tags please’. It seems that the writer of this code might have advertised this side-effect.
How do I search for the code that does this cleverly?

                            Thank You For Your Attention

Here is some code that you can’t run in SC, because forum typesetting replaces straight quotes with curly quotes:

“Hello, World!”.postln;

You’ll also have problems with e.g. a*b*2 becoming ab2. It is not safe to write code as normal text.

Here is the same code, wrapped in code tags:

"Hello, World!".postln;

Note the different font.

Here’s how to write it in your post: triple-backticks before and after.

```
"Hello, World!".postln;
```

They probably didn’t think of it.

I’m guessing that they implemented embedInStream for Symbol, so you might look for that in your environment.

EDIT: The other way to find things like this is to remove extensions one by one, until the problem disappears. Then, the last one you removed is the culprit. (Or the other way around – remove them all, and add them back in one by one.)

hjh

I found the Extension that broke Psym. It was ChordSymbol. If you remove it
the looking up of names in Psym works as expected.

                       Thank You
1 Like