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

@@ -39,8 +39,35 @@
[% END %] [% END %]
[% WRAPPER setting title="PLUGIN_SQUEEZEESP32_EQUALIZER" desc="" %] [% WRAPPER setting title="PLUGIN_SQUEEZEESP32_EQUALIZER" desc="" %]
<div>[% "PLUGIN_SQUEEZEESP32_EQUALIZER_SAVE" | string %]</div>
[% END %] [% END %]
<script TYPE="text/javascript">
if (Ext) {
Ext.onReady(function () {
new Ext.util.TaskRunner().start({
run: checkEq,
interval: 1000
});
});
function checkEq() {
var eqValues = [];
this.lastValues = this.lastValues || [];
for (var x = 0; x < 10; x++) {
eqValues[x] = Ext.get('pref_equalizer.' + x).dom.value || 0;
}
if (eqValues.join() != this.lastValues.join()) {
this.lastValues = eqValues;
SqueezeJS.Controller.request({
params: ['[% playerid %]', ['squeezeesp32', 'seteq', eqValues.join()]]
});
}
}
}
</script>
[% WRAPPER settingSection %] [% WRAPPER settingSection %]
[% WRAPPER settingGroup title='31Hz' desc="" %] [% WRAPPER settingGroup title='31Hz' desc="" %]
<input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.0" id="pref_equalizer.0" value="[% pref_equalizer.0 %]" size="2""> <input type="text" class="stdedit sliderInput_-13_20" name="pref_equalizer.0" id="pref_equalizer.0" value="[% pref_equalizer.0 %]" size="2"">

View File

@@ -43,6 +43,9 @@ sub initPlugin {
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' }); 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"); 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. # 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(@_) }, [ ['newmetadata'] ] );
Slim::Control::Request::subscribe( sub { onNotification(@_) }, [ ['playlist'], ['open', 'newsong'] ]); 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 { sub send_equalizer {
my ($client) = @_; my ($client, $equalizer) = @_;
if ($client->model eq 'squeezeesp32') { 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 $size = @$equalizer;
my $data = pack("c[$size]", @{$equalizer}); my $data = pack("c[$size]", @{$equalizer});
$client->sendFrame( eqlz => \$data ); $client->sendFrame( eqlz => \$data );

View File

@@ -97,3 +97,6 @@ PLUGIN_SQUEEZEESP32_EQUALIZER
DE Parametrischer Equalizer DE Parametrischer Equalizer
EN Parametric equalizer EN Parametric equalizer
PLUGIN_SQUEEZEESP32_EQUALIZER_SAVE
DE Bitte speichern Sie die Equalizer Einstellungen, falls das Gerät diese dauerhaft verwenden soll. Ansonsten werden sie beim nächsten Start zurückgesetzt.
EN Don't forget to save the Equalizer settings if you want them to stick. Otherwise they'll be reset next time you restart the device.