Skip to content

Commit

Permalink
Fix microphone volume level control.
Browse files Browse the repository at this point in the history
Previously, the "My Voice" control in the options GUI did nothing. The
old plWinMicLevel code was originally for the WinMM library from 1991
(!!!). This rewrites all that junk to use the Windows Core Audio library
upon which WinMM sits as of Windows Vista. When using OpenAL Soft, the
primary backend is WASAPI, a Core Audio component. Further, when
adjusting the level in Uru, you can observe the level changing in the
Windows mixer as well.
  • Loading branch information
Hoikas committed Jan 28, 2020
1 parent d2bdc59 commit a92334b
Show file tree
Hide file tree
Showing 9 changed files with 506 additions and 464 deletions.
8 changes: 2 additions & 6 deletions Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ You can contact Cyan Worlds, Inc. by email [email protected]
#include "plSurface/plLayerOr.h"
#include "plAudio/plAudioSystem.h"
#include "plAudio/plVoiceChat.h"
#include "plAudio/plWinMicLevel.h"
#include "plPipeline/plFogEnvironment.h"
#include "plPipeline/plPlates.h"
#include "plPipeline/plDynamicEnvMap.h"
Expand Down Expand Up @@ -3429,11 +3428,8 @@ PF_CONSOLE_CMD( Audio, IsolateSound,

PF_CONSOLE_CMD( Audio, SetMicVolume, "float volume", "Sets the microphone volume, in the range of 0 to 1" )
{
if( !plWinMicLevel::CanSetLevel() )
PrintString( "Unable to set microphone level" );
else
{
plWinMicLevel::SetLevel( (float)params[ 0 ] );
if (!plgAudioSys::SetCaptureVolume((float)params[0])) {
PrintString("Unable to set microphone level");
}
}

Expand Down
14 changes: 3 additions & 11 deletions Sources/Plasma/FeatureLib/pfPython/pyAudioControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email [email protected]

#include "plAudio/plAudioSystem.h"
#include "plAudio/plVoiceChat.h"
#include "plAudio/plWinMicLevel.h"

// Sets the master volume of a given audio channel
void pyAudioControl::SetSoundFXVolume(float volume)
Expand Down Expand Up @@ -252,26 +251,19 @@ bool pyAudioControl::IsMuted() const
//------------------------
// Voice Settings

// Sets the microphone volume, in the range of 0 to 1
bool pyAudioControl::CanSetMicLevel() const
{
return plWinMicLevel::CanSetLevel();
return plgAudioSys::CanChangeCaptureVolume();
}

void pyAudioControl::SetMicLevel(float level)
{
// make sure the volume is within range
if( level > 1.f )
level = 1.f;
else if( level < 0.f )
level = 0.f;
if( CanSetMicLevel() )
plWinMicLevel::SetLevel( level );
plgAudioSys::SetCaptureVolume(level);
}

float pyAudioControl::GetMicLevel() const
{
return plWinMicLevel::GetLevel();
return plgAudioSys::GetCaptureVolume();
}


Expand Down
4 changes: 2 additions & 2 deletions Sources/Plasma/PubUtilLib/plAudio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ if(PLASMA_USE_SPEEX)
endif()

set(plAudio_SOURCES
plAudioEndpointVolume.cpp
plAudioSystem.cpp
plDSoundBuffer.cpp
plEAXEffects.cpp
Expand All @@ -28,12 +29,12 @@ set(plAudio_SOURCES
plWin32Sound.cpp
plWin32StaticSound.cpp
plWin32StreamingSound.cpp
plWinMicLevel.cpp
plWin32VideoSound.cpp
)

set(plAudio_HEADERS
plAudioCreatable.h
plAudioEndpointVolume.h
plAudioSystem.h
plAudioSystem_Private.h
plDSoundBuffer.h
Expand All @@ -48,7 +49,6 @@ set(plAudio_HEADERS
plWin32Sound.h
plWin32StaticSound.h
plWin32StreamingSound.h
plWinMicLevel.h
plWin32VideoSound.h
)

Expand Down
Loading

0 comments on commit a92334b

Please sign in to comment.