L
L
lxtral2014-02-27 21:55:05
C++ / C#
lxtral, 2014-02-27 21:55:05

UPDATE! Loudness Leveling (WinAPI, ICodecAPI, DirectShow, Core Audio Interface, MMDevice API, DeviceTopology API)

In Windows, there is a "Volume equalization" (Sound - Playback - Select a device - Additional features).
When watching a video, the volume is at the same level (voice and effects sound equally loud), but listening to music is impossible - all the dynamics are killed.
Tired of opening the settings 50 times a day to turn on / off the checkbox. I decided to write a utility that hangs in the tray and does it in one click. But I ran into a problem :) All examples are in C ++, which I am not familiar with.
What we have:
1. There is an ICodecAPI interface (goo.gl/4Fb0WR)
2. Using the SetValue method, you can set the value for the CODECAPI_AVDSPLoudnessEqualization (goo.gl/eqzKfv) property, which turns alignment on/off.
What he wrote:

#include "stdafx.h"
#include <Dshow.h>
#pragma comment(lib, "strmiids")

int _tmain(int argc, _TCHAR* argv[])
{
  HRESULT hr = CoInitialize(NULL);
  ICodecAPI *myCodecAPI = NULL;
  VARIANT VResult;

  hr = CoCreateInstance(
    CLSID_FilterGraph,
    NULL,
    CLSCTX_INPROC_SERVER,
    IID_IGraphBuilder,
    (void**)&myGraphBuilder
    );

  hr = myGraphBuilder->QueryInterface(IID_ICodecAPI, (void**)&myCodecAPI);

But there is no CODECAPI_AVDSPLoudnessEqualization property in myCodecAPI->GetValue.
Am I moving in the right direction?
Another such moment - we set the volume equalization for a specific output device, which means we need to programmatically get this device and access its settings. How to do it?
I really hope for help. Maybe someone has come across this. Tell me what to read in this direction?
UPDATE
They suggested that you need to dig in the direction of the MMDevice API.
Got the default playback device. Now you need to somehow get to its settings. Found the IAudioLoudness interface ( goo.gl/i1UEIC ), but how do I use it?
Here is a listing of what happened:
#include "stdafx.h"
#include "Mmdeviceapi.h"
#include "Functiondiscoverykeys_devpkey.h"

int _tmain(int argc, _TCHAR* argv[])
{
        HRESULT hr = CoInitialize(NULL);
        if (SUCCEEDED(hr))
        {
                IMMDeviceEnumerator *pEnum = NULL;
                hr = CoCreateInstance(
                        __uuidof(MMDeviceEnumerator),
                        NULL,
                        CLSCTX_ALL,
                        __uuidof(IMMDeviceEnumerator),
                        (void**)&pEnum);
                if (SUCCEEDED(hr))
                {
                        IMMDevice *pDevice;
                        hr = pEnum->GetDefaultAudioEndpoint(
                                eRender,
                                eMultimedia,
                                &pDevice);
                        if (SUCCEEDED(hr))
                        {
                                IPropertyStore *pStore;
                                hr = pDevice->OpenPropertyStore(STGM_READ, &pStore);
                                if (SUCCEEDED(hr))
                                {
                                        PROPVARIANT friendlyName;
                                        PropVariantInit(&friendlyName);
                                        hr = pStore->GetValue(
                                                PKEY_Device_DeviceDesc,
                                                &friendlyName);
                                        if (SUCCEEDED(hr))
                                        {
                                                printf("Audio Device: %i\n", friendlyName.pwszVal);
                                                PropVariantClear(&friendlyName);
                                        }
                                        pStore->Release();
                                }
                                pDevice->Release();
                        }
                        pEnum->Release();
                }
        }
        return hr;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AxisPod, 2014-02-28
@AxisPod

Well, your requirement says one thing, that sucks sound or acoustics, or all together at once. Usually the problem is different, it's hard to listen to Russian dubbing, because for some reason ours have a mania for lowering the volume of the voice in comparison with the original.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question