Skip to content

Commit 4e7d208

Browse files
committed
sound settings: Split output/input amplification.
1 parent 53a7b99 commit 4e7d208

3 files changed

Lines changed: 56 additions & 17 deletions

File tree

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const VOLUME_ADJUSTMENT_STEP = 0.05; /* Volume adjustment step in % */
3737
const ICON_SIZE = 28;
3838

3939
const CINNAMON_DESKTOP_SOUNDS = "org.cinnamon.desktop.sound";
40-
const OVERAMPLIFICATION_KEY = "allow-amplified-volume";
40+
const OVERAMPLIFICATION_OUT_KEY = "allow-amplified-out-volume";
41+
const OVERAMPLIFICATION_IN_KEY = "allow-amplified-in-volume";
4142

4243
class ControlButton {
4344
constructor(icon, tooltip, callback, small = false) {
@@ -1098,16 +1099,19 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
10981099
let appsys = Cinnamon.AppSystem.get_default();
10991100
appsys.connect("installed-changed", () => this._updateLaunchPlayer());
11001101

1101-
this._sound_settings.connect("changed::" + OVERAMPLIFICATION_KEY, () => this._on_overamplification_change());
1102-
this._on_overamplification_change();
1102+
this._sound_settings.connect("changed::" + OVERAMPLIFICATION_OUT_KEY, () => this._on_overamplification_out_change());
1103+
this._on_overamplification_out_change();
1104+
1105+
this._sound_settings.connect("changed::" + OVERAMPLIFICATION_IN_KEY, () => this._on_overamplification_in_change());
1106+
this._on_overamplification_in_change();
11031107
}
11041108

11051109
_setKeybinding() {
11061110
Main.keybindingManager.addXletHotKey(this, "sound-open", this.keyOpen, Lang.bind(this, this._openMenu));
11071111
}
11081112

1109-
_on_overamplification_change () {
1110-
if (this._sound_settings.get_boolean(OVERAMPLIFICATION_KEY)) {
1113+
_on_overamplification_out_change () {
1114+
if (this._sound_settings.get_boolean(OVERAMPLIFICATION_OUT_KEY)) {
11111115
this._volumeMax = 1.5 * this._volumeNorm;
11121116
this._outputVolumeSection.set_mark(1/1.5);
11131117
}
@@ -1118,6 +1122,18 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
11181122
this._outputVolumeSection._update();
11191123
}
11201124

1125+
_on_overamplification_in_change () {
1126+
if (this._sound_settings.get_boolean(OVERAMPLIFICATION_IN_KEY)) {
1127+
this._volumeMax = 1.5 * this._volumeNorm;
1128+
this._inputVolumeSection.set_mark(1/1.5);
1129+
}
1130+
else {
1131+
this._volumeMax = this._volumeNorm;
1132+
this._inputVolumeSection.set_mark(0);
1133+
}
1134+
this._inputVolumeSection._update();
1135+
}
1136+
11211137
on_settings_changed () {
11221138
if(this.playerControl && this._activePlayer)
11231139
this.setAppletTextIcon(this._players[this._activePlayer], true);

files/usr/share/cinnamon/cinnamon-settings/modules/cs_sound.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
CINNAMON_SOUNDS = "org.cinnamon.sounds"
1212
CINNAMON_DESKTOP_SOUNDS = "org.cinnamon.desktop.sound"
13-
OVERAMPLIFICATION_KEY = "allow-amplified-volume"
13+
OVERAMPLIFICATION_OUT_KEY = "allow-amplified-out-volume"
14+
OVERAMPLIFICATION_IN_KEY = "allow-amplified-in-volume"
1415

1516
DECAY_STEP = .15
1617

@@ -552,8 +553,8 @@ def buildLayout(self):
552553
devSettings.add_row(self.woofer)
553554

554555
# overamplification
555-
switch = GSettingsSwitch(_("Overamplification"), CINNAMON_DESKTOP_SOUNDS, OVERAMPLIFICATION_KEY)
556-
switch.set_tooltip_text(_("Allow the volume to exceed 100%, with reduced sound quality."))
556+
switch = GSettingsSwitch(_("Overamplification"), CINNAMON_DESKTOP_SOUNDS, OVERAMPLIFICATION_OUT_KEY)
557+
switch.set_tooltip_text(_("Allow the output volume to exceed 100%, with reduced sound quality."))
557558
devSettings.add_row(switch)
558559

559560
## Input page
@@ -583,6 +584,11 @@ def buildLayout(self):
583584
devSettings.add_row(self.inLevel)
584585
self.inputStack.add_named(inputBox, "inputBox")
585586

587+
# overamplification
588+
switch = GSettingsSwitch(_("Overamplification"), CINNAMON_DESKTOP_SOUNDS, OVERAMPLIFICATION_IN_KEY)
589+
switch.set_tooltip_text(_("Allow the input volume to exceed 100%, with reduced sound quality."))
590+
devSettings.add_row(switch)
591+
586592
noInputsMessage = Gtk.Box()
587593
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
588594
image = Gtk.Image.new_from_icon_name("xsi-sign-forbidden-symbolic", Gtk.IconSize.DIALOG)
@@ -632,20 +638,27 @@ def buildLayout(self):
632638
noAppsMessage.pack_start(box, True, True, 0)
633639
self.appStack.add_named(noAppsMessage, "noAppsMessage")
634640

635-
self.sound_settings.connect(f"changed::{OVERAMPLIFICATION_KEY}", self.onOverAmplificationChanged)
636-
self.onOverAmplificationChanged()
641+
self.sound_settings.connect(f"changed::{OVERAMPLIFICATION_OUT_KEY}", self.onOverAmplificationOutChanged)
642+
self.onOverAmplificationOutChanged()
643+
self.sound_settings.connect(f"changed::{OVERAMPLIFICATION_IN_KEY}", self.onOverAmplificationInChanged)
644+
self.onOverAmplificationInChanged()
637645

638-
def onOverAmplificationChanged(self, settings=None, key=None):
639-
overamplification = self.sound_settings.get_boolean(OVERAMPLIFICATION_KEY)
646+
def onOverAmplificationOutChanged(self, settings=None, key=None):
647+
overamplificationout = self.sound_settings.get_boolean(OVERAMPLIFICATION_OUT_KEY)
640648
self.outVolume.slider.clear_marks()
641-
self.inVolume.slider.clear_marks()
642-
if overamplification:
649+
if overamplificationout:
643650
self.outVolume.adjustment.set_upper(150)
644-
self.inVolume.adjustment.set_upper(150)
645651
self.outVolume.setMark(100)
646-
self.inVolume.setMark(100)
647652
else:
648653
self.outVolume.adjustment.set_upper(100)
654+
655+
def onOverAmplificationInChanged(self, settings=None, key=None):
656+
overamplificationin = self.sound_settings.get_boolean(OVERAMPLIFICATION_IN_KEY)
657+
self.inVolume.slider.clear_marks()
658+
if overamplificationin:
659+
self.inVolume.adjustment.set_upper(150)
660+
self.inVolume.setMark(100)
661+
else:
649662
self.inVolume.adjustment.set_upper(100)
650663

651664
def inializeController(self):

js/ui/gestures/actions.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,17 @@ var VolumeAction = class extends BaseAction {
316316

317317
const soundSettings = new Gio.Settings({ schema_id: "org.cinnamon.desktop.sound" });
318318

319-
if(soundSettings.get_boolean("allow-amplified-volume"))
319+
if(soundSettings.get_boolean("allow-amplified-out-volume"))
320+
this.max_volume = mixer.get_vol_max_amplified();
321+
else
322+
this.max_volume = mixer.get_vol_max_norm();
323+
324+
this.pct_step = Math.ceil(this.max_volume / 100);
325+
326+
this.last_time = 0;
327+
this.poll_interval = CONTINUOUS_ACTION_POLL_INTERVAL;
328+
329+
if(soundSettings.get_boolean("allow-amplified-in-volume"))
320330
this.max_volume = mixer.get_vol_max_amplified();
321331
else
322332
this.max_volume = mixer.get_vol_max_norm();

0 commit comments

Comments
 (0)