Posted: Wed Jun 16, 2010 4:47 pm Post subject: Morse code translator
So, I was bored and made this. There's some messy stuff in it (like the initialization of number sequences) but it works. Feel free to mess around with the 'speed' and 'freq' constants, though you need to stay in the hearing range for freq and any speed under 75 just sounds like a bunch of clicks.
proc tone (seq:string) for x: 1..length(seq) Music.Sound(freq, speed*strint(seq(x))) Music.SoundOff delay(round(1.5*speed)) endfor end tone
loop put"Enter a sentence to convert: "..
var text :string get text :* put"Morse code of \"" + text + "\":" for x: 1..length(text) put text (x)+" "..
iford(text(x)) >= 97andord(text(x)) <= 122then put letters (ord(text(x))-96)
tone (letters (ord(text(x))-96)) elsiford(text(x)) >= 65andord(text(x)) <= 90then put letters (ord(text(x))-64)
tone (letters (ord(text(x))-64)) elsifstrintok(text(x))then put letters (strint(text(x))+26)
tone (letters (strint(text(x))+ 26)) elsif text (x)=" "then put"<Space>" delay(7*speed) else put"<invalid character>" endif delay(3*speed) endfor endloop
Sponsor Sponsor
Cezna
Posted: Wed Jun 16, 2010 6:00 pm Post subject: RE:Morse code translator
Awesome program Insectoid, had a lot of fun messing around with it.
Out of curiosity, why did you use 1's and 3's instead of 1's and 2's or 0's and 1's ?
EDIT: Doohhh !!!
Just realized as I hit submit it must be to control the duration of the beeps....
Insectoid
Posted: Wed Jun 16, 2010 6:39 pm Post subject: RE:Morse code translator
I'm meeting the standard. A short beep is 1 unit long, a long beep is 3, pause between letters is 3 units (I think....) and between words is 7.
Cezna
Posted: Wed Jun 16, 2010 6:43 pm Post subject: RE:Morse code translator
Is the 7 accurate?
Either way, very cool, great work.
Insectoid
Posted: Wed Jun 16, 2010 7:53 pm Post subject: RE:Morse code translator
Yes, the 7 is accurate. What isn't accurate is the space between beeps within individual letters, which should be 1 unit while mine is 1.5. Just worked better.
Cezna
Posted: Wed Jun 16, 2010 8:17 pm Post subject: RE:Morse code translator
You made the right choice, because it works great.
Turing_Gamer
Posted: Thu Aug 19, 2010 2:55 am Post subject: Re: Morse code translator
Really cool but I think the morse code is a little faster than that. Anyway, nice program. I always wanted to convey messages in morse code.
mirhagk
Posted: Thu Aug 19, 2010 8:52 am Post subject: RE:Morse code translator
no if only it could translate from morse code....
Lol maybe this would go into my free ipod app ideas (the idea being make simple but useful and popular apps, but charge no price, but merely have ads, and then a pro version with no ads.
Sponsor Sponsor
Insectoid
Posted: Thu Aug 19, 2010 9:07 am Post subject: RE:Morse code translator
Turing_Gamer, you can make it as fast as you like by changing the constant speed.
If this were to be a phone app, I'd like it to also convert morse to text, and convert text to morse on-the-fly so you don't have to type out the entire sentence before converting. Of course this then presents the issue of typos and backspace, and people who type slower than morse code can be generated.
chrisbrown
Posted: Thu Aug 19, 2010 9:20 am Post subject: Re: RE:Morse code translator
mirhagk @ Thu Aug 19, 2010 8:52 am wrote:
the idea being make simple but useful and popular apps
(The iFart app comes to mind.. simple and disgustingly popular, but probably the most useless app ever)
Turing_Gamer
Posted: Tue Aug 24, 2010 1:25 pm Post subject: RE:Morse code translator
I think the morse to text is way beyond the capability of Turing.
First: You need a fool-proof way of recording Morse. When people contact in Morse, they have their own way of holding the sound. Some go fast while some go slow. So the program need to analyze what is long and what is short and what is a pause.
Second: The sound must be broken up accordingly by pauses, short blips, and long beeps. For this to happen, the code must be further analyzed which far from what Turing can do.
Third: Turing can possibly help with this one. All you have too do is make the 1st one a reference, then match that with the already broken up code, add a little conversion table to tell what beep is what letter and there you go.
In short, if you ever manage to do this with Turing, I commend you.
DemonWasp
Posted: Tue Aug 24, 2010 2:12 pm Post subject: RE:Morse code translator
@Turing_Gamer: As Turing is a Turing-complete language, theoretically such a program is possible. It wouldn't be easy, but it'd be quite possible.
@Turing_Gamer
yeah i cant see it being easy/possible to translate the sound to words, but what if the morse code was entered as text i.e. a 1 represents a tap, a 3 represents a hold, and a " " represents a space.....
then it would be easily possible.
IF I GAVE ANYONE IDEAS, PLEASE GO FORWARD WITH THEM! =D
Srlancelot39, that would work, but the question remains as to how you get that file of characters in the first place. The idea is that you record a string of blips that represent morse code and convert that to a usable string of characters, ie 0's, 1's and 3's, that can then be converted to text.
If all your program does is translate a bunch of 1's and 3's into text, it isn't translating morse. It's just parsing a very strange text format.
Srlancelot39, that would work, but the question remains as to how you get that file of characters in the first place. The idea is that you record a string of blips that represent morse code and convert that to a usable string of characters, ie 0's, 1's and 3's, that can then be converted to text.
If all your program does is translate a bunch of 1's and 3's into text, it isn't translating morse. It's just parsing a very strange text format.
ya it's kinda sad how thats so true...=(.....could still be fun though lol