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