Click here to Skip to main content
15,885,782 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Stuck with 'Loudness Equalization' Pin
Mark Salsbery15-Jul-11 5:54
Mark Salsbery15-Jul-11 5:54 
GeneralRe: Stuck with 'Loudness Equalization' Pin
Malli_S15-Jul-11 20:27
Malli_S15-Jul-11 20:27 
GeneralRe: Stuck with 'Loudness Equalization' Pin
Richard MacCutchan15-Jul-11 7:12
mveRichard MacCutchan15-Jul-11 7:12 
GeneralRe: Stuck with 'Loudness Equalization' Pin
Malli_S15-Jul-11 20:29
Malli_S15-Jul-11 20:29 
GeneralRe: Stuck with 'Loudness Equalization' Pin
Richard MacCutchan15-Jul-11 22:32
mveRichard MacCutchan15-Jul-11 22:32 
GeneralRe: Stuck with 'Loudness Equalization' Pin
Malli_S16-Jul-11 17:27
Malli_S16-Jul-11 17:27 
GeneralRe: Stuck with 'Loudness Equalization' Pin
Richard MacCutchan16-Jul-11 21:50
mveRichard MacCutchan16-Jul-11 21:50 
GeneralRe: Stuck with 'Loudness Equalization' Pin
Malli_S17-Jul-11 1:14
Malli_S17-Jul-11 1:14 
#include <objbase.h>
#include <audioenginebaseapo.h>
#include <stdio.h>
#include <stdlib.h>
#include <wmcodecdsp.h>

APO_CONNECTION_DESCRIPTOR inDesc = {
    APO_CONNECTION_BUFFER_TYPE_EXTERNAL, // APO_CONNECTION_BUFFER_TYPE
    NULL,
    0, // u32MaxFrameCount
    NULL,
    APO_CONNECTION_DESCRIPTOR_SIGNATURE
}, *pInDesc = &inDesc,
outDesc = {
    APO_CONNECTION_BUFFER_TYPE_EXTERNAL, // APO_CONNECTION_BUFFER_TYPE
    NULL,
    0,
    NULL,
    APO_CONNECTION_DESCRIPTOR_SIGNATURE
}, *pOutDesc = &outDesc;

APO_CONNECTION_PROPERTY inConn = {
    NULL,
    0, // frame count
    BUFFER_VALID,
    APO_CONNECTION_PROPERTY_SIGNATURE
}, *pInConn = &inConn,
outConn = {
    NULL,
    0, // frame count
    BUFFER_INVALID,
    APO_CONNECTION_PROPERTY_SIGNATURE
}, *pOutConn = &outConn;

#define CHECKHR(x) hr = x; if (FAILED(hr)) {printf("%d: %08X\n", __LINE__, hr); goto exit;}

#define SET_I4(pkey,val) pv.vt = VT_I4; pv.lVal = val; CHECKHR(pPS->SetValue(pkey, &pv));
#define SET_BOOL(pkey,val) pv.vt = VT_BOOL; pv.boolVal = val ? VARIANT_TRUE : VARIANT_FALSE; CHECKHR(pPS->SetValue(pkey, &pv));

void useAPO()
{
    IUnknown* pUnk = NULL;
    IAudioProcessingObjectRT* pRT = NULL;
    IAudioProcessingObjectConfiguration* pConfig = NULL;
    IPropertyStore* pPS = NULL;
    WAVEFORMATEXTENSIBLE wfx;
    IAudioMediaType* pAMTIn = NULL, *pAMTOut = NULL;
    PROPVARIANT pv;
    HRESULT hr;
    CHECKHR(CoCreateInstance(CLSID_CWMAudioLFXAPO, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (void**)&pUnk));
    CHECKHR(pUnk->QueryInterface(__uuidof(IAudioProcessingObjectRT), (void**)&pRT));
    CHECKHR(pUnk->QueryInterface(__uuidof(IAudioProcessingObjectConfiguration), (void**)&pConfig));
    CHECKHR(pUnk->QueryInterface(IID_IPropertyStore, (void**)&pPS));

    SET_I4(MFPKEY_CORR_MULTICHANNEL_MODE, 2); // turn on speaker filling
    SET_I4(MFPKEY_CORR_BASS_MANAGEMENT_MODE, 1); // turn on bass management
    SET_I4(MFPKEY_BASSMGMT_SPKRBASSCONFIG, 0); // all main speakers are small
    SET_I4(MFPKEY_BASSMGMT_CROSSOVER_FREQ, 120);
    SET_BOOL(MFPKEY_CORR_LOUDNESS_EQUALIZATION_ON, TRUE); // turn on loudness equalization
    SET_BOOL(MFPKEY_BASSMGMT_BIGROOM, TRUE); // affects bass management filter

    // initialize WAVEFORMATEXTENSIBLE for the input format
    wfx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
    wfx.Format.nChannels = 2;
    wfx.Format.nSamplesPerSec = 44100;
    wfx.Format.wBitsPerSample = 32;
    wfx.Format.nBlockAlign = wfx.Format.wBitsPerSample / 8 * wfx.Format.nChannels;
    wfx.Format.nAvgBytesPerSec = wfx.Format.nSamplesPerSec * wfx.Format.nBlockAlign;
    wfx.Format.cbSize = 22;
    wfx.Samples.wValidBitsPerSample = 32;
    wfx.dwChannelMask = 3; // stereo
    wfx.SubFormat.Data1 = WAVE_FORMAT_IEEE_FLOAT;
    wfx.SubFormat.Data2 = 0x0000;
    wfx.SubFormat.Data3 = 0x0010;
    wfx.SubFormat.Data4[0] = 0x80;
    wfx.SubFormat.Data4[1] = 0x00;
    wfx.SubFormat.Data4[2] = 0x00;
    wfx.SubFormat.Data4[3] = 0xaa;
    wfx.SubFormat.Data4[4] = 0x00;
    wfx.SubFormat.Data4[5] = 0x38;
    wfx.SubFormat.Data4[6] = 0x9b;
    wfx.SubFormat.Data4[7] = 0x71;

    CHECKHR(CreateAudioMediaType(&wfx.Format, &pAMTIn));

    // modify WAVEFORMATEXTENSIBLE for the output format
    wfx.Format.nChannels = 6;
    wfx.Format.nBlockAlign = wfx.Format.wBitsPerSample / 8 * wfx.Format.nChannels;
    wfx.Format.nAvgBytesPerSec = wfx.Format.nSamplesPerSec * wfx.Format.nBlockAlign;
    wfx.dwChannelMask = 0x3f; // one 5.1 flavor

    CHECKHR(CreateAudioMediaType(&wfx.Format, &pAMTOut));
    pInDesc->pFormat = pAMTIn;
    pOutDesc->pFormat = pAMTOut;
    CHECKHR(pConfig->LockForProcess(1, &pInDesc, 1, &pOutDesc));

    while (0/*have data to process*/)
    {
        pInConn->u32ValidFrameCount = 0; // sample count
        pInConn->pBuffer = 0; // input buffer
        pOutConn->pBuffer = 0; // output buffer
        pOutConn->u32BufferFlags = BUFFER_INVALID;
        pRT->APOProcess(1, &pInConn, 1, &pOutConn);
        // do something with the output buffer
    }

    pConfig->UnlockForProcess();

exit:
#define SAFE_RELEASE(p) if (p) p->Release();
    SAFE_RELEASE(pAMTIn);
    SAFE_RELEASE(pAMTOut);
    SAFE_RELEASE(pUnk);
    SAFE_RELEASE(pRT);
    SAFE_RELEASE(pConfig);
    SAFE_RELEASE(pPS);
}


The above code gives compiler error for CreateAudioMediaType() function. The error is

error C2660: 'CreateAudioMediaType' : function does not take 2 arguments

When I modify these function calls to

hr = CreateAudioMediaType(&wfx.Format, wfx.Format.cbSize, &pAMTOut);

it gives linker error as :

error LNK2019: unresolved external symbol _CreateAudioMediaType@12 referenced in function "void __cdecl useAPO(void)" (?useAPO@@YAXXZ)


This is what all I have in my code. I hope now this will help.
Thanks in advance.
[Delegates]      [Virtual Desktop]      [Tray Me !]

-Malli...! Rose | [Rose]

GeneralRe: Stuck with 'Loudness Equalization' Pin
Richard MacCutchan17-Jul-11 7:18
mveRichard MacCutchan17-Jul-11 7:18 
GeneralRe: Stuck with 'Loudness Equalization' Pin
Malli_S18-Jul-11 0:16
Malli_S18-Jul-11 0:16 
QuestionCrash in multiple threading with shared resource Pin
includeh1014-Jul-11 9:30
includeh1014-Jul-11 9:30 
AnswerRe: Crash in multiple threading with shared resource Pin
Mark Salsbery14-Jul-11 11:08
Mark Salsbery14-Jul-11 11:08 
AnswerRe: Crash in multiple threading with shared resource Pin
«_Superman_»14-Jul-11 15:44
professional«_Superman_»14-Jul-11 15:44 
AnswerRe: Crash in multiple threading with shared resource Pin
Eugen Podsypalnikov15-Jul-11 1:33
Eugen Podsypalnikov15-Jul-11 1:33 
AnswerRe: Crash in multiple threading with shared resource Pin
ThatsAlok15-Jul-11 1:46
ThatsAlok15-Jul-11 1:46 
QuestionNeed to detect the properties of any object on an application window. Pin
kartikdasani14-Jul-11 2:11
kartikdasani14-Jul-11 2:11 
AnswerRe: Need to detect the properties of any object on an application window. Pin
Chris Losinger14-Jul-11 2:44
professionalChris Losinger14-Jul-11 2:44 
GeneralRe: Need to detect the properties of any object on an application window. Pin
kartikdasani14-Jul-11 2:57
kartikdasani14-Jul-11 2:57 
GeneralRe: Need to detect the properties of any object on an application window. Pin
Chris Losinger14-Jul-11 3:26
professionalChris Losinger14-Jul-11 3:26 
AnswerRe: Need to detect the properties of any object on an application window. Pin
«_Superman_»14-Jul-11 6:55
professional«_Superman_»14-Jul-11 6:55 
AnswerRe: Need to detect the properties of any object on an application window. Pin
Code-o-mat14-Jul-11 22:46
Code-o-mat14-Jul-11 22:46 
AnswerRe: Need to detect the properties of any object on an application window. Pin
Eugen Podsypalnikov15-Jul-11 1:59
Eugen Podsypalnikov15-Jul-11 1:59 
QuestionHow to make modeless dialog actrive Pin
manju 314-Jul-11 1:32
manju 314-Jul-11 1:32 
AnswerRe: How to make modeless dialog actrive Pin
Richard MacCutchan14-Jul-11 1:55
mveRichard MacCutchan14-Jul-11 1:55 
AnswerRe: How to make modeless dialog actrive Pin
Albert Holguin14-Jul-11 4:01
professionalAlbert Holguin14-Jul-11 4:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.