# What is wrong with this method of detecting the presence of a signal?

I am trying to decode Morse code from an audio (wav) file. Here is the technique I am using to detect the presence of the signal:

I have a window of size (sampling_freq/tone), where tone is the frequency of the Morse code tone, as determined by the fft (most prominent tone). I move this window across the entire recording, and for each window location, I detect if there is any signal above a user-defined threshold by checking the samples in that window (sample freq is 11025, tone is 981 Hz.)

This pretty much works, giving dots and dashes where they should appear. HOWEVER: these dots and dashes are not solid; if I zoom in, there are lots of empty spaces which make it difficult (impossible?) to determine where the real dots and dashes are.

How can I fix this, or is there a better approach?

EDIT: I am detecting where dots and dashes are as: when I detect a signal in the window, I make all the entries in a corresponding output array '1' for that same window.

• If you downvote, it is generally useful to leave a comment. – horse hair Jul 24 '14 at 8:25
• Maybe some example, figure? – jojek Jul 24 '14 at 10:35
• @jojek - What sort of example would be useful, figure? – horse hair Jul 24 '14 at 13:41

Let's ignore the practical implementation and assume you have a pure sine : $$y = \sin(2\pi x)$$Now assume you shift your window somewhat: $$y=\sin(2\pi x' + \pi/2)$$