Avatar of jimmn
jimmn
 asked on

Can I use all the Windows WAVE record and playing APIs using just a simple non-windows console?

I have a project coming up that needs do the following:
1. Receive audio input from the mic/input device.
2. Packetize it.
3. Send it to a receiving client through unicast UDP.
4. Play the audio.
5. Repeat from 1.
Ideally this will be a 2 way application.

My question is, I am not familiar enough with the Windows framework to program it using all the winmain stuff yet.  So I am not sure if I can do what I want just through a main() application.  It looks as though alot of the stuff might require handlers and such and I want to avoid this if possible since I don't need any GUI, just a command prompt.

Can you please verify if I can or cannot do this?

I am marking this as fairly urgent b/c I would like to know if I should abandon this project or not.

Thank you!
-Jim M.
C++

Avatar of undefined
Last Comment
jimmn

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
rstaveley

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jimmn

ASKER
I have the following code.  I'm not sure how I need to set the wave format variables in order to use the GSM 6.10 codec from Microsoft.  How does one know this information?  Right now I'm using some guess values based on PCM, which are probably wrong.  I don't know where I"d look this information up.  As you can guess, I always get a failed test.

#include <windows.h>
#include <mmsystem.h>
#include <mmreg.h>
#include <iostream>

int main()
{
    WAVEFORMATEX wfx;
    wfx.wFormatTag = WAVE_FORMAT_GSM610;
    wfx.nChannels = 1; //mono
    wfx.nSamplesPerSec = 11025;
    wfx.wBitsPerSample = 0;
    wfx.nBlockAlign = 65;
    wfx.nAvgBytesPerSec = 1625;
    wfx.cbSize = 2; // from sizeof(GSM610WAVEFORMAT)-sizeof(WAVEFORMATEX)

    MMRESULT mmri = waveInOpen(
        NULL,                 // ptr can be NULL for query
        WAVE_MAPPER,            // the device identifier
        &wfx,                 // defines requested format
        NULL,                 // no callback
        NULL,                 // no instance data
        WAVE_FORMAT_QUERY);  // query only, do not open device

    if(!mmri ==  MMSYSERR_NOERROR )
    {
        printf("error getting GSM caps\n");
        return -1;
    }
    printf("Success!\n");

    return 0;
}
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes