Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio System Improvements #596

Merged
merged 14 commits into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ set_package_properties(OpenSSL PROPERTIES
TYPE REQUIRED
)

find_package(OpenAL REQUIRED)
set_package_properties(OpenAL PROPERTIES
URL "http://www.openal.org/"
DESCRIPTION "3D audio and EAX library"
TYPE REQUIRED
)

set(Python_ADDITIONAL_VERSIONS 2.7)
find_package(PythonLibs REQUIRED)
set_package_properties(PythonLibs PROPERTIES
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Plasma currently requires the following third-party libraries:
- Python 2.7 - http://www.python.org/download/releases/2.7/
- libOgg and libVorbis - http://www.xiph.org/downloads/
- OpenSSL - http://www.slproweb.com/products/Win32OpenSSL.html
- OpenAL - http://www.openal.org/
- OpenAL Soft - https://openal-soft.org/
- eXpat - http://expat.sourceforge.net/
- libJPEG - http://libjpeg-turbo.virtualgl.org/
- libPNG - http://www.libpng.org/
Expand Down
76 changes: 26 additions & 50 deletions Scripts/Python/plasma/Plasma.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,14 +1281,6 @@ def enableVoiceChat(self,state):
"""Enables or disables voice chat."""
pass

def enableVoiceCompression(self,state):
"""Enables or disables voice compression."""
pass

def enableVoiceNetBroadcast(self,state):
"""Enables or disables voice over network broadcast."""
pass

def enableVoiceRecording(self,state):
"""Enables or disables voice recording."""
pass
Expand All @@ -1297,12 +1289,16 @@ def getAmbienceVolume(self):
"""Returns the volume (0.0 to 1.0) for the Ambiance."""
pass

def getAudioDeviceName(self,index):
"""Gets the name of audio device for the given index"""
def getCaptureDevice(self):
"""Gets the name for the capture device being used by the audio system."""
pass

def getDeviceName(self):
"""Gets the name for the device being used by the audio system"""
def getCaptureDevices(self):
"""Gets the name of all available audio capture devices."""
pass

def getFriendlyDeviceName(self, devicename):
"""Returns the provided device name without any OpenAL prefixes applied."""
pass

def getGUIVolume(self):
Expand All @@ -1317,10 +1313,6 @@ def getMicLevel(self):
"""Returns the microphone recording level (0.0 to 1.0)."""
pass

def getMode(self):
"""Gets the audio system mode"""
pass

def getMusicVolume(self):
"""Returns the volume (0.0 to 1.0) for the Music."""
pass
Expand All @@ -1333,6 +1325,14 @@ def getNumAudioDevices(self):
"""Returns the number of available audio devices."""
pass

def getPlaybackDevice(self):
"""Gets the name for the device being used by the audio system."""
pass

def getPlaybackDevices(self):
"""Gets the names of all available audio playback devices."""
pass

def getPriorityCutoff(self):
"""Returns current sound priority"""
pass
Expand All @@ -1349,12 +1349,12 @@ def hideIcons(self):
"""Hides (disables) the voice recording icons."""
pass

def isEnabled(self):
"""Is the audio enabled? Returns 1 if true otherwise returns 0."""
def isEAXSupported(self):
"""Returns true or false based on whether or not a the device specified supports EAX"""
pass

def isHardwareAccelerated(self):
"""Is audio hardware acceleration enabled? Returns 1 if true otherwise returns 0."""
def isEnabled(self):
"""Is the audio enabled? Returns 1 if true otherwise returns 0."""
pass

def isMuted(self):
Expand All @@ -1365,14 +1365,6 @@ def isUsingEAXAcceleration(self):
"""Is EAX sound acceleration enabled? Returns 1 if true otherwise returns 0."""
pass

def isVoiceCompressionEnabled(self):
"""Is voice compression enabled? Returns 1 if true otherwise returns 0."""
pass

def isVoiceNetBroadcastEnabled(self):
"""Is voice over net enabled? Returns 1 if true otherwise returns 0."""
pass

def isVoiceRecordingEnabled(self):
"""Is voice recording enabled? Returns 1 if true otherwise returns 0."""
pass
Expand All @@ -1385,21 +1377,13 @@ def pushToTalk(self,state):
"""Enables or disables 'push-to-talk'."""
pass

def recordFrame(self,size):
"""Sets the voice packet frame size."""
pass

def recordSampleRate(self,sampleRate):
"""Sets the recording sample rate."""
pass

def setAmbienceVolume(self,volume):
"""Sets the Ambience volume (0.0 to 1.0) for the game.
This only sets the volume for this game session."""
pass

def setDeviceName(self,devicename,restart):
"""Sets the device name for the audio system, and optionally restarts it"""
def setCaptureDevice(self, devicename):
"""Sets the audio capture device by name."""
pass

def setGUIVolume(self,volume):
Expand All @@ -1415,10 +1399,6 @@ def setMicLevel(self,level):
"""Sets the microphone recording level (0.0 to 1.0)."""
pass

def setMode(self,mode):
"""Sets the audio system mode"""
pass

def setMusicVolume(self,volume):
"""Sets the Music volume (0.0 to 1.0) for the game.
This only sets the volume for this game session."""
Expand All @@ -1429,6 +1409,10 @@ def setNPCVoiceVolume(self,volume):
This only sets the volume for this game session."""
pass

def setPlaybackDevice(self,devicename,restart):
"""Sets audio system output device by name, and optionally restarts it"""
pass

def setPriorityCutoff(self,priority):
"""Sets the sound priority"""
pass
Expand Down Expand Up @@ -1456,10 +1440,6 @@ def squelchLevel(self,level):
"""Sets the squelch level."""
pass

def supportsEAX(self):
"""Returns true or false based on whether or not a the device specified supports EAX"""
pass

def unmuteAll(self):
"""Unmutes all sounds."""
pass
Expand All @@ -1468,10 +1448,6 @@ def useEAXAcceleration(self,state):
"""Enables or disables EAX sound acceleration (requires hardware acceleration)."""
pass

def useHardwareAcceleration(self,state):
"""Enables or disables audio hardware acceleration."""
pass

class ptAvatar:
"""Plasma avatar class"""
def __init__(self):
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Python/xIniAudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,9 @@ def SetAudioMode(init, device, eax):

PtDebugPrint(device)
if entryDev:
entryDev.setValue(0, "\"" + device + "\"")
entryDev.setValue(0, "\"" + device.encode("utf-8") + "\"")
else:
gIniFile.addEntry("Audio.SetDeviceName \"" + device + "\"")
gIniFile.addEntry("Audio.SetDeviceName \"" + device.encode("utf-8") + "\"")

if eax:
val = kBeTrue
Expand Down
32 changes: 17 additions & 15 deletions Scripts/Python/xOptionsMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
kDemoMovieName = "avi/UruPreview.webm"
gPreviewStarted = 0
prevAudioDeviceName = None
gAudioDevices = ()

# =====================================
# Aspect Ratios
Expand Down Expand Up @@ -1244,15 +1245,15 @@ def OnGUINotify(self,id,control,event):
if self.restartAudio:
audio = ptAudioControl()
audioField = ptGUIControlKnob(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeID))
audModeNum = audio.getNumAudioDevices() - 1
audModeNum = len(gAudioDevices) - 1
curSelection = round(audioField.getValue() * audModeNum)
intCurSelection = int(curSelection)

#Enable EAX Support
EAXcheckbox = ptGUIControlCheckBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeCBID03))
audio.useEAXAcceleration(EAXcheckbox.isChecked())

audio.setDeviceName(audio.getAudioDeviceName(intCurSelection), 1)
audio.setPlaybackDevice(gAudioDevices[intCurSelection], 1)
self.WriteAudioControls()

elif event == kAction or event == kValueChanged:
Expand Down Expand Up @@ -1310,23 +1311,21 @@ def OnGUINotify(self,id,control,event):
self.restartAudio = 1
audio = ptAudioControl()
#~ PtDebugPrint("Number of Audio Devices: %d" % (audio.getNumAudioDevices()))
audModeNum = audio.getNumAudioDevices() - 1
audModeNum = len(gAudioDevices) - 1
curSelection = round(control.getValue() * audModeNum)
intCurSelection = int(curSelection)
control.setValue(curSelection/audModeNum)

audioDeviceName = audio.getAudioDeviceName(intCurSelection)
audioDeviceName = gAudioDevices[intCurSelection]

audioModeCtrlTextBox = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeTextID))
curText = audioModeCtrlTextBox.getString()
if curText != audio.getAudioDeviceName(intCurSelection):
audioModeCtrlTextBox.setString(audioDeviceName)
audioModeCtrlTextBox.setStringW(audio.getFriendlyDeviceName(audioDeviceName))

if audioDeviceName != prevAudioDeviceName: #Only update the EAX checkbox when the mouse has been let up...
PtDebugPrint("Audio Device Name changed!")
prevAudioDeviceName = audioDeviceName
EAXcheckbox = ptGUIControlCheckBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeCBID03))
if not audio.supportsEAX(audioDeviceName):
if not audio.isEAXSupported():
PtDebugPrint("Disabling EAX checkbox")
#Disable EAX checkbox
EAXcheckbox.disable()
Expand Down Expand Up @@ -1670,7 +1669,7 @@ def WriteAudioControls(self):

EAXcheckbox = ptGUIControlCheckBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeCBID03))

xIniAudio.SetAudioMode( True, audio.getDeviceName(), EAXcheckbox.isChecked() )
xIniAudio.SetAudioMode( True, audio.getPlaybackDevice(), EAXcheckbox.isChecked() )
#xIniAudio.SetAudioMode( audio.isEnabled(), audio.getDeviceName(), EAXcheckbox.isChecked() )
#xIniAudio.SetAudioMode( audio.isEnabled(), audio.getDeviceName(), audio.isUsingEAXAcceleration() )
#xIniAudio.SetMicLevel( audio.getMicLevel() )
Expand All @@ -1679,11 +1678,14 @@ def WriteAudioControls(self):
xIniAudio.WriteIni()

def InitAudioControlsGUI(self):
global gAudioDevices
global prevAudioDeviceName

xIniAudio.ReadIni()
audio = ptAudioControl()

gAudioDevices = audio.getPlaybackDevices()

audioField = ptGUIControlKnob(AudioSettingsDlg.dialog.getControlFromTag(kAudioNumberOfSoundsSliderTag))
audioField.setValue( audio.getPriorityCutoff() )

Expand Down Expand Up @@ -1714,21 +1716,21 @@ def InitAudioControlsGUI(self):
respDisableItems.run(self.key, state="enableEAX")

audioField = ptGUIControlKnob(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeID))
numAudioDevices = audio.getNumAudioDevices() - 1.0
numAudioDevices = len(gAudioDevices) - 1.0

if numAudioDevices > 0:
for num in range(audio.getNumAudioDevices()):
if audio.getAudioDeviceName(num) == audio.getDeviceName():
if not audio.supportsEAX(audio.getDeviceName()):
for num, device in enumerate(gAudioDevices):
if gAudioDevices[num] == audio.getPlaybackDevice():
if not audio.isEAXSupported():
EAXcheckbox.disable()
respDisableItems.run(self.key, state="disableEAX")
EAXcheckbox.setChecked(False)
ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeEAXTextID)).setForeColor(ptColor(0.839, 0.785, 0.695, 1))

audioField.setValue(num/numAudioDevices)
audioModeCtrlTextBox = ptGUIControlTextBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeTextID))
audioDeviceName = prevAudioDeviceName = audio.getAudioDeviceName(num)
audioModeCtrlTextBox.setString(audioDeviceName)
audioDeviceName = prevAudioDeviceName = audio.getPlaybackDevice()
audioModeCtrlTextBox.setStringW(audio.getFriendlyDeviceName(device))
else:
EAXcheckbox.disable()
respDisableItems.run(self.key, state="disableEAX")
Expand Down
2 changes: 0 additions & 2 deletions Sources/Plasma/Apps/plClient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ include_directories("../../NucleusLib")
include_directories("../../PubUtilLib/inc")
include_directories("../../PubUtilLib")

include_directories(${OPENAL_INCLUDE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${PYTHON_INCLUDE_DIR})
include_directories(${CURL_INCLUDE_DIR})
Expand Down Expand Up @@ -160,7 +159,6 @@ target_link_libraries(plClient pnUtils)
target_link_libraries(plClient pnUUID)

target_link_libraries(plClient ${PYTHON_LIBRARIES})
target_link_libraries(plClient ${OPENAL_LIBRARY})
target_link_libraries(plClient ${OPENSSL_LIBRARIES})
target_link_libraries(plClient ${EXPAT_LIBRARY})
target_link_libraries(plClient ${JPEG_LIBRARY})
Expand Down
26 changes: 4 additions & 22 deletions Sources/Plasma/Apps/plClient/plClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ You can contact Cyan Worlds, Inc. by email [email protected]
#include "plScene/plVisMgr.h"

#include "plAudio/plAudioSystem.h"
#include "plAudio/plAudioCaps.h"

#include "plStatGather/plProfileManagerFull.h"

Expand Down Expand Up @@ -158,7 +157,6 @@ You can contact Cyan Worlds, Inc. by email [email protected]

static plDispatchBase* gDisp = nil;
static plTimerCallbackManager* gTimerMgr = nil;
static plAudioSystem* gAudio = nil;

#ifdef HS_BUILD_FOR_WIN32
extern ITaskbarList3* gTaskbarList;
Expand Down Expand Up @@ -1380,7 +1378,6 @@ bool plClient::StartInit()
((plResManager *)hsgResMgr::ResMgr())->VerifyPages();

plgAudioSys::Init();
gAudio = plgAudioSys::Sys();

RegisterAs( kClient_KEY );

Expand Down Expand Up @@ -2122,20 +2119,11 @@ void plClient::IDetectAudioVideoSettings()
#endif

//check to see if audio.ini exists
if (s.Open(audioIniFile))
{
if (s.Open(audioIniFile)) {
s.Close();
}
else
{
} else {
stream = plEncryptedStream::OpenEncryptedFileWrite(audioIniFile);

plAudioCaps caps = plAudioCapsDetector::Detect(false, true);

char deviceName[256];
sprintf(deviceName, "\"%s\"", DEFAULT_AUDIO_DEVICE_NAME);

WriteBool(stream, "Audio.Initialize", caps.IsAvailable());
WriteBool(stream, "Audio.Initialize", true);
WriteBool(stream, "Audio.UseEAX", false);
WriteInt(stream, "Audio.SetPriorityCutoff", 6);
WriteInt(stream, "Audio.MuteAll", false);
Expand All @@ -2144,21 +2132,15 @@ void plClient::IDetectAudioVideoSettings()
WriteInt(stream, "Audio.SetChannelVolume Ambience", 1);
WriteInt(stream, "Audio.SetChannelVolume NPCVoice", 1);
WriteInt(stream, "Audio.EnableVoiceRecording", 1);
WriteString(stream, "Audio.SetDeviceName", deviceName );
stream->Close();
delete stream;
stream = nil;
}

// check to see if graphics.ini exists
if (s.Open(graphicsIniFile))
{
s.Close();
}
else
{
IWriteDefaultGraphicsSettings(graphicsIniFile);
}
}

void plClient::IWriteDefaultGraphicsSettings(const plFileName& destFile)
Expand Down
1 change: 1 addition & 0 deletions Sources/Plasma/CoreLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ set(CoreLib_SOURCES
plLoadMask.cpp
plProduct.cpp
plViewTransform.cpp
hsWindows.cpp
)

if(WIN32 AND NOT CYGWIN)
Expand Down
Loading