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
(---o-------o-o-o---o-o-o----( David F. Place mailto:d@vidplace.com
you could use msgfile from zexy and write your transaltions into a textfile a 1; b 2; c 3; ... and then [r letter] | [rewind, find $1( | [msgfile] | [$2( | [s number]
pool (thomas grill) also has dictionary lookup features. but I am not sure if any of these solutions is more elegant then select, and select is quite fast. how many letters do you have? marius.
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
(---o-------o-o-o---o-o-o----( David F. Place mailto:d@vidplace.com
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
marius schebella wrote:
you could use msgfile from zexy and write your transaltions into a textfile
if you are using zexy anyhow, then i suggest using [index] (a dictionary) instead of [msgfile] (you can use [msgfile] or [textfile] to actually store the mapping.
or use [select] as marius has suggested.
or use moocow's [any2string] which will give you the ascii-value of each character in a symbol (or list). this could be interesting if you want people to enter more than just one single character.
fmgads.r IOhannes
On Feb 12, 2008, at 11:51 PM, marius schebella wrote:
you could use msgfile from zexy and write your transaltions into a
textfile a 1; b 2; c 3; ... and then [r letter] | [rewind, find $1( | [msgfile] | [$2( | [s number]pool (thomas grill) also has dictionary lookup features. but I am
not sure if any of these solutions is more elegant then select, and
select is quite fast. how many letters do you have? marius.
Thanks. I prefer to stick with vanilla Pd to make it easier to
port. Select will certainly work. I have to translate 50 letters
('I' is never used as a rehearsal letter), so it is quite an ugly patch.
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 ___________________ (---o-------o-o-o---o-o-o----( David F. Place mailto:d@vidplace.com _______________________________________________ PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/ listinfo/pd-list
(---o-------o-o-o---o-o-o----( David F. Place mailto:d@vidplace.com
Hallo, David F. Place hat gesagt: // David F. Place wrote:
Thanks. I prefer to stick with vanilla Pd to make it easier to
port. Select will certainly work. I have to translate 50 letters
('I' is never used as a rehearsal letter), so it is quite an ugly patch.
To make it more beautiful, you could use an abstraction "transl.pd" with these objects inside:
"route float"
"select $1"
"f $2"
then make a chain of these:
"transl a 1"
"transl b 2"
"transl c 3"
...
I currently cannot type bracket and pipe symbols in my terminal, so completing the patches above is left as an exercise for interested readers. ;)
Frank Barknecht _ ______footils.org__
Hallo, Frank Barknecht hat gesagt: // Frank Barknecht wrote:
Hallo, David F. Place hat gesagt: // David F. Place wrote:
Thanks. I prefer to stick with vanilla Pd to make it easier to
port. Select will certainly work. I have to translate 50 letters
('I' is never used as a rehearsal letter), so it is quite an ugly patch.To make it more beautiful, you could use an abstraction "transl.pd" with these objects inside:
"route float"
"select $1"
"f $2"
then make a chain of these:
"transl a 1"
"transl b 2"
"transl c 3"
...
I currently cannot type bracket and pipe symbols in my terminal, so completing the patches above is left as an exercise for interested readers. ;)
Solution attached. Includes a little bonus (that requires list-abs)
Frank Barknecht _ ______footils.org__
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
(---o-------o-o-o---o-o-o----( David F. Place mailto:d@vidplace.com
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
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...
On Feb 13, 2008, at 4:52 AM, 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.
I use [key] to implement simple controls for my program. I also use
symbolatom to accept alphanumeric input. These two uses often clash
however. If I want to enter a string that contains one of my command
letters the command is triggered. I would prefer that keystrokes are
not sent to [key] when a symbolatom is selected for input. Does
anyone agree?
(---o-------o-o-o---o-o-o----( David F. Place mailto:d@vidplace.com
Hallo, David F. Place hat gesagt: // David F. Place wrote:
I use [key] to implement simple controls for my program. I also use
symbolatom to accept alphanumeric input. These two uses often clash
however. If I want to enter a string that contains one of my command
letters the command is triggered. I would prefer that keystrokes are
not sent to [key] when a symbolatom is selected for input. Does
anyone agree?
Workaround: You could use a key, that is seldom used (e.g. F-keys) to disable and enable your key commands.
Frank Barknecht _ ______footils.org__