1
votes

I'd really love to see an explicit example of an exclusive-mode audio application which takes its input from line in (not microphone) at a certain input level (volume), and does the absolute minimum to achieve this. (C++ preferred, but anything is better than nothing)

This sounds like it should be simple, but finding out how has been frustratingly hard.

For example, the Device Topologies documentation from Microsoft makes it sound like if you have simple common audio hardware (like on most desktop PCs) and you only want to set volume, mute, or select channel, then you won't need to worry about device topologies because the Device Topologies API is for much more complex devices.

That would be terrific, but it stops short of saying how, and raises other questions: is there a standard for the common desktop PC audio that always seems to provide speaker out, line in, and microphone in? Will line in and microphone always be mixed or multiplexed as a result of such a standard? The diagram in this Device Topologies documentation indicates multiplexing; I have old mixerXXX() code I am trying to upgrade that indicates mixing.

Also, further reading about Endpoint Volume Controls suggests that this may be doable using the IAudioEndpointVolume interface, but the audio examples in the Win 7.1 SDK did not give examples of IAudioEndpointVolume with input devices. The documentation on individual IAudioEndpointVolume functions indicates support for both input and output ("audio stream that enters or leaves the audio endpoint device") but none of those functions seem to support multiplexing, and again indicate mixing of line in and microphone signals.

1

1 Answers

0
votes

In contrast to the old waveXXX() and mixerXXX() APIs, which were complex, confusing and sometimes just didn't even work when things changed, the new Core Audio APIs (often just called WASAPI) are still complex and confusing, but designed to anticipate a changing and networked world. So on that level it is significant progress. But there is still a big diverse audio world out there, and creating all examples for all people is impractical.

If you want a minimal example, start by downloading the Windows SDK, take a look at the audio samples (perhaps CaptureSharedEventDriven or CaptureSharedTimerDriven) and start deleting some of the things that do not matter in your context. Refactoring what remains will be a good exercise to make sure you understand what is going on, and what options you have. For example, if you really need exclusive capture (do you?) you will need to change the IAudioClient::Initialize() parameters accordingly.

To set the input volume level, take a look at the EndpointVolume example. You'll find that this and the other examples mentioned start from selecting an endpoint device. After that, you activate the IAudioEndpointVolume interface, and use it set the desired volume, so that code will be easy to identify and copy across to your refactored example.

However, for mysterious reasons, on some hardware (mine at least) line-in will not be enumerated as an audio endpoint by the IMMDeviceEnumerator instance unless there is something physically plugged into the line-in jack... whereas the microphone input will be found regardless of what is or isn't plugged into it. Which underscores the complex and confusing nature of Windows audio, and leads to questions like this.