Lautstärke von HWAVEIN rausfinden



  • Hallo!
    Ich benutze den folgenden Code um die Lautstärke des benutzten HWAVEINs herauszufinden..einmal hab ichs nach waveInOpen und einmal nach waveInStart probiert...hab auch anstatt dem HWAVEIN als Handle schon den Mixer verwendet...am weitesten kommt er mit der folgenden Konstellation...der Fehler ist bei mixerGetControlDetails MMSYSERROR_INVALIDPARAM...vielleicht schafft ihr es ja die MSDN besser zu interpretieren als ich 😕

    rc = mixerOpen(&hMixer, (UINT)m_currentOb->waveIn.m_hWaveIn,0,0,MIXER_OBJECTF_HWAVEIN);
    			if (MMSYSERR_NOERROR != rc) {
    				return;
    			}
    
    			ZeroMemory(&mxl,sizeof(mxl));
    			mxl.cbStruct = sizeof(mxl);
    
    			//mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_WAVEIN;
    
    			rc = mixerGetLineInfo((HMIXEROBJ)m_currentOb->waveIn.m_hWaveIn, &mxl,
                               MIXER_OBJECTF_HWAVEIN);
    
    			if(rc != MMSYSERR_NOERROR)
    				return;
    
    			ZeroMemory(&mxlc, sizeof(mxlc));
    			mxlc.cbStruct = sizeof(mxlc);
    			mxlc.dwLineID = mxl.dwLineID;
    			mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_PEAKMETER;
    			mxlc.cControls = 1;
    			mxlc.cbmxctrl = sizeof(mxc);
    			mxlc.pamxctrl = &mxc;
    			ZeroMemory(&mxc, sizeof(mxc));
    			mxc.cbStruct = sizeof(mxc);
    			//MIXER_GETLINECONTROLSF_ONEBYTYPE
    			rc = mixerGetLineControls((HMIXEROBJ)m_currentOb->waveIn.m_hWaveIn,&mxlc,
    									   MIXER_OBJECTF_HWAVEIN);
    
    			if(rc != MMSYSERR_NOERROR)
    				return;
    
    			MIXERCONTROLDETAILS mxcd;             // Gets the control values.
    			MIXERCONTROLDETAILS_SIGNED volStruct; // Gets the control values.
    			long volume;                          // Holds the final volume value.
    
    			// Initialize the MIXERCONTROLDETAILS structure
    			ZeroMemory(&mxcd, sizeof(mxcd));
    			mxcd.cbStruct = sizeof(mxcd);
    			mxcd.cbDetails = sizeof(volStruct);
    			mxcd.dwControlID = mxc.dwControlID;
    			mxcd.paDetails = &volStruct;
    			mxcd.cChannels = 1;
    
    			// Get the current value of the peakmeter control. Typically, you
    			// would set a timer in your program to query the volume every 10th
    			// of a second or so.
    
    			//MIXER_GETCONTROLDETAILSF_VALUE
    			rc = mixerGetControlDetails((HMIXEROBJ)m_currentOb->waveIn.m_hWaveIn, &mxcd,
    									 MIXER_OBJECTF_HWAVEIN);
    		/*	rc = mixerGetControlDetails((HMIXEROBJ)hMixer, &mxcd,
    										 MIXER_GETCONTROLDETAILSF_VALUE);*/
    
    			if (MMSYSERR_NOERROR != rc) {
    				return;
    			}
    			volume = volStruct.lValue;
    
    			// Get the absolute value of the volume.
    			if (volume < 0)
    				volume = -volume;
    
    			m_ctrlPeakMeter.SetMeterBands(1, mxc.Bounds.lMaximum);
    			int iArray[1];
    			iArray[0] = volume;
    			m_ctrlPeakMeter.SetData(iArray, 0, 1);
    
    			mixerClose(hMixer);
    

    Danke

    Kevin



  • Willst du die eingestellte Lautstärke ermitteln, oder die aktuell aufgenommene?
    Falls letzteres ist das vielleicht ein kleiner Anstoß: http://www.c-plusplus.net/forum/viewtopic.php?t=53394 🙂



  • Hi!
    Jo danke...aber ich hab leider nicht ganz verstanden wie man jetzt aus nem Datenblock den man sich vom Treiber holt die Lautstärke herausfinden kann 😕
    Ich denke auch, dass das nicht wirklich flüssig ist denn es vergeht ja ne ziemlich große Zeit bevor der nächste Block eingelesen wird...wenn ich dann erst die neue Mikrofonhöhe ausgebe ist das ziemlich langsam..alle 0,25 Sekunden mal ne Aktualisierung ... wow 🙂
    Sehe ich auch deutlich am WaveOut..da hab ich nen Slider gecodet und nach jedem "Ausschub" an den Treiber wird die neue Position festgesetzt...da wird bei low Qualität 10 Sekunden nur 3 Mal was an den Treiber geschickt..das reicht wirklich gar nicht!

    Kevin


Anmelden zum Antworten