?
Solved

Low level MM in win32

Posted on 1999-01-28
7
Medium Priority
?
262 Views
Last Modified: 2010-04-15
In linux you can play or record sound (from sound card) just with opening file "dev/dsp" and change settings with ioctl. Are there similar functions in win32 API? Please any short working example.
0
Comment
Question by:abmo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1258492
Yes, there is something similar.

You should use mixerSetControlDetails() and mixerGetControlDetails(). Also look into mixerGetLineControls().
0
 

Author Comment

by:abmo
ID: 1258493
Sorry for rejecting, but can you insert some working example which can play (or record) something?  
0
 
LVL 1

Expert Comment

by:The_Raven
ID: 1258494
Play Sound...

#define MSG_SIZE 1024
char Msg[MSG_SIZE+1];

mciSendString("open test.wav type waveaudio alias mywave",Msg, MSG_SIZE, (HANDLE)hWnd);
mciSendString("set mywave time format samples",Msg, MSG_SIZE, (HANDLE)hWnd);
mciSendString("play mywave from 1 waid",Msg, MSG_SIZE, (HANDLE)hWnd);
mciSendString("close mywave",Msg, MSG_SIZE, (HANDLE)hWnd);

------------------------------------------------------------
Record Sound...

mciSendString("open new type waveaudio alias mywave",Msg, MSG_SIZE, (HANDLE)hWnd);
mciSendString("record mywave",Msg, MSG_SIZE, (HANDLE)hWnd);

// Do something here until record is terminated

mciSendString("stop mywave",Msg, MSG_SIZE, (HANDLE)hWnd);
mciSendString("save mywave tst.wav",Msg, MSG_SIZE, (HANDLE)hWnd);
mciSendString("close mywave",Msg, MSG_SIZE, (HANDLE)hWnd);

That is the easyest way to do it.

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:abmo
ID: 1258495
Ehm, sorry, that is for MCI and wave file. But isn´t there any possibility to read and write sound as a file (or something similar)?
Exactly I need to display "volume" in peaks of dB of incoming sound (so I need to "read" samples to memory), analyze it (at a sampling rate of 32000Hz) in real time, and then record (only good :-) samples) or do something. And I think there should be some low level MM functions to do that, but I didn´t found it yet...
Can you help me?
0
 

Expert Comment

by:core123
ID: 1258496
Look for some documentation on the waveIn* functions such as waveInOpen(), they'll enable you to record sound on the windows system.  Hope you can find some :)
0
 
LVL 1

Accepted Solution

by:
The_Raven earned 300 total points
ID: 1258497
Are you looking for a double buffering system, something like this ? (This is something I wrote using Imprise C++ Builder)

VOID StartRecord(void)
{
   MMRESULT rc;
   int      i;
   MMTIME   mmtime;

// prepare buffer blocks and add to input queue
//.............................................

for (i = 0; i < MAX_BUFFERS; i++)      {                                                              
  rc = waveInPrepareHeader(hwi, wh[i], sizeof(WAVEHDR));    
  // add buffers to the input queue                            
  if (rc == MMSYSERR_NOERROR)
    rc = waveInAddBuffer(hwi, wh[i], sizeof(WAVEHDR));
   if (rc != MMSYSERR_NOERROR
   {waveInGetErrorText(rc, msg, MSG_LEN),                        
    MessageBox(Application->Handle, msg, NULL, MB_OK);
    StopRecord();  // free allocated memory
    return; }
                                    }
// start recording                                              
//................                                              
                                                                   rc = waveInStart(hwi);
    mmtime.wType = TIME_SAMPLES;
    rc = waveInGetPosition(hwi, &mmtime, sizeof(MMTIME));
    if (rc != MMSYSERR_NOERROR)
    {
      waveInGetErrorText(rc, msg, MSG_LEN),
      MessageBox(Application->Handle, msg, NULL, MB_OK);
    }                                          
}
0
 

Author Comment

by:abmo
ID: 1258498
YES YES YES, that it is, thank you all. It is a bit more complicated, than I thinked about. The_Raven just can you add some note (example) on how to get "hwi" handler?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question