mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 05:57:05 +03:00
equalizer fix
This commit is contained in:
Binary file not shown.
@@ -91,12 +91,19 @@ sub init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$client->SUPER::init(@_);
|
$client->SUPER::init(@_);
|
||||||
$client->config_artwork;
|
main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub initPrefs {
|
sub initPrefs {
|
||||||
my $client = shift;
|
my $client = shift;
|
||||||
|
|
||||||
$sprefs->client($client)->init($defaultPrefs);
|
$sprefs->client($client)->init($defaultPrefs);
|
||||||
|
|
||||||
|
$prefs->client($client)->init( {
|
||||||
|
equalizer => [(0) x 10],
|
||||||
|
artwork => 0,
|
||||||
|
} );
|
||||||
|
|
||||||
$client->SUPER::initPrefs;
|
$client->SUPER::initPrefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +153,15 @@ sub treble {
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub send_equalizer {
|
||||||
|
my ($client, $equalizer) = @_;
|
||||||
|
|
||||||
|
$equalizer ||= $prefs->client($client)->get('equalizer') || [(0) x 10];
|
||||||
|
my $size = @$equalizer;
|
||||||
|
my $data = pack("c[$size]", @{$equalizer});
|
||||||
|
$client->sendFrame( eqlz => \$data );
|
||||||
|
}
|
||||||
|
|
||||||
sub update_equalizer {
|
sub update_equalizer {
|
||||||
my ($client, $value, $index) = @_;
|
my ($client, $value, $index) = @_;
|
||||||
return if $client->tone_update;
|
return if $client->tone_update;
|
||||||
@@ -240,8 +256,11 @@ sub config_artwork {
|
|||||||
|
|
||||||
sub reconnect {
|
sub reconnect {
|
||||||
my $client = shift;
|
my $client = shift;
|
||||||
$client->pluginData('artwork_md5', '');
|
|
||||||
$client->SUPER::reconnect(@_);
|
$client->SUPER::reconnect(@_);
|
||||||
|
|
||||||
|
$client->pluginData('artwork_md5', '');
|
||||||
|
$client->config_artwork;
|
||||||
|
$client->send_equalizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Change the analog output mode between headphone and sub-woofer
|
# Change the analog output mode between headphone and sub-woofer
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ sub page {
|
|||||||
sub prefs {
|
sub prefs {
|
||||||
my ($class, $client) = @_;
|
my ($class, $client) = @_;
|
||||||
my @prefs;
|
my @prefs;
|
||||||
push @prefs, qw(width small_VU) if defined $client->displayWidth;
|
push @prefs, qw(width small_VU) if $client->displayWidth;
|
||||||
return ($prefs->client($client), @prefs);
|
return ($prefs->client($client), @prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ sub handler {
|
|||||||
my ($cprefs, @prefs) = $class->prefs($client);
|
my ($cprefs, @prefs) = $class->prefs($client);
|
||||||
|
|
||||||
if ($paramRef->{'saveSettings'}) {
|
if ($paramRef->{'saveSettings'}) {
|
||||||
if (defined $client->displayWidth) {
|
if ($client->displayWidth) {
|
||||||
$cprefs->set('small_VU', $paramRef->{'pref_small_VU'} || 15);
|
$cprefs->set('small_VU', $paramRef->{'pref_small_VU'} || 15);
|
||||||
my $spectrum = {
|
my $spectrum = {
|
||||||
scale => $paramRef->{'pref_spectrum_scale'} || 25,
|
scale => $paramRef->{'pref_spectrum_scale'} || 25,
|
||||||
@@ -76,7 +76,7 @@ sub handler {
|
|||||||
$client->update_tones($equalizer);
|
$client->update_tones($equalizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $client->displayWidth) {
|
if ($client->displayWidth) {
|
||||||
# the Settings super class can't handle anything but scalar values
|
# the Settings super class can't handle anything but scalar values
|
||||||
# we need to populate the $paramRef for the other prefs manually
|
# we need to populate the $paramRef for the other prefs manually
|
||||||
$paramRef->{'pref_spectrum'} = $cprefs->get('spectrum');
|
$paramRef->{'pref_spectrum'} = $cprefs->get('spectrum');
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ $prefs->migrateClient(1, sub {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$prefs->setChange(sub {
|
$prefs->setChange(sub {
|
||||||
send_equalizer($_[2]);
|
$_[2]->send_equalizer;
|
||||||
}, 'equalizer');
|
}, 'equalizer');
|
||||||
|
|
||||||
sub initPlugin {
|
sub initPlugin {
|
||||||
@@ -40,8 +40,10 @@ sub initPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$class->SUPER::initPlugin(@_);
|
$class->SUPER::initPlugin(@_);
|
||||||
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' });
|
# no name can be a subset of others due to a bug in addPlayerClass
|
||||||
main::INFOLOG && $log->is_info && $log->info("Added class 100 for SqueezeESP32");
|
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32-basic', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' });
|
||||||
|
Slim::Networking::Slimproto::addPlayerClass($class, 101, 'squeezeesp32-graphic', { client => 'Plugins::SqueezeESP32::Player', display => 'Slim::Display::NoDisplay' });
|
||||||
|
main::INFOLOG && $log->is_info && $log->info("Added class 100 and 101 for SqueezeESP32");
|
||||||
|
|
||||||
# register a command to set the EQ - without saving the values! Send params as single comma separated list of values
|
# register a command to set the EQ - without saving the values! Send params as single comma separated list of values
|
||||||
Slim::Control::Request::addDispatch(['squeezeesp32', 'seteq', '_eq'], [1, 0, 0, \&setEQ]);
|
Slim::Control::Request::addDispatch(['squeezeesp32', 'seteq', '_eq'], [1, 0, 0, \&setEQ]);
|
||||||
@@ -50,9 +52,6 @@ sub initPlugin {
|
|||||||
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['newmetadata'] ] );
|
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['newmetadata'] ] );
|
||||||
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['playlist'], ['open', 'newsong'] ]);
|
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['playlist'], ['open', 'newsong'] ]);
|
||||||
Slim::Control::Request::subscribe( \&onStopClear, [ ['playlist'], ['stop', 'clear'] ]);
|
Slim::Control::Request::subscribe( \&onStopClear, [ ['playlist'], ['stop', 'clear'] ]);
|
||||||
|
|
||||||
# the custom player class is only initialized if it has a display - thus we need to listen to connect events in order to initializes other player prefs
|
|
||||||
Slim::Control::Request::subscribe( \&onPlayer,[ ['client'], [ 'new', 'reconnect' ] ] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub onStopClear {
|
sub onStopClear {
|
||||||
@@ -64,20 +63,6 @@ sub onStopClear {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub onPlayer {
|
|
||||||
my $request = shift;
|
|
||||||
my $client = $request->client || return;
|
|
||||||
|
|
||||||
if ($client->model eq 'squeezeesp32') {
|
|
||||||
main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
|
|
||||||
|
|
||||||
$prefs->client($client)->init( {
|
|
||||||
equalizer => [(0) x 10],
|
|
||||||
} );
|
|
||||||
send_equalizer($client);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sub onNotification {
|
sub onNotification {
|
||||||
my $request = shift;
|
my $request = shift;
|
||||||
my $client = $request->client || return;
|
my $client = $request->client || return;
|
||||||
@@ -104,18 +89,7 @@ sub setEQ {
|
|||||||
$eqParams[$x] ||= 0;
|
$eqParams[$x] ||= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
send_equalizer($client, \@eqParams);
|
$client->send_equalizer(\@eqParams);
|
||||||
}
|
|
||||||
|
|
||||||
sub send_equalizer {
|
|
||||||
my ($client, $equalizer) = @_;
|
|
||||||
|
|
||||||
if ($client->model eq 'squeezeesp32') {
|
|
||||||
$equalizer ||= $prefs->client($client)->get('equalizer') || [(0) x 10];
|
|
||||||
my $size = @$equalizer;
|
|
||||||
my $data = pack("c[$size]", @{$equalizer});
|
|
||||||
$client->sendFrame( eqlz => \$data );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -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.104</version>
|
<version>0.201</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.200" name="SqueezeESP32" minTarget="7.9" maxTarget="*">
|
<plugin version="0.201" 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>ab2d65f5ba8e73f0f78a1a8650af19ebb1e8e724</sha>
|
<sha>c7134a3f03fbb836c48c929700ad7765854644f7</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