Link to home
Start Free TrialLog in
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.
ASKER CERTIFIED SOLUTION
Avatar of rstaveley
rstaveley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jimmn
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;
}