Make the EQ in player settings update the player in "real time" as you change the values.

This commit is contained in:
Michael Herger
2020-05-08 13:42:40 +02:00
parent 338c6e5a1b
commit 192847af89
3 changed files with 55 additions and 2 deletions

View File

@@ -43,6 +43,9 @@ sub initPlugin {
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' });
main::INFOLOG && $log->is_info && $log->info("Added class 100 for SqueezeESP32");
# 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]);
# Note for some forgetful know-it-all: we need to wrap the callback to make it unique. Otherwise subscriptions would overwrite each other.
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['newmetadata'] ] );
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['playlist'], ['open', 'newsong'] ]);
@@ -84,11 +87,31 @@ sub onNotification {
}
}
sub setEQ {
my $request = shift;
# check this is the correct command.
if ($request->isNotCommand([['squeezeesp32'],['seteq']])) {
$request->setStatusBadDispatch();
return;
}
# get our parameters
my $client = $request->client();
my @eqParams = split(/,/, $request->getParam('_eq') || '');
for (my $x = 0; $x < 10; $x++) {
$eqParams[$x] ||= 0;
}
send_equalizer($client, \@eqParams);
}
sub send_equalizer {
my ($client) = @_;
my ($client, $equalizer) = @_;
if ($client->model eq 'squeezeesp32') {
my $equalizer = $prefs->client($client)->get('equalizer') || [(0) x 10];
$equalizer ||= $prefs->client($client)->get('equalizer') || [(0) x 10];
my $size = @$equalizer;
my $data = pack("c[$size]", @{$equalizer});
$client->sendFrame( eqlz => \$data );