MorseKOB / PyKOB

Python implementation of a library for Morse and MorseKOB functionality
https://sites.google.com/site/morsekob/morsekob40
MIT License
4 stars 2 forks source link

Speaker lags key #158

Closed leskerr closed 7 months ago

leskerr commented 4 years ago

The simulated sounder lags behind the key by ~125ms when using a Key & Sounder interface. This much delay makes it very difficult to send on a bug. Ideally it would be 15ms or less.

AESilky commented 4 years ago

I captured trace images to show the delay.

image Trace 1: Showing dit on key, the sounder drive output, and the 'click' and 'clack' from the speaker. (50ms/Div)

image Trace 2: Showing key down to 'click' from the speaker. (50ms/Div)

image Trace 3: Showing key up to 'clack' from the speaker. (50ms/Div)

image Trace 4: Showing key down to sounder drive output. (1ms/Div)

Traces 1, 2, and 3 show that the speaker 'click' lags the key down by ~125ms (as indicated by Les) and the speaker 'clack' lags the key up by ~100ms.

Trace 4 shows that the sounder drive lags the key by ~7ms. It also shows the key bounce on the key down. On this particular key the bounce is complete after 4.5ms.

AESilky commented 4 years ago

Image of the 'click' and 'clack' waveforms.

image Image 1: Click waveform

image Image 2: Clack waveform

These show that the 'click' and 'clack' sound files have 12ms-13ms of unneeded lead-in. This doesn't account for the entire 125ms delay, but removing it should reduce the delay.

AESilky commented 4 years ago

I would like to improve this to the point it is usable - as I use MKOB with a key (only) and the 'simulated sounder' with headphones to listen to, and practice Morse in the late evening.

I love the sound of my sounder(s) - but they permeate the house, and I simply can't use them late at night. Using the simulated sounder allows me to turn down the volume or to put headphones/earphones on.

AESilky commented 4 years ago

After removing the 'dead' space at the beginnings of the 'click' and 'clack' audio files I now get this:

image Showing that the delay was reduced. We still have work to do, but this reduces 10ms of it.

leskerr commented 4 years ago

Those traces are very cool!

I once tried trimming off the beginning of the audio waveforms like you did, and decided it was a bad idea. It alters the sound of the clicks and clacks to the point of making them unnatural and unpleasing (to my ear, at least). What you're hearing at the beginning isn't really superfluous, it represents the initial movement of the sounder's lever before it hits the stop and makes the 'click' or 'clack'.

I also experimented with artificial 'click' and 'clack' waveforms that had very quick rise times, but they sounded terrible.

jchausler commented 4 years ago
Hi Ed,I enjoyed the traces.  Have you ever considered doing the same thing with version 2.5 to see what the differences are? You know, you can quiet down telegraph sounders quite a lot by setting the lever travel to a very narrow range like a single thickness of paper at the front stop.  You may also then be able to adjust the spring force to lighten it a bit which can reduce the sound level even more although not so much that you don't clearly hear the "clack" distinctly.  When I want to adjust a sounder, either louder or softer, once I set the lever travel I then connect to wire 107 (35WPM provided by Les) to adjust the spring force so that I clearly hear the clicks and clacks and that they are appropriately spaced.  Sometimes a little further adjustment of the lever travel is necessary, the two interact.  Once the sounder sounds "good" and the sound level is what I want, I then return to the slower wires to which I usually listen and all is good.  I usually keep my sounders here at home relatively quiet so as not to pound out my eardrums to the point that at times when I have taken them "on the road" for a display in a large hall, I find I (and the public) can't hear them that well and so have to reverse the process and widen the lever travel and increase the spring force.  Just FYI.On an entirely different subject, what do you think of RIGOL scopes?  I was ready to buy a RIGOL scope one year while attending the Dayton Hamvention to help man the MTC's booth we had there for a number of years.  However the vendor was also selling a number of them "as is" which had been returned non-functional by their customers leading me to assume that there were either quality control problems with them or that they were un-repairable, so I passed.  But at a quarter of the price of an equivalent TEK scope they certainly were attractive.  I'm sill mulling over whether I want to spend around $2500 for a TEK scope.  Scopes are one of those tools for which there is no real alternative :-)73, Chris-----Original Message----- From: Ed Silky Sent: Oct 29, 2020 7:18 AM To: MorseKOB/PyKOB Cc: Subscribed Subject: Re: [MorseKOB/PyKOB] Speaker lags key (#158) I would like to improve this to the point it is usable - as I use MKOB with a key (only) and the 'simulated sounder' with headphones to listen to, and practice Morse in the late evening. I love the sound of my sounder(s) - but they permeate the house, and I simply can't use them late at night. Using the simulated sounder allows me to turn down the volume or to put headphones/earphones on. —You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.
AESilky commented 4 years ago

@leskerr although I couldn't hear the difference, I will trust your ear and I'll undo my change to those files.

leskerr commented 4 years ago

Thanks @AESilky. I hate to make you undo stuff, but that's what Git is so good at.

AESilky commented 4 years ago

@jchausler I can easily run the same with the 2.5 version. I was planning to do that, but ran out of time last night/this morning.

In addition to avoiding the noise, using the computer audio allows me to just use my 'key cable' to attach my stand-alone key to the computer while I sit on the sofa. No power or bulk of the sounder.

I spent many, many, years using Tek scopes and was also the resident goto person when we first got a brand new HP digital storage scope (others had a hard time getting used to the fact that it would continue to show the trace even when the circuit was turned off). However, I couldn't really justify the price of a Tek 4 channel, 100mhz storage scope for my home/hobby use.

AESilky commented 4 years ago

As @jchausler suggested and I had planned on - here are traces from MKOB 2.5.

image Trace 1B: Key 'dit' with sounder drive and speaker output. 50ms/div

image Trace 2B: Key down to sounder and speaker 'click' output. 50ms/div

image Trace 3B: Key up to sounder and speaker 'clack' output. 50ms/div

image Trace 4B: Key (showing bounce) to sounder drive. 1ms/div

image Trace 5B: 'H' from a bug. 50ms/div

This shows that on MKOB 2.5:

leskerr commented 4 years ago

This is really interesting stuff! The 42ms lag is way too long for comfortable sending, in my opinion. I've already noticed that with MorseKOB 2.5 and been bothered by it.

The last time I had good audio performance was with Windows XP. When Microsoft came out with Vista, the audio stopped working. I had to switch to DirectSound, and it's never been the same since.

It would be very interesting to get the same traces with XP. I may have an old computer somewhere that still has XP on it, but I think I gave it to a friend. To disable DirectSound, you need to go to the Tools > Debug screen in MorseKOB and uncheck the DirectSound option (which is normally enabled by default every time you start the program).

Low latency audio has been the # 1 challenge ever since I started working on Morse software.

AESilky commented 4 years ago

I want to make sure I'm correct in thinking that the latency is mostly a problem when you are sending (or practicing) with a key and using the computer audio (simulated sounder). If you are just listening to code the latency doesn't matter (within reason).

However, I can see it becoming an issue (outside of sending) if the latency between playing a click and a clack becomes too great when you are listening to some higher speed code.

I should put a microphone at the physical sounder and get that as the 4th trace. That way we can see the true audio output from the sounder and not just the sounder drive signal. I should also do a trace with a KOB, such that there isn't any MKOB induced delay in the sounder.

jchausler commented 4 years ago
Hi Les,Interesting.  I had not thought of this before because for all practical purposes I have only been using real sounders for years now (real men use real sounders ;-)  Using a sounder driver configuration so the sounder and key are in separate loops thus the sounder only sounds when the computer operates the RTS signal, and turning computer sound on as well, the delay between the real sounder and the computer sound sounder is quite noticeable and somewhat annoying (is there an echo in here :-).  However, if I disable the real sounder I don't find the delayed feedback from the computer sound impacts my ability to send with a bug in the 20 to 25 CPS range (that's as fast as I can send :-) although I do notice the slight delay.  I suspect it might have a bigger impact at higher speeds.  But you know what they say, 20 is plenty :-)  At least from what I've seen the delay from key actuation to computer sound, both click and clack, seems to be of a constant duration, which is a good thing.  If it varied, that would cause havoc.  Of course this is all with 2.5 and Windows 7.  Your mileage may vary...A side note, I turned off Direct Sound and got a weird result.  When I sent dashes with my bug I would still hear the computer sound but when I set faster dots, I would here the first dot and then none of the rest of the dots in the dot stream.  The real sounder operated normally.  Turning Direct Sound on again fixed it of course.73, Chris-----Original Message----- From: Les Kerr Sent: Oct 30, 2020 2:39 AM To: MorseKOB/PyKOB Cc: "J. Chris Hausler" , Mention Subject: Re: [MorseKOB/PyKOB] Speaker lags key (#158) This is really interesting stuff! The 42ms lag is way too long for comfortable sending, in my opinion. I've already noticed that with MorseKOB 2.5 and been bothered by it. The last time I had good audio performance was with Windows XP. When Microsoft came out with Vista, the audio stopped working. I had to switch to DirectSound, and it's never been the same since. It would be very interesting to get the same traces with XP. I may have an old computer somewhere that still has XP on it, but I think I gave it to a friend. To disable DirectSound, you need to go to the Tools > Debug screen in MorseKOB and uncheck the DirectSound option (which is normally enabled by default every time you start the program). Low latency audio has been the # 1 challenge ever since I started working on Morse software. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
leskerr commented 4 years ago

I want to make sure I'm correct in thinking that the latency is mostly a problem when you are sending (or practicing) with a key and using the computer audio (simulated sounder). If you are just listening to code the latency doesn't matter (within reason).

However, I can see it becoming an issue (outside of sending) if the latency between playing a click and a clack becomes too great when you are listening to some higher speed code.

That's right. It's only a problem when sending. When you're listening, the latency is irrelevant, even at higher speeds. There's no additional latency between the click and the clack, as far as I know. There's just a delay in getting the sound engine started after it's been idle for some period of time.

jchausler commented 4 years ago
Hi Les,Yes, as long as the latency is of constant duration from program "actuation" to computer sound and the same for click and clack, there shouldn't be a problem even at high speeds for just listening to incoming data.  If program "actuation" is local, from a key, then I wouldn't want it to be any longer than the 42 ms which has been measured with 2.5 and even shorter would be better.  73, Chris-----Original Message----- From: Les Kerr Sent: Oct 30, 2020 12:48 PM To: MorseKOB/PyKOB Cc: "J. Chris Hausler" , Mention Subject: Re: [MorseKOB/PyKOB] Speaker lags key (#158) I want to make sure I'm correct in thinking that the latency is mostly a problem when you are sending (or practicing) with a key and using the computer audio (simulated sounder). If you are just listening to code the latency doesn't matter (within reason). However, I can see it becoming an issue (outside of sending) if the latency between playing a click and a clack becomes too great when you are listening to some higher speed code. That's right. It's only a problem when sending. When you're listening, the latency is irrelevant, even at higher speeds. There's no additional latency between the click and the clack, as far as I know. There's just a delay in getting the sound engine started after it's been idle for some period of time. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
AESilky commented 7 months ago

This is fixed now. I moved the activation of the sound/sounder into the key processing, immidiately after the key close/open is detected. It was being done later, which included the key de-bounce time and well as some additional processing, thereby causing the delay.

leskerr commented 7 months ago

Outstanding! I may not get a chance to try this, but I'm delighted to hear that it's been fixed. Good work!

~Les

On Wed, Mar 13, 2024 at 6:06 PM Ed Silky @.***> wrote:

This is fixed now. I moved the activation of the sound/sounder into the key processing, immidiately after the key close/open is detected. It was being done later, which included the key de-bounce time and well as some additional processing, thereby causing the delay.

— Reply to this email directly, view it on GitHub https://github.com/MorseKOB/PyKOB/issues/158#issuecomment-1996211261, or unsubscribe https://github.com/notifications/unsubscribe-auth/APHISTIX2L5AFOXPWJ22ACLYYDZ2TAVCNFSM4SVEXLU2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJZGYZDCMJSGYYQ . You are receiving this because you were mentioned.Message ID: @.***>