Use cubic scale for volume. Fixes #21

Volume sliders should usually adjust volume using cubic scale. This also changes max volume to 150% which should be louder than previous value anyway.
This commit is contained in:
Rafostar
2020-11-30 09:26:27 +01:00
parent bc5aa45a8f
commit e7ad0143a5
4 changed files with 67 additions and 34 deletions

View File

@@ -1,4 +1,4 @@
const { Gio, GstPlayer, Gtk } = imports.gi;
const { Gio, GstAudio, GstPlayer, Gtk } = imports.gi;
const Debug = imports.clapper_src.debug;
var appName = 'Clapper';
@@ -11,6 +11,8 @@ var settings = new Gio.Settings({
schema_id: appId,
});
var maxVolume = 1.5;
let { debug } = Debug;
let inhibitCookie;
@@ -83,3 +85,21 @@ function getFormattedTime(time, showHours)
let parsed = (hours) ? `${hours}:` : '';
return parsed + `${minutes}:${seconds}`;
}
function getCubicValue(linearVal)
{
return GstAudio.StreamVolume.convert_volume(
GstAudio.StreamVolumeFormat.LINEAR,
GstAudio.StreamVolumeFormat.CUBIC,
linearVal
);
}
function getLinearValue(cubicVal)
{
return GstAudio.StreamVolume.convert_volume(
GstAudio.StreamVolumeFormat.CUBIC,
GstAudio.StreamVolumeFormat.LINEAR,
cubicVal
);
}