Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.

Audio System Companion #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
72 changes: 12 additions & 60 deletions Python/plasma/Plasma.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,46 +1281,22 @@ 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

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"""
pass

def getDeviceName(self):
"""Gets the name for the device being used by the audio system"""
def getFriendlyDeviceName(self):
"""Returns the provided device name without any OpenAL prefixes applied."""
pass

def getGUIVolume(self):
"""Returns the volume (0.0 to 1.0) for the GUI dialogs."""
pass

def getHighestMode(self):
"""Gets the highest possible audio system mode"""
pass

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 @@ -1329,8 +1305,12 @@ def getNPCVoiceVolume(self):
"""Returns the volume (0.0 to 1.0) for the NPC's voice."""
pass

def getNumAudioDevices(self):
"""Returns the number of available audio devices."""
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):
Expand All @@ -1353,10 +1333,6 @@ def isEnabled(self):
"""Is the audio enabled? Returns 1 if true otherwise returns 0."""
pass

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

def isMuted(self):
"""Are all sounds muted? Returns 1 if true otherwise returns 0."""
pass
Expand All @@ -1365,10 +1341,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
Expand All @@ -1385,23 +1357,11 @@ 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"""
pass

def setGUIVolume(self,volume):
"""Sets the GUI dialog volume (0.0 to 1.0) for the game.
This only sets the volume for this game session."""
Expand All @@ -1415,10 +1375,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 +1385,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 +1416,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 +1424,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 Python/xIniAudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ def SetAudioMode(init, device, eax):

print 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
33 changes: 17 additions & 16 deletions Python/xOptionsMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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,20 @@ def OnGUINotify(self,id,control,event):
self.restartAudio = 1
audio = ptAudioControl()
#~ print "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...
print "Audio Device Name changed!"
prevAudioDeviceName = audioDeviceName
EAXcheckbox = ptGUIControlCheckBox(AudioSettingsDlg.dialog.getControlFromTag(kAudioModeCBID03))
if not audio.supportsEAX(audioDeviceName):
if not audio.isEAXSupported():
print "Disabling EAX checkbox"
#Disable EAX checkbox
EAXcheckbox.disable()
Expand Down Expand Up @@ -1670,7 +1668,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 +1677,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 +1715,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