|
Post by Rod on Jul 9, 2020 16:02:19 GMT
There are two discussions going here, both about very different timing issues.
Morse is fairly precisely timed given its a human generating it, dots have a specific timed length, dashes have a specific timed length and so too the silences in between characters and words.
Now outputting Morse from a text file just needs to use all of those timings and you would be best to use pre defined dot, dash .wav and silences. But it is relatively easy to generate precise sounding Morse.
Honkytonk on the other hand is wanting to mimic a Morse Key using the keyboard or mouse. ie a human generating the Morse timing. Quite a different problem, getting the keyboard or mouse to react instantly and mimic a true Morse key.
I thought we had solved that in a previous thread using the key up event.
|
|
|
Post by zzz000abc on Jul 9, 2020 17:59:16 GMT
There are two discussions going here, both about very different timing issues. Morse is fairly precisely timed given its a human generating it, dots have a specific timed length, dashes have a specific timed length and so too the silences in between characters and words. Now outputting Morse from a text file just needs to use all of those timings and you would be best to use pre defined dot, dash .wav and silences. But it is relatively easy to generate precise sounding Morse. Honkytonk on the other hand is wanting to mimic a Morse Key using the keyboard or mouse. ie a human generating the Morse timing. Quite a different problem, getting the keyboard or mouse to react instantly and mimic a true Morse key. I thought we had solved that in a previous thread using the key up event. Rod exactly where you are. If call the dot and dash ,Morse Codes (mc) then a dot should be played for 1 unit time and dash should be played for 3 units time , the time between two successive mc's should be 1 unit , the time between two successive characters should be 3 units and that of two successive words should be 7 units.
|
|
|
Post by tsh73 on Jul 9, 2020 21:21:51 GMT
I made a 5 second Sine audio (440 Hz) by Audacity (attached) and tried to turn it on and off by clicking mouse or holding Ctrl. While mouse works unreliably, I would say that pressing/releasing Ctrl works (sounds?) really nice. nomainwin open "hold LMButton for tone" for graphics_nsb_nf as #gr #gr "trapclose [quit]" #gr "down; home; posxy cx cy" #gr "when leftButtonDown [startBeep]" #gr "when leftButtonUp [endBeep]" #gr "when characterInput [keyPressed]" #gr "size 2" x = 2: y = 2
ctrl$ = chr$(_VK_CONTROL) ctrlDown$ = chr$(8)+ctrl$ ctrlUp$ = chr$(0)+ctrl$
timer 50, [tick]
wait
[tick] x=x+2 if x > cx*2 then x=2:y=y+4 if y>cy*2 then x=2:y=y+2:#gr "cls" if started then #gr "set ";x;" ";y wait
[keyPressed] ' print len(Inkey$), asc(mid$(Inkey$, 1, 1)), asc(mid$(Inkey$, 2, 1)) if Inkey$= ctrlDown$ then [startBeep] if Inkey$= ctrlUp$ then [endBeep] wait
[startBeep] started = 1 playwave "media\sin5sec440.wav", async wait
[endBeep] started = 0 playwave "" wait
[quit] playwave "" close #gr end
Attachments:sin5sec440.zip (250.33 KB)
|
|
|
Post by honkytonk on Jul 10, 2020 22:56:56 GMT
@:tsh73: Your code works very well, but when it is integrated (what I did), it is the execution times (time calculation, display, appendices ...), which make the latency.
|
|
|
Post by Rod on Jul 11, 2020 10:21:15 GMT
We have been discussing this "latency" issue for a few months now and I am a bit confused. We found that using the Alt key (which issues a key down and key up message) there was no latency at all and the morse sounded pretty good.
So if you have latency you have introduced it within your code. You should show us that code so that we can properly understand where the latency comes from. Then we might be better able to show you how to avoid it.
if you are trying to process code during the keypress monitoring there may not be an answer. But, you might minimise the interference by recording the keypresses and processing it all later.
|
|
|
Post by honkytonk on Jul 11, 2020 10:28:29 GMT
But, you might minimise the interference by recording the keypresses and processing it all later. Very good idea.
|
|
|
Post by tsh73 on Jul 11, 2020 13:41:42 GMT
|
|