Text to Morse Code
I've got individual letters down using a route object then delay patterns to generate the sounds. My problem comes from trying to step through a text file letter per letter. I'm at a loss for how to do this, other than putting each letter on a separate line, which I don't want to do.
Anyone have any solutions or help on how to step through even just a world letter for letter?
Thanks in advance
funny - I just did this a month ago for a gig - but in Processing/Java (which is somewhat easier for text munging but poor for audio). In Max I'd send slabs of text into a JavaScript object to do string manipulation & send the individual letters out to the rest of your patch. You'll want to strip punctuation as well.
Sorry, I understand neither Processing nor Java, can you point me in a direction.
Read through the text file line by line and send it through a [regexp] object as shown below. This should get you up and running in no time:
yeah cool. Since there's no punctuation chars in morse code, use the following expression in the regexp object & it will just pass alphanumeric chars and spaces. Like Luke said - send it a line at a time.
([a-zA-z0-9\s])
You might want to use the space chars to trigger a little pause in the audio output.
... or you can use [spell]
aa
You won't believe it, Max comes with a morse generator:
/Applications/Max5/Cycling '74/java/help/MorseGen.maxhelp (on Mac, PC should be comparable)
Its a java class...
I also made one some time ago (unadapted Max 4 style, looks a bit unfinished and is, but sounds ok...)
There is also some Morse Code gen routines and stuff in the 'tom-swirly-max-javascript' stuff . . .
Hi,
Stefantiedje, first of all thanks for your code, I could not find any example in max 6 or 7 about morse (please let me know if I am wrong). I know it was long time ago but I am still interested on it. As it is pointed in another post the timing might have to be slightly adjusted but other than that gives a pretty good base for a text to code translator.
However, I have one question about some object which is confusing me a bit. Why did you reverse the dots and dashes for each letter? that would read the code for each letter right to left instead of left to right but there might probably be something I am missing here..
Thanks in advance
Juan,
You are correct. Those letters which are not symmetrical in Morse are sent incorrectly by the patch.
Best regards,
Michael