Hi,
I use Lua to do keyboard input processing [1] (from GridFlow's [#out window] so I don't accidentally activate any Pd shortcuts when performing...).
A Lua object to map symbols to numbers would be very simple:
-- snip boring class init stuff
local tab = { A = 1, a = 1, B = 2, b = 2 }
function MyClass:in_1_symbol(s)
self:outlet(1, "float", { tab[s] or -1 })
end
I think [select] is probably "the Pd way", albeit "unattractive" as you say.
Another library that might help is pdcontainer, which has a "map" object, where you can associate values to keys. It's been a while since I used it however, but I seem to remember it was quite intuitive / well documented.
Claude
Roman Haefeli wrote:
just in case, you didn't know the objectclass, there is a objectclass [key], which outputs a number, whenever a key is pressd. since you want to press only single keys, having to press enter after each keypress could be a pain.
however, if you decide to go for [key] instead of symbolatom, you use a table to look-up the numbers.
roman
On Tue, 2008-02-12 at 21:29 -0500, David F. Place wrote:
Dear Pd Friends:
I need to create a mapping from letters into numbers:
(A->1,a->1,B->2,b->2,...)
I want to be able to enter a letter into a symbol box and translate
it to the number. This will allow me to enter rehearsal letters
from parts that cue up a sequence to the right spot. I can think of
very unattractive ways to do this in Pd using select. Is there an
elegant way?Best Wishes, David
[1] https://devel.goto10.org/filedetails.php?repname=maximus&path=%2F2008%2F...