Solved

FAST SERIOUS QUESTION: Need to detect default WaveOut device!

Posted on 2004-04-28
15
914 Views
Last Modified: 2012-06-27
Hi All,

I need to know what WaveOut device Windows uses as default... I need it for automatical setting device number for function:

WaveOutOpen(@FWaveOutHandle, 0, @FFormat.Format, FOutHandle, 0, CALLBACK_WINDOW or WAVE_MAPPED);

second 0 is device ID, I need to know default device ID... Because device 0 sometimes does not work properly.

Thanks.
0
Comment
Question by:dosware
[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
  • 5
  • 3
15 Comments
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 10937106
use the WAVE_MAPPER parameter for Default device

FOutHandle must be  WAVE_MAPPER
0
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 10937113
use WAVE_MAPPER instead of 0 , it'll set the device id to the  device id which windows uses as default

control panel->Audio->Sound Playback Default Device
0
 

Author Comment

by:dosware
ID: 10937114
But WAVE_MAPPER defined as -1?! Are you think that it will work?

Ok, thanks for answer, I will try it now.
0
Industry Leaders: 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!

 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 10937119
WaveOutOpen(@FWaveOutHandle, WAVE_MAPPER, @FFormat.Format, FOutHandle, 0, CALLBACK_WINDOW or WAVE_MAPPED);
0
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 10937131
first 0 is device id no second 0
you should use WAVE_MAPPER instead of first 0
0
 

Author Comment

by:dosware
ID: 10937166
As I understand I should use same constant for WaveInOpen also?

WaveInOpen(@FWaveInHandle, WAVE_MAPPER, @FFormat.Format, FInHandle, 0, CALLBACK_WINDOW or WAVE_MAPPED);
0
 

Author Comment

by:dosware
ID: 10937176
Unfortunately it does not work :(

I can not hear voice stream when I use WAVE_MAPPER
0
 

Author Comment

by:dosware
ID: 10937221
It normally works when I use:

WaveInOpen(@FWaveInHandle, WAVE_MAPPER, @FFormat.Format, FInHandle, 0, CALLBACK_WINDOW);
WaveOutOpen(@FWaveOutHandle, WAVE_MAPPER, @FFormat.Format, FOutHandle, 0, CALLBACK_WINDOW);

Is it correct code?
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 10937261
yes it is...for more explanation take a look at the WIndows SDK help (that comes with delphi)...

from there:

MMRESULT waveInOpen(LPHWAVEIN phwi, UINT uDeviceID, LPWAVEFORMATEX pwfx,

    DWORD dwCallback, DWORD dwCallbackInstance, DWORD fdwOpen);


phwi

Address filled with a handle identifying the open waveform-audio input device. Use this handle to identify the device when calling other waveform-audio input functions. This parameter can be NULL if WAVE_FORMAT_QUERY is specified for fdwOpen.

uDeviceID

Identifier of the waveform-audio input device to open. It can be either a device identifier or a handle of an open waveform-audio input device.You can use the following flag instead of a device identifier:

WAVE_MAPPER

The function selects a waveform-audio input device capable of recording in the specified format.
[...]
***
MMRESULT waveOutOpen(LPHWAVEOUT phwo, UINT uDeviceID,

    LPWAVEFORMATEX pwfx, DWORD dwCallback, DWORD dwCallbackInstance,
    DWORD fdwOpen);
MMRESULT waveOutOpen(LPHWAVEOUT phwo, UINT uDeviceID,

    LPWAVEFORMATEX pwfx, DWORD dwCallback, DWORD dwCallbackInstance,
    DWORD fdwOpen);
phwo

Address filled with a handle identifying the open waveform-audio output device. Use the handle to identify the device when calling other waveform-audio output functions. This parameter might be NULL if the WAVE_FORMAT_QUERY flag is specified for fdwOpen.

uDeviceID

Identifier of the waveform-audio output device to open. It can be either a device identifier or a handle of an open waveform-audio input device.You can use the following flag instead of a device identifier:

WAVE_MAPPER

The function selects a waveform-audio output device capable of playing the given format.
[...]
0
 

Author Comment

by:dosware
ID: 10937293
I know it, but are you seeing differences between two codes?

WaveInOpen(@FWaveInHandle, WAVE_MAPPER, @FFormat.Format, FInHandle, 0, CALLBACK_WINDOW or WAVE_MAPPED);
WaveInOpen(@FWaveInHandle, WAVE_MAPPER, @FFormat.Format, FInHandle, 0, CALLBACK_WINDOW);

First variant does not work! Why?
0
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 500 total points
ID: 10937349
WAVE_MAPPED

If this flag is specified, the uDeviceID parameter specifies a waveform-audio device to be mapped to by the wave mapper.

then

Use the waveOutGetNumDevs function to determine the number of waveform-audio output devices present in the system. If the value specified by the uDeviceID parameter is a device identifier, it can vary from zero to one less than the number of devices present.
So
If there are 3 output devices then UdeviceID can be from 0 to 2
but as WAVE_MAPPER is -1 ( that is the constant for using the default deviceID) using it combined with WAVE_MAPPED flag does not work because it must be at least 0, never -1
0
 

Author Comment

by:dosware
ID: 10937363
OK, this is what I wanted to know! Thanks!
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 10937367
For WaveInOpen it's the same...the only differece is the function to get the waveform-audio output devices number that is waveInGetNumDevs
0
 

Author Comment

by:dosware
ID: 10937383
Thanks bud! You really have helped me!
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 10937401
Glad to have helped you. :)

Good work.

F68 ;-)
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

617 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