Morse code sound effect using Beep() function

678 Views Asked by At

I would like to record speaker's output of my morse code. The code is written in C based on Beep function to play the beep sound. I am using Audacity to record the speaker's output. Here is the code :

/* Send  character  in  morse  code */
void  MCSendChar(unsigned  char ch){
    unsigned  char a = asciiToMC(ch);
    unsigned  char n = a & 0x07 , j;

    for(j = 0; j < n; j++) {
        if((0x80 & a) != 0)
            Beep(500,40);
        else
            Beep(500,120);

        a = a << 1;
        //  Inter  Symbol spacing
        Beep(0,40); 
    }

    //  Inter  character  space
    Beep(0,120);
}

I have a confusion about setting the frequency and the wpm. Also, when I tried to decode the recorded file using an online web decoder, the results are not correct at all. Any Ideas ?

1

There are 1 best solutions below

0
On

Assuming Beep() is the win32 function, from MSDN on the dwFreq parameter:

The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).

So you must implement the pauses by some other means than using Beep(), for example using Sleep()