Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8042457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:35:08+00:00 2026-06-05T04:35:08+00:00

I am writing an application where I get sound data using low-latency ASIO card.

  • 0

I am writing an application where I get sound data using low-latency ASIO card. The low-latency means that I get only 128 samples per batch, for 48k sample rate. From the ASIO card, I get raw samples in 32-bit signed integer range.

Now I want to listen to the sound coming through the ASIO card, but not on the ASIO card, but on the default output device in Windows. I am using waveOutWrite set up with WAVE_FORMAT_PCM and the same characteristics as the ASIO input. I call it every time I get a new 128-sample long batch. Now, because Wav format does not allow for 32-bit integer samples, I downgrade them to 16-bits.

HWAVEOUT waveOut;

void startListening(){
    WAVEFORMATEX format;
    format.wFormatTag = WAVE_FORMAT_PCM;
    format.nChannels = 1;
    format.nSamplesPerSec = sampleRate;
    format.nAvgBytesPerSec = sampleRate * 2;
    format.nBlockAlign = 2;
    format.wBitsPerSample = 16;
    format.cbSize = 0;
    MMRESULT result = waveOutOpen(waveOut, WAVE_MAPPER, &format, 0, 0, CALLBACK_NULL);
    if(result != MMSYSERR_NOERROR){
        return;
    }
}

typedef struct{
    short *buffer;
    int length;
    HWAVEOUT waveOut;
} ListenInfo;

void newListeningData(void *buffer, int length){
    ListenInfo *listenInfo = new ListenInfo();
    listenInfo->buffer = new short[length];
    listenInfo->length = length;
    listenInfo->waveOut = *waveOut;
    if(bitrate == 32){
        int *bufferInt = (int *)buffer;
        for(int i = 0; i < length; i++){
            listenInfo->buffer[i] = (bufferInt[i]);
        }
        CreateThread(NULL, 0, &(listen), listenInfo, 0, NULL);
    }
    else if(bitrate == 16){
         memcpy(listenInfo->buffer, (short *)buffer, length * 2);
         CreateThread(NULL, 0, &(listen), listenInfo, 0, NULL);
    }
    else{
        printf("%d: Bitrate is not 16 or 32!\n", index);
    }
}

DWORD WINAPI listen(__in  LPVOID lpParameter){
    ListenInfo *info = (ListenInfo *)lpParameter;
    WAVEHDR header;
    memset(&header, 0, sizeof(WAVEHDR));
    header.dwBufferLength = info->length;
    header.lpData = (char *)(info->buffer);
    MMRESULT result = waveOutPrepareHeader(info->waveOut, &header, sizeof(WAVEHDR));
    result = waveOutWrite(info->waveOut, &header, sizeof(WAVEHDR));
    while(waveOutUnprepareHeader(info->waveOut, &header, sizeof(WAVEHDR)) == WAVERR_STILLPLAYING){
        Sleep(10);
    }
    delete[] info->buffer;
    delete info;
    return 0;
}

The problem is that I can hear only severe clipping and squeaking. The sound is distorted beyond recognition. I know it is not a synchronization error, because I also save the samples into a wav file with the same characteristics and the sound is distorted in the same way.

How can I convert signed 32-bit samples into something that waveOutWrite can play?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:35:09+00:00Added an answer on June 5, 2026 at 4:35 am

    The problem was cause by the fact that I was using different bitrate than I was led to believe I was using. When I modified the WAVEFORMATEX with correct values, it worked!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an application that listens for sound events (using messages passed in with
I am writing a web application that allows a user to get an employee's
I writing simple application that need to make some record of the incoming sound.
I am writing C# application that need to print data to POS STAR printer
I'm writing an application that has 5 threads that get some information from web
I am writing application using c++, in windows. I want to get a thumbnail
While writing an application that interacts with a database the only way I can
I am writing a small application to get the various diagnostic parameter of Apache
I'm writing an Android application, which uses AccountManager to get the token. From an
I'm writing my first Android application and trying to get my head around communication

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.