mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 22:17:17 +03:00
better synchronize bass/treble & equalizer
This commit is contained in:
Binary file not shown.
@@ -13,6 +13,19 @@ my $sprefs = preferences('server');
|
|||||||
my $prefs = preferences('plugin.squeezeesp32');
|
my $prefs = preferences('plugin.squeezeesp32');
|
||||||
my $log = logger('plugin.squeezeesp32');
|
my $log = logger('plugin.squeezeesp32');
|
||||||
|
|
||||||
|
{
|
||||||
|
__PACKAGE__->mk_accessor('rw', 'tone_update');
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my $class = shift;
|
||||||
|
my $client = $class->SUPER::new(@_);
|
||||||
|
$client->init_accessor(
|
||||||
|
tone_update => 0,
|
||||||
|
);
|
||||||
|
return $client;
|
||||||
|
}
|
||||||
|
|
||||||
our $defaultPrefs = {
|
our $defaultPrefs = {
|
||||||
'analogOutMode' => 0,
|
'analogOutMode' => 0,
|
||||||
'bass' => 0,
|
'bass' => 0,
|
||||||
@@ -54,6 +67,9 @@ sub init {
|
|||||||
my $client = shift;
|
my $client = shift;
|
||||||
|
|
||||||
if (!$handlersAdded) {
|
if (!$handlersAdded) {
|
||||||
|
|
||||||
|
$sprefs->setChange( \&change_tone, 'bass');
|
||||||
|
$sprefs->setChange( \&change_tone, 'treble');
|
||||||
|
|
||||||
# Add a handler for line-in/out status changes
|
# Add a handler for line-in/out status changes
|
||||||
Slim::Networking::Slimproto::addHandler( LIOS => \&lineInOutStatus );
|
Slim::Networking::Slimproto::addHandler( LIOS => \&lineInOutStatus );
|
||||||
@@ -116,26 +132,48 @@ sub playerSettingsFrame {
|
|||||||
$client->SUPER::playerSettingsFrame($data_ref);
|
$client->SUPER::playerSettingsFrame($data_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub bass {
|
sub change_tone {
|
||||||
return tone(2, @_);
|
my ($type, $new, $client, $old) = @_;
|
||||||
}
|
return $client->$type($new) unless $client->isa('Plugins::SqueezeESP32::Player') && !$client->tone_update;
|
||||||
|
|
||||||
sub treble {
|
my ($c, $minValue, $maxValue);
|
||||||
return tone(8, @_);
|
my $equalizer = $prefs->client($client)->get('equalizer');
|
||||||
|
|
||||||
|
if ($type eq 'bass') {
|
||||||
|
$c = 2;
|
||||||
|
$minValue = minBass;
|
||||||
|
$maxValue = maxBass;
|
||||||
|
} else {
|
||||||
|
$c = 8;
|
||||||
|
$minValue = minTreble;
|
||||||
|
$maxValue = maxTreble;
|
||||||
|
}
|
||||||
|
|
||||||
|
$new = $minValue if $new < $minValue;
|
||||||
|
$new = $minValue if $new < $minValue;
|
||||||
|
|
||||||
|
if ($old - $minValue) {
|
||||||
|
my $ratio = ($new - $minValue) / ($old - $minValue) - 1;
|
||||||
|
$equalizer->[$c-1] = min(int(($equalizer->[$c-1] - $minValue) * (1 + 0.2 * $ratio) + 0.5 + $minValue), $maxValue);
|
||||||
|
$equalizer->[$c] = min(int(($equalizer->[$c] - $minValue) * (1 + 0.7 * $ratio) + 0.5 + $minValue), $maxValue);
|
||||||
|
$equalizer->[$c+1] = min(int(($equalizer->[$c+1] - $minValue) * (1 + 0.1 * $ratio) + 0.5 + $minValue), $maxValue);
|
||||||
|
} else {
|
||||||
|
$equalizer->[$c-1] = int($new * 0.2 + 0.5);
|
||||||
|
$equalizer->[$c] = int($new * 0.7 + 0.5);
|
||||||
|
$equalizer->[$c+1] = int($new * 0.1 + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
$prefs->client($client)->set('equalizer', $equalizer);
|
||||||
|
$sprefs->client($client)->set($type, $new);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub tone {
|
sub update_tones {
|
||||||
my ($center, $client, $value) = @_;
|
my ($client, $equalizer) = @_;
|
||||||
my $equalizer = $prefs->client($client)->get('equalizer');
|
|
||||||
|
|
||||||
if (defined($value)) {
|
|
||||||
$equalizer->[$center-1] = int($value * 0.2 + 0.5);
|
|
||||||
$equalizer->[$center] = int($value * 0.7 + 0.5);
|
|
||||||
$equalizer->[$center+1] = int($value * 0.1 + 0.5);
|
|
||||||
$prefs->client($client)->set('equalizer', $equalizer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return int($equalizer->[$center-1] * 0.2 + $equalizer->[$center] * 0.7 + $equalizer->[$center+1] * 0.1);
|
$client->tone_update(1);
|
||||||
|
$sprefs->client($client)->set('bass', int($equalizer->[1]*0.2 + $equalizer->[2]*0.7 + $equalizer->[3]*0.1 + 0.5));
|
||||||
|
$sprefs->client($client)->set('treble', int($equalizer->[7]*0.2 + $equalizer->[8]*0.7 + $equalizer->[9]*0.1 + 0.5));
|
||||||
|
$client->tone_update(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub update_artwork {
|
sub update_artwork {
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ sub handler {
|
|||||||
$equalizer->[$i] = $paramRef->{"pref_equalizer.$i"} || 0;
|
$equalizer->[$i] = $paramRef->{"pref_equalizer.$i"} || 0;
|
||||||
}
|
}
|
||||||
$cprefs->set('equalizer', $equalizer);
|
$cprefs->set('equalizer', $equalizer);
|
||||||
|
$client->update_tones($equalizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($client->displayWidth) {
|
if ($client->displayWidth) {
|
||||||
|
|||||||
@@ -10,6 +10,6 @@
|
|||||||
<name>PLUGIN_SQUEEZEESP32</name>
|
<name>PLUGIN_SQUEEZEESP32</name>
|
||||||
<description>PLUGIN_SQUEEZEESP32_DESC</description>
|
<description>PLUGIN_SQUEEZEESP32_DESC</description>
|
||||||
<module>Plugins::SqueezeESP32::Plugin</module>
|
<module>Plugins::SqueezeESP32::Plugin</module>
|
||||||
<version>0.101</version>
|
<version>0.102</version>
|
||||||
<creator>Philippe</creator>
|
<creator>Philippe</creator>
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<?xml version='1.0' standalone='yes'?>
|
<?xml version='1.0' standalone='yes'?>
|
||||||
<extensions>
|
<extensions>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin version="0.101" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
|
<plugin version="0.102" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
|
||||||
<link>https://github.com/sle118/squeezelite-esp32</link>
|
<link>https://github.com/sle118/squeezelite-esp32</link>
|
||||||
<creator>Philippe</creator>
|
<creator>Philippe</creator>
|
||||||
<sha>49cb70db3a3d4359360332f1f49a845e2e4970b8</sha>
|
<sha>f9c8fbc60812bed4e3989e6dfa3e99fb1a2869c3</sha>
|
||||||
<email>philippe_44@outlook.com</email>
|
<email>philippe_44@outlook.com</email>
|
||||||
<desc lang="EN">SqueezeESP32 additional player id (100)</desc>
|
<desc lang="EN">SqueezeESP32 additional player id (100)</desc>
|
||||||
<url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url>
|
<url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url>
|
||||||
|
|||||||
Reference in New Issue
Block a user