It seems like playing a simple tone is something that should be a primitive in the Gambas Language... A simple Play(frequency, duration) type of function as was found in many of the early BASIC languages. Am I the only one who think like this?
On Fri, Feb 7, 2014 at 4:15 PM, Caveat <gam...@caveat.demon.co.uk> wrote: > A very crude implementation... I first used audacity to generate a basic > tone that lasts a few seconds and saved it as tone.wav. > > The form contains a text box called TextBox1 and a button called Button1. > > The results sound kind of morsey, but you will probably want to play > around with the pauses and lengths of the dots and dashes. > > Private morseTable As Collection > > Public Sub Form_Open() > > Music.Load("/home/jules/Sounds/tone.wav") > setupMorse() > > End > > Public Sub setupMorse() > > morseTable = New Collection > morseTable.Add(".-", "a") > morseTable.Add("-...", "b") > morseTable.Add("-.-.", "c") > morseTable.Add("-..", "d") > morseTable.Add(".", "e") > morseTable.Add("..-.", "f") > morseTable.Add("--.", "g") > morseTable.Add("....", "h") > morseTable.Add("..", "i") > morseTable.Add(".---", "j") > morseTable.Add("-.-", "k") > morseTable.Add(".-..", "l") > morseTable.Add("--", "m") > morseTable.Add("-.", "n") > morseTable.Add("---", "o") > morseTable.Add(".--.", "p") > morseTable.Add("--.-", "q") > morseTable.Add(".-.", "r") > morseTable.Add("...", "s") > morseTable.Add("-", "t") > morseTable.Add("..-", "u") > morseTable.Add("...-", "v") > morseTable.Add(".--", "w") > morseTable.Add("-..-", "x") > morseTable.Add("-.--", "y") > morseTable.Add("--..", "z") > morseTable.Add("-----", "0") > morseTable.Add(".----", "1") > morseTable.Add("..---", "2") > morseTable.Add("...--", "3") > morseTable.Add("....-", "4") > morseTable.Add(".....", "5") > morseTable.Add("-....", "6") > morseTable.Add("--...", "7") > morseTable.Add("---..", "8") > morseTable.Add("----.", "9") > morseTable.Add(".-.-.-", ".") > morseTable.Add("--..--", ",") > morseTable.Add("..--..", "?") > morseTable.Add(".----.", "'") > morseTable.Add("-.-.--", "!") > morseTable.Add("-..-.", "/") > morseTable.Add("-.--.", "(") > morseTable.Add("-.--.-", ")") > morseTable.Add(".-...", "&") > morseTable.Add("---...", ":") > morseTable.Add("-.-.-.", ";") > morseTable.Add("-...-", "=") > morseTable.Add(".-.-.", "+") > morseTable.Add("-....-", "-") > morseTable.Add("..--.-", "_") > morseTable.Add(".-..-.", "\"") > morseTable.Add("...-..-", "$") > morseTable.Add(".--.-.", "@") > End > > Public Sub Button1_Click() > > Dim idx As Integer > Dim aChar As String > For idx = 1 To Len(TextBox1.text) > aChar = Mid$(TextBox1.text, idx, 1) > If aChar = " " Then > Print "Break between words" > ' Pause between words (perhaps do something to eliminate multiple > spaces?) > Wait 0.7 > Continue > Endif > playChar(aChar) > Next > > End Sub > > Public Sub playChar(aChar As String) > > Dim charAsMorse As String > Dim idx As Integer > charAsMorse = morseTable[aChar] > Print "Playing: " & charAsMorse > For idx = 1 To Len(charAsMorse) > If Mid$(charAsMorse, idx, 1) = "." Then > playDot() > Else > playDash() > Endif > ' Pause between individual dots/dashes of a single character > Wait 0.2 > Next > ' Pause between characters of a word > Wait 0.5 > > End > > Public Sub playDot() > > playTone(0.1) > > End > > Public Sub playDash() > > playTone(0.4) > > End > > > > Public Sub playTone(duration As Float) > > Music.Play() > Wait duration > Music.Stop() > > End > > Kind regards, > Caveat > > On 07/02/14 18:49, Ru Vuott wrote: > >> Wow! That's exactly what I was looking for. Great job, vuott. > > Thank you very much, Jesus. > > > >> In the other hand, I suggest Dirk to take a close look at this project > [1], > >> though written in Python, well worth to give it a try, or perhaps > >> trying to convert to gambas the relevant code. > >> > >> [1] > >> > https://code.google.com/p/kochmorse/source/browse/trunk/KochMorse/alsamorse/morse.py > > > > uhmmm... very interesting, Jesus. Is someone able to "convert" that > python code in Gambas ? > > > > Bye > > vuott > > > > > ------------------------------------------------------------------------------ > > Managing the Performance of Cloud-Based Applications > > Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. > > Read the Whitepaper. > > > http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk > > _______________________________________________ > > Gambas-user mailing list > > Gambas-user@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/gambas-user > > > > > > ------------------------------------------------------------------------------ > Managing the Performance of Cloud-Based Applications > Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. > Read the Whitepaper. > > http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk > _______________________________________________ > Gambas-user mailing list > Gambas-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/gambas-user > -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take? ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user