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 361733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:10:38+00:00 2026-05-12T13:10:38+00:00

I’m making a game in native vc++ (not .Net) I’m looking for a way

  • 0

I’m making a game in native vc++ (not .Net)

I’m looking for a way to play a noise (maybe 8 bit or something) through the real speakers (not internal). I know about PlaySound, but I don’t want to make my EXE big. I want to program the sound.

Is there an api way (kinda like Beep() ) but that plays through the real speakers?

Thanks

  • 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-05-12T13:10:39+00:00Added an answer on May 12, 2026 at 1:10 pm

    You mention that you know about PlaySound. One of the it’s flags (SND_MEMORY) will allow you to play a WAVE that is already loaded into memory, i.e. a buffer that you have created yourself. As long as the buffer has the appropriate WAVE header, whatever you you put in there should play through the speakers.

    The header is a 44 byte block that is fairly straight forward

    struct WaveHeader
    {
        DWORD chunkID;       // 0x46464952 "RIFF" in little endian
        DWORD chunkSize;     // 4 + (8 + subChunk1Size) + (8 + subChunk2Size)
        DWORD format;        // 0x45564157 "WAVE" in little endian
    
        DWORD subChunk1ID;   // 0x20746d66 "fmt " in little endian
        DWORD subChunk1Size; // 16 for PCM
        WORD  audioFormat;   // 1 for PCM, 3 fot EEE floating point , 7 for μ-law
        WORD  numChannels;   // 1 for mono, 2 for stereo
        DWORD sampleRate;    // 8000, 22050, 44100, etc...
        DWORD byteRate;      // sampleRate * numChannels * bitsPerSample/8
        WORD  blockAlign;    // numChannels * bitsPerSample/8
        WORD  bitsPerSample; // number of bits (8 for 8 bits, etc...)
    
        DWORD subChunk2ID;   // 0x61746164 "data" in little endian
        DWORD subChunk2Size; // numSamples * numChannels * bitsPerSample/8 (this is the actual data size in bytes)
    };
    

    You’d set up your buffer with something similar to:

    char *myBuffer = new char[sizeof(WaveHeader) + myDataSize];
    
    WaveHeader *header = (WaveHeader*)myBuffer;
    // fill out the header...
    
    char *data = myBuffer + sizeof(WaveHeader); //jumps to beginning of data
    // fill out waveform data...
    

    So you use it something like:

    PlaySound(myBuffer, NULL, SND_MEMORY | SND_ASYNC);
    

    I’m assuming that you’re going to be using you generated sound for the lifetime of you app. If you aren’t, be careful with that SND_ASYNC flag. That is, don’t go freeing the buffer directly after you call PlaySound (while it is still in use).

    MSDN PlaySound Docs
    A page with more detail on the WAV header (OLD – not working now)

    DirectX also supports playing audio from in-memory buffers and is a much more powerful API, but it maybe overkill for what you need to do 🙂

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

Sidebar

Related Questions

No related questions found

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.