提交 53d936c5 编写于 作者: S Shaolin 提交者: jp9000

UI: Add audio meter decay rate option

The decay rate of the audio meters can now be selected in the audio
settings.  The values are:

- "Fast"   (OBS default, 40 dB / 1.7s)
- "Medium" (Type I PPM,  20 dB / 1.7s)
- "Slow"   (Type II PPM, 24 dB / 2.8s)

Closes jp9000/obs-studio#1143
上级 bba37a70
...@@ -700,6 +700,10 @@ Basic.Settings.Video.DownscaleFilter.Lanczos="Lanczos (Sharpened scaling, 32 sam ...@@ -700,6 +700,10 @@ Basic.Settings.Video.DownscaleFilter.Lanczos="Lanczos (Sharpened scaling, 32 sam
Basic.Settings.Audio="Audio" Basic.Settings.Audio="Audio"
Basic.Settings.Audio.SampleRate="Sample Rate" Basic.Settings.Audio.SampleRate="Sample Rate"
Basic.Settings.Audio.Channels="Channels" Basic.Settings.Audio.Channels="Channels"
Basic.Settings.Audio.MeterDecayRate="Audio Meter Decay Rate"
Basic.Settings.Audio.MeterDecayRate.Fast="Fast"
Basic.Settings.Audio.MeterDecayRate.Medium="Medium (Type I PPM)"
Basic.Settings.Audio.MeterDecayRate.Slow="Slow (Type II PPM)"
Basic.Settings.Audio.MultiChannelWarning.Enabled="WARNING: Surround sound audio is enabled." Basic.Settings.Audio.MultiChannelWarning.Enabled="WARNING: Surround sound audio is enabled."
Basic.Settings.Audio.MultichannelWarning="If streaming, check to see if your streaming service supports both surround sound ingest and surround sound playback. Twitch, Facebook 360 Live, Mixer RTMP, Smashcast are examples where surround sound is fully supported. Although Facebook Live and YouTube Live both accept surround ingest, Facebook Live downmixes to stereo, and YouTube Live plays only two channels.\n\nOBS audio filters are compatible with surround sound, though VST plugin support isn't guaranteed." Basic.Settings.Audio.MultichannelWarning="If streaming, check to see if your streaming service supports both surround sound ingest and surround sound playback. Twitch, Facebook 360 Live, Mixer RTMP, Smashcast are examples where surround sound is fully supported. Although Facebook Live and YouTube Live both accept surround ingest, Facebook Live downmixes to stereo, and YouTube Live plays only two channels.\n\nOBS audio filters are compatible with surround sound, though VST plugin support isn't guaranteed."
Basic.Settings.Audio.MultichannelWarning.Title="Enable surround sound audio?" Basic.Settings.Audio.MultichannelWarning.Title="Enable surround sound audio?"
......
...@@ -518,7 +518,6 @@ VolumeMeter { ...@@ -518,7 +518,6 @@ VolumeMeter {
qproperty-magnitudeColor: rgb(0, 0, 0); qproperty-magnitudeColor: rgb(0, 0, 0);
qproperty-majorTickColor: rgb(225,224,225); /* veryLight */ qproperty-majorTickColor: rgb(225,224,225); /* veryLight */
qproperty-minorTickColor: rgb(122,121,122); /* light */ qproperty-minorTickColor: rgb(122,121,122); /* light */
qproperty-peakDecayRate: 23.4; /* Override of the standard PPM Type I rate. */
} }
......
...@@ -68,7 +68,6 @@ VolumeMeter { ...@@ -68,7 +68,6 @@ VolumeMeter {
qproperty-magnitudeColor: rgb(0, 0, 0); qproperty-magnitudeColor: rgb(0, 0, 0);
qproperty-majorTickColor: rgb(0, 0, 0); qproperty-majorTickColor: rgb(0, 0, 0);
qproperty-minorTickColor: rgb(50, 50, 50); qproperty-minorTickColor: rgb(50, 50, 50);
qproperty-peakDecayRate: 23.4; /* Override of the standard PPM Type I rate. */
} }
......
...@@ -729,7 +729,6 @@ VolumeMeter { ...@@ -729,7 +729,6 @@ VolumeMeter {
qproperty-magnitudeColor: rgb(49, 54, 59); /* Blue-gray */ qproperty-magnitudeColor: rgb(49, 54, 59); /* Blue-gray */
qproperty-majorTickColor: rgb(239, 240, 241); /* White */ qproperty-majorTickColor: rgb(239, 240, 241); /* White */
qproperty-minorTickColor: rgb(118, 121, 124); /* Light Gray */ qproperty-minorTickColor: rgb(118, 121, 124); /* Light Gray */
qproperty-peakDecayRate: 23.4; /* Override of the standard PPM Type I rate. */
} }
/*******************/ /*******************/
......
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>801</width> <width>801</width>
<height>1044</height> <height>741</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_19"> <layout class="QVBoxLayout" name="verticalLayout_19">
...@@ -733,8 +733,8 @@ ...@@ -733,8 +733,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>601</width> <width>818</width>
<height>640</height> <height>697</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_21"> <layout class="QVBoxLayout" name="verticalLayout_21">
...@@ -3362,7 +3362,7 @@ ...@@ -3362,7 +3362,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0" colspan="2"> <item row="8" column="0" colspan="2">
<widget class="QScrollArea" name="audioSourceScrollArea"> <widget class="QScrollArea" name="audioSourceScrollArea">
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
...@@ -3372,14 +3372,14 @@ ...@@ -3372,14 +3372,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>63</width> <width>800</width>
<height>16</height> <height>69</height>
</rect> </rect>
</property> </property>
</widget> </widget>
</widget> </widget>
</item> </item>
<item row="8" column="1"> <item row="9" column="1">
<widget class="QLabel" name="audioMsg"> <widget class="QLabel" name="audioMsg">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">color: rgb(255, 0, 4);</string> <string notr="true">color: rgb(255, 0, 4);</string>
...@@ -3392,7 +3392,7 @@ ...@@ -3392,7 +3392,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="10" column="1">
<widget class="QLabel" name="audioMsg_2"> <widget class="QLabel" name="audioMsg_2">
<property name="text"> <property name="text">
<string notr="true"/> <string notr="true"/>
...@@ -3405,6 +3405,41 @@ ...@@ -3405,6 +3405,41 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0">
<widget class="QLabel" name="label_65">
<property name="text">
<string>Basic.Settings.Audio.MeterDecayRate</string>
</property>
<property name="buddy">
<cstring>meterDecayRate</cstring>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QComboBox" name="meterDecayRate">
<property name="currentText">
<string>Basic.Settings.Audio.MeterDecayRate.Fast</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Basic.Settings.Audio.MeterDecayRate.Fast</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.Settings.Audio.MeterDecayRate.Medium</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.Settings.Audio.MeterDecayRate.Slow</string>
</property>
</item>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="videoPage"> <widget class="QWidget" name="videoPage">
...@@ -3756,7 +3791,7 @@ ...@@ -3756,7 +3791,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>803</width> <width>593</width>
<height>761</height> <height>761</height>
</rect> </rect>
</property> </property>
......
...@@ -56,7 +56,7 @@ void VolControl::VolumeChanged() ...@@ -56,7 +56,7 @@ void VolControl::VolumeChanged()
slider->blockSignals(true); slider->blockSignals(true);
slider->setValue((int) (obs_fader_get_deflection(obs_fader) * 100.0f)); slider->setValue((int) (obs_fader_get_deflection(obs_fader) * 100.0f));
slider->blockSignals(false); slider->blockSignals(false);
updateText(); updateText();
} }
...@@ -109,6 +109,11 @@ void VolControl::EmitConfigClicked() ...@@ -109,6 +109,11 @@ void VolControl::EmitConfigClicked()
emit ConfigClicked(); emit ConfigClicked();
} }
void VolControl::SetMeterDecayRate(qreal q)
{
volMeter->setPeakDecayRate(q);
}
VolControl::VolControl(OBSSource source_, bool showConfig) VolControl::VolControl(OBSSource source_, bool showConfig)
: source (source_), : source (source_),
levelTotal (0.0f), levelTotal (0.0f),
...@@ -430,7 +435,7 @@ VolumeMeter::VolumeMeter(QWidget *parent, obs_volmeter_t *obs_volmeter) ...@@ -430,7 +435,7 @@ VolumeMeter::VolumeMeter(QWidget *parent, obs_volmeter_t *obs_volmeter)
errorLevel = -9.0; // -9 dB errorLevel = -9.0; // -9 dB
clipLevel = -0.5; // -0.5 dB clipLevel = -0.5; // -0.5 dB
minimumInputLevel = -50.0; // -50 dB minimumInputLevel = -50.0; // -50 dB
peakDecayRate = 11.7; // 20 dB / 1.7 sec peakDecayRate = 11.76; // 20 dB / 1.7 sec
magnitudeIntegrationTime = 0.3; // 99% in 300 ms magnitudeIntegrationTime = 0.3; // 99% in 300 ms
peakHoldDuration = 20.0; // 20 seconds peakHoldDuration = 20.0; // 20 seconds
inputPeakHoldDuration = 1.0; // 1 second inputPeakHoldDuration = 1.0; // 1 second
...@@ -524,7 +529,9 @@ inline void VolumeMeter::calculateBallisticsForChannel(int channelNr, ...@@ -524,7 +529,9 @@ inline void VolumeMeter::calculateBallisticsForChannel(int channelNr,
// Attack of peak is immediate. // Attack of peak is immediate.
displayPeak[channelNr] = currentPeak[channelNr]; displayPeak[channelNr] = currentPeak[channelNr];
} else { } else {
// Decay of peak is 20 dB / 1.7 seconds. // Decay of peak is 40 dB / 1.7 seconds for Fast Profile
// 20 dB / 1.7 seconds for Medium Profile (Type I PPM)
// 24 dB / 2.8 seconds for Slow Profile (Type II PPM)
qreal decay = peakDecayRate * timeSinceLastRedraw; qreal decay = peakDecayRate * timeSinceLastRedraw;
displayPeak[channelNr] = CLAMP(displayPeak[channelNr] - decay, displayPeak[channelNr] = CLAMP(displayPeak[channelNr] - decay,
currentPeak[channelNr], 0); currentPeak[channelNr], 0);
......
...@@ -253,4 +253,6 @@ public: ...@@ -253,4 +253,6 @@ public:
QString GetName() const; QString GetName() const;
void SetName(const QString &newName); void SetName(const QString &newName);
void SetMeterDecayRate(qreal q);
}; };
...@@ -400,6 +400,16 @@ void OBSBasic::copyActionsDynamicProperties() ...@@ -400,6 +400,16 @@ void OBSBasic::copyActionsDynamicProperties()
} }
} }
void OBSBasic::UpdateVolumeControlsDecayRate()
{
double meterDecayRate = config_get_double(basicConfig, "Audio",
"MeterDecayRate");
for (size_t i = 0; i < volumes.size(); i++) {
volumes[i]->SetMeterDecayRate(meterDecayRate);
}
}
void OBSBasic::ClearVolumeControls() void OBSBasic::ClearVolumeControls()
{ {
VolControl *control; VolControl *control;
...@@ -1235,6 +1245,8 @@ bool OBSBasic::InitBasicConfigDefaults() ...@@ -1235,6 +1245,8 @@ bool OBSBasic::InitBasicConfigDefaults()
config_set_default_uint (basicConfig, "Audio", "SampleRate", 44100); config_set_default_uint (basicConfig, "Audio", "SampleRate", 44100);
config_set_default_string(basicConfig, "Audio", "ChannelSetup", config_set_default_string(basicConfig, "Audio", "ChannelSetup",
"Stereo"); "Stereo");
config_set_default_double(basicConfig, "Audio", "MeterDecayRate",
VOLUME_METER_DECAY_FAST);
return true; return true;
} }
...@@ -2549,6 +2561,9 @@ void OBSBasic::ActivateAudioSource(OBSSource source) ...@@ -2549,6 +2561,9 @@ void OBSBasic::ActivateAudioSource(OBSSource source)
VolControl *vol = new VolControl(source, true); VolControl *vol = new VolControl(source, true);
double meterDecayRate = config_get_double(basicConfig, "Audio",
"MeterDecayRate");
vol->SetMeterDecayRate(meterDecayRate);
vol->setContextMenuPolicy(Qt::CustomContextMenu); vol->setContextMenuPolicy(Qt::CustomContextMenu);
connect(vol, &QWidget::customContextMenuRequested, connect(vol, &QWidget::customContextMenuRequested,
......
...@@ -193,6 +193,7 @@ private: ...@@ -193,6 +193,7 @@ private:
void CreateFirstRunSources(); void CreateFirstRunSources();
void CreateDefaultScene(bool firstStart); void CreateDefaultScene(bool firstStart);
void UpdateVolumeControlsDecayRate();
void ClearVolumeControls(); void ClearVolumeControls();
void UploadLog(const char *file); void UploadLog(const char *file);
......
...@@ -400,6 +400,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) ...@@ -400,6 +400,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
HookWidget(ui->advRBMegsMax, SCROLL_CHANGED, OUTPUTS_CHANGED); HookWidget(ui->advRBMegsMax, SCROLL_CHANGED, OUTPUTS_CHANGED);
HookWidget(ui->channelSetup, COMBO_CHANGED, AUDIO_RESTART); HookWidget(ui->channelSetup, COMBO_CHANGED, AUDIO_RESTART);
HookWidget(ui->sampleRate, COMBO_CHANGED, AUDIO_RESTART); HookWidget(ui->sampleRate, COMBO_CHANGED, AUDIO_RESTART);
HookWidget(ui->meterDecayRate, COMBO_CHANGED, AUDIO_CHANGED);
HookWidget(ui->desktopAudioDevice1, COMBO_CHANGED, AUDIO_CHANGED); HookWidget(ui->desktopAudioDevice1, COMBO_CHANGED, AUDIO_CHANGED);
HookWidget(ui->desktopAudioDevice2, COMBO_CHANGED, AUDIO_CHANGED); HookWidget(ui->desktopAudioDevice2, COMBO_CHANGED, AUDIO_CHANGED);
HookWidget(ui->auxAudioDevice1, COMBO_CHANGED, AUDIO_CHANGED); HookWidget(ui->auxAudioDevice1, COMBO_CHANGED, AUDIO_CHANGED);
...@@ -2119,6 +2120,8 @@ void OBSBasicSettings::LoadAudioSettings() ...@@ -2119,6 +2120,8 @@ void OBSBasicSettings::LoadAudioSettings()
"SampleRate"); "SampleRate");
const char *speakers = config_get_string(main->Config(), "Audio", const char *speakers = config_get_string(main->Config(), "Audio",
"ChannelSetup"); "ChannelSetup");
double meterDecayRate = config_get_double(main->Config(), "Audio",
"MeterDecayRate");
loading = true; loading = true;
...@@ -2147,6 +2150,13 @@ void OBSBasicSettings::LoadAudioSettings() ...@@ -2147,6 +2150,13 @@ void OBSBasicSettings::LoadAudioSettings()
else else
ui->channelSetup->setCurrentIndex(1); ui->channelSetup->setCurrentIndex(1);
if (meterDecayRate == VOLUME_METER_DECAY_MEDIUM)
ui->meterDecayRate->setCurrentIndex(1);
else if (meterDecayRate == VOLUME_METER_DECAY_SLOW)
ui->meterDecayRate->setCurrentIndex(2);
else
ui->meterDecayRate->setCurrentIndex(0);
LoadAudioDevices(); LoadAudioDevices();
LoadAudioSources(); LoadAudioSources();
...@@ -3079,6 +3089,28 @@ void OBSBasicSettings::SaveAudioSettings() ...@@ -3079,6 +3089,28 @@ void OBSBasicSettings::SaveAudioSettings()
config_set_string(main->Config(), "Audio", "ChannelSetup", config_set_string(main->Config(), "Audio", "ChannelSetup",
channelSetup); channelSetup);
if (WidgetChanged(ui->meterDecayRate)) {
double meterDecayRate;
switch (ui->meterDecayRate->currentIndex()) {
case 0:
meterDecayRate = VOLUME_METER_DECAY_FAST;
break;
case 1:
meterDecayRate = VOLUME_METER_DECAY_MEDIUM;
break;
case 2:
meterDecayRate = VOLUME_METER_DECAY_SLOW;
break;
default:
meterDecayRate = VOLUME_METER_DECAY_FAST;
break;
}
config_set_double(main->Config(), "Audio", "MeterDecayRate",
meterDecayRate);
main->UpdateVolumeControlsDecayRate();
}
for (auto &audioSource : audioSources) { for (auto &audioSource : audioSources) {
auto source = OBSGetStrongRef(get<0>(audioSource)); auto source = OBSGetStrongRef(get<0>(audioSource));
if (!source) if (!source)
......
...@@ -37,6 +37,10 @@ class OBSHotkeyWidget; ...@@ -37,6 +37,10 @@ class OBSHotkeyWidget;
#include "ui_OBSBasicSettings.h" #include "ui_OBSBasicSettings.h"
#define VOLUME_METER_DECAY_FAST 23.53
#define VOLUME_METER_DECAY_MEDIUM 11.76
#define VOLUME_METER_DECAY_SLOW 8.57
class SilentUpdateCheckBox : public QCheckBox { class SilentUpdateCheckBox : public QCheckBox {
Q_OBJECT Q_OBJECT
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册