The language used is C and the compiler is GCC.
I am trying to create a program that modulates the sound coming from a microphone using real-time processing and outputs it from a speaker.
Currently, a window with a start and end button and a track bar that displays the frequency is displayed when it starts, and if you press start, there is a lag, but you can input and output. The exit button is now a button that only displays a small window to make sure it starts.

Error message

-There is no error message, but when I press the start button to start I/O, there is no response, and when I press the enter key in the GCC window, it ends. This is a problem, and the cause is unknown.
・ We are currently investigating various things, but we want to use the value of the track bar (HWND) to set the frequency, so we can use it if we can input it to the variable of double. I am currently thinking of using the atof function and am looking for a way to convert HWND type to Const char type. If anyone knows how to convert HWND to double and how to convert to const char, I would love to hear from you.

Applicable source code
#Define BUTTON_ID1 0
#Define BUTTON_ID2 1
#Define ID_TRACK 100
#Define ID_STATIC 101

HWND hTrack, hStatic;
static HWND hButton1;
static HWND hButton2;
char i [128];
int * a = 0;
int b = 0;
int plus1 (int * m);
double fm;
    char buffer [100];
    switch (msg) {
    case WM_DESTROY:
        PostQuitMessage (0);
        return 0;
  case WM_CREATE:
        hStatic = CreateControlWindow (hwnd, 10,10,250,45,0,
                             0, "", "STATIC", (HMENU) ID_STATIC, (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE));
        hTrack = CreateControlWindow (hwnd, 10,60,280,55,0,
                             TBS_AUTOTICKS, "", TRACKBAR_CLASS, (HMENU) ID_TRACK, (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE));
        // Set the track bar range (0-300)
        SendMessage (hTrack, TBM_SETRANGE, TRUE, MAKELONG (300, 1000));
        // Page size setting (10) --->Moving amount when mouse is clickedSendMessage (hTrack, TBM_SETPAGESIZE, 0,10);
        // Set line size (1) --->Movement amount when arrow key is pressed
        SendMessage (hTrack, TBM_SETLINESIZE, 0,1);
        // Position setting (100)
        SendMessage (hTrack, TBM_SETPOS, TRUE, 100);
        // Set the scale size (30)
        SendMessage (hTrack, TBM_SETTICFREQ, 30,0);
        SetFocus (hTrack);
  case WM_HSCROLL:
        if ((HWND) (lp) == hTrack)
        {// display current position
            wsprintf (buffer, "Current frequency is% d [Hz]", SendMessage (hTrack, TBM_GETPOS, 0,0));
               SendMessage (hStatic, WM_SETTEXT, 0, (LPARAM) buffer);
        case WM_COMMAND:
        switch (LOWORD (wp)) {
            case BUTTON_ID1:
                a =&b;
                plus1 (a);
                MessageBox (NULL, "BUTTON_ID1", "Voice Changer", MB_OK);
                EnableWindow (hButton1, FALSE);
                EnableWindow (hButton2, TRUE);
                return FALSE;
            case BUTTON_ID2:
                MessageBox (NULL, "BUTTON_ID2", "Vois", MB_OK);
                EnableWindow (hButton1, TRUE);
                EnableWindow (hButton2, FALSE);
                return FALSE;
        return 0;
    return DefWindowProc (hwnd, msg, wp, lp);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
            PSTR lpCmdLine, int nCmdShow) {
    HWND hwnd;
    MSG msg;
    WNDCLASS winc;winc.style = CS_HREDRAW | CS_VREDRAW;
    winc.lpfnWndProc = WndProc;
    winc.cbClsExtra = winc.cbWndExtra = 0;
    winc.hInstance = hInstance;
    winc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    winc.hCursor = LoadCursor (NULL, IDC_ARROW);
    winc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
    winc.lpszMenuName = NULL;
    winc.lpszClassName = TEXT ("VOIS");
    if (! RegisterClass (&winc)) return -1;
    hwnd = CreateWindow (
            TEXT ("VOIS"), TEXT ("Vois on your lap"),
            NULL, NULL, hInstance, NULL
    hButton1 = CreateWindow (
        TEXT ("BUTTON"), TEXT ("Start"),
        300, 10, 200, 200,
        hwnd, (HMENU) BUTTON_ID1, hInstance, NULL
    hButton2 = CreateWindow (
        TEXT ("BUTTON"), TEXT ("End"),
         300, 300, 200, 200,
        hwnd, (HMENU) BUTTON_ID2, hInstance, NULL
    if (hwnd == NULL) return -1;
    while (GetMessage (&msg, NULL, 0, 0)) DispatchMessage (&msg);
    return msg.wParam;

I didn't originally use the EnableWindow function and thought it was the cause.

Supplemental information (FW/tool version etc.)

GCC → It is MINGW.
The second half of the program such as modulation is omitted due to the limitation of the number of characters.

  • Answer # 1

    Bull, dodox86

    Thank you for your comments. Now works fine with the CreateThread function!

  • Answer # 2

    This is the latter half of the program that could not be displayed due to the character limit.

    int plus1 (int * m)
      char key;
      int n, in0, in1, out0, out1, flag, offset, fs;
        double am;
      short s [BUFFER_SIZE];/* sound data * /
      short in_buffer [NUMBER_OF_BUFFER] [BUFFER_SIZE];/* input buffer * /
      WAVEHDR in_hdr [NUMBER_OF_BUFFER];/* Input buffer header * /
      HWAVEIN in_hdl = 0;/* Handle of sound device * /
      short out_buffer [NUMBER_OF_BUFFER] [BUFFER_SIZE];/* Output buffer * /
      WAVEHDR out_hdr [NUMBER_OF_BUFFER];/* Output buffer header * /
      HWAVEOUT out_hdl = 0;/* Handle of sound device * /
      WAVEFORMATEX wave_format_ex = (WAVE_FORMAT_PCM,/* PCM * /
                                     1,/* Mono * /
                                     10000,/* Sampling frequency (8000Hz) * /
                                     16000,/* Size of sound data per second (16000 bytes) * /
                                     2,/* Minimum unit of sound data (2 bytes) * /
                                     16,/* Quantization accuracy (16bit) * /
                                     0/* Option information size (0 bytes) * /
      / * Open sound device * /
       waveInOpen (&in_hdl, 0,&wave_format_ex, 0, 0, CALLBACK_NULL);
      / * Clear in_hdr by writing 0 * /
       for (in0 = 0;in0