diff --git a/HTML/EN/plugins/BS2B/settings/player.html b/HTML/EN/plugins/BS2B/settings/player.html index 655afd7..2e1103a 100644 --- a/HTML/EN/plugins/BS2B/settings/player.html +++ b/HTML/EN/plugins/BS2B/settings/player.html @@ -2,11 +2,27 @@ [% WRAPPER settingSection %] - [% WRAPPER setting title="Enable BS2B" desc="" %] + [% WRAPPER setting title="PLUGIN_BS2B" desc="PLUGIN_BS2B_DESC" %] [% END %] + [% WRAPPER setting title="PLUGIN_BS2B_CROSSFEED_LEVEL" desc="PLUGIN_BS2B_CROSSFEED_LEVEL_DESC" %] +

+ + +

+

+ + +

+

+ + + +

+ [% END %] + [% END %] [% PROCESS settings/footer.html %] diff --git a/PlayerSettings.pm b/PlayerSettings.pm index 446e1e1..702a14a 100644 --- a/PlayerSettings.pm +++ b/PlayerSettings.pm @@ -30,17 +30,24 @@ sub page { } sub handler { - my ($class, $client, $params, $callback, @args) = @_; - - if ($params->{'saveSettings'}) { + my ($class, $client, $params) = @_; - $prefs->client($client)->set('bs2b', $params->{'pref_bs2b'} || 0); + if ( $client ) { + + if ($params->{saveSettings}) { + + $prefs->client($client)->set('bs2b', $params->{'pref_bs2b'} || 0); + $prefs->client($client)->set('bs2b_crossfeed_level', $params->{'pref_bs2b_crossfeed_level'} || 'd'); + + } + + $params->{prefs}->{pref_bs2b} = $prefs->client($client)->get('bs2b') || 0; + $params->{prefs}->{pref_bs2b_crossfeed_level} = $prefs->client($client)->get('bs2b_crossfeed_level') || 'd'; + + Plugins::BS2B::Plugin::setupTranscoder($client); - Plugins::BS2B::Plugin::setupTranscoder($client); } - - $params->{'prefs'}->{'pref_bs2b'}= $prefs->client($client)->get('bs2b') || 0; - + return $class->SUPER::handler($client, $params); } diff --git a/Plugin.pm b/Plugin.pm index 8557002..000b6e9 100644 --- a/Plugin.pm +++ b/Plugin.pm @@ -13,44 +13,58 @@ use Plugins::BS2B::PlayerSettings; my $prefs = preferences('plugin.bs2b'); my $log = Slim::Utils::Log->addLogCategory({ - 'category' => 'plugin.bs2b', - 'defaultLevel' => 'WARN', - 'description' => 'PLUGIN_BS2B', + 'category' => 'plugin.bs2b', + 'defaultLevel' => 'WARN', + 'description' => 'PLUGIN_BS2B', }); sub initPlugin { - my $class = shift; + my $class = shift; - Plugins::BS2B::PlayerSettings->new; + Plugins::BS2B::PlayerSettings->new; - Slim::Control::Request::subscribe(\&initClient, [['client'],['new','reconnect']]); + Slim::Control::Request::subscribe(\&initClient, [['client'],['new','reconnect']]); } sub setupTranscoder { my $client = $_[0] || return; - my $usebs2b = $prefs->client($client)->get('bs2b'); + my $usebs2b = $prefs->client($client)->get('bs2b'); + my $bs2b_preset = $prefs->client($client)->get('bs2b_crossfeed_level'); - my $flc = 'flc-flc-*-' . lc($client->macaddress); + my $flc = 'flc-flc-*-' . lc($client->macaddress); + my $mp3 = 'mp3-mp3-*-' . lc($client->macaddress); - if ($usebs2b) { - - # AU is specifically designed to be written to a pipe (http://www.mega-nerd.com/libsndfile/FAQ.html#Q017) - my $cmdTable = '[sox] -q -t flac $FILE$ -t au - $START$ | [bs2bconvert] /dev/stdin /dev/stdout | [sox] -q -t au - -t flac -C 0 - '; - my $capabilities = { F => 'noArgs', T => 'START=trim %s' }; + if ($usebs2b) { + + # AU is specifically designed to be written to a pipe (http://www.mega-nerd.com/libsndfile/FAQ.html#Q017) + my $flc_cmdTable = '[sox] -q -t flac $FILE$ -t au - $START$ | [bs2bconvert] -l ' . $bs2b_preset . ' /dev/stdin /dev/stdout | [sox] -q -t au - -t flac -C 0 - '; + my $flc_capabilities = { F => 'noArgs', T => 'START=trim %s' }; - $Slim::Player::TranscodingHelper::commandTable{ $flc } = $cmdTable; - $Slim::Player::TranscodingHelper::capabilities{ $flc } = $capabilities; - - } else { + $Slim::Player::TranscodingHelper::commandTable{ $flc } = $flc_cmdTable; + $Slim::Player::TranscodingHelper::capabilities{ $flc } = $flc_capabilities; + + my $mp3_cmdTable = '[sox] -q -t mp3 $FILE$ -t au - $START$ | [bs2bconvert] -l ' . $bs2b_preset . ' /dev/stdin /dev/stdout | [sox] -q -t au - -t wav - | [lame] --silent -q $QUALITY$ $RESAMPLE$ $BITRATE$ - '; + my $mp3_capabilities = { F => 'noArgs', T => 'START=trim %s', IFB => 'BITRATE=--abr %B', 'D' => 'RESAMPLE=--resample %D' }; + + $Slim::Player::TranscodingHelper::commandTable{ $mp3 } = $mp3_cmdTable; + $Slim::Player::TranscodingHelper::capabilities{ $mp3 } = $mp3_capabilities; - my $cmdTable = '[flac] -dcs $START$ $END$ -- $FILE$ | [sox] -q -t wav - -t flac -C 0 -r 48000 - '; - my $capabilities = { F => 'noArgs', T => 'START=--skip=%t', U => 'END=--until=%v', D => 'RESAMPLE=-r %d' }; + } else { + + # Revert to standard convert rules + my $cmdTable = '-'; + my $capabilities = { }; $Slim::Player::TranscodingHelper::commandTable{ $flc } = $cmdTable; $Slim::Player::TranscodingHelper::capabilities{ $flc } = $capabilities; - - } + + $Slim::Player::TranscodingHelper::commandTable{ $mp3 } = $cmdTable; + $Slim::Player::TranscodingHelper::capabilities{ $mp3 } = $capabilities; + + } + + } sub initClient { diff --git a/install.xml b/install.xml index d62bac2..44fec69 100644 --- a/install.xml +++ b/install.xml @@ -12,6 +12,6 @@ SlimServer 7.9 - 8.* + * diff --git a/strings.txt b/strings.txt index 0db7f33..041111b 100644 --- a/strings.txt +++ b/strings.txt @@ -8,3 +8,18 @@ PLUGIN_BS2B_DESC PLUGIN_BS2B_ENABLE EN Enable Bauer stereophonic-to-binaural DSP for this player + +PLUGIN_BS2B_CROSSFEED_LEVEL + EN Crossfeed level + +PLUGIN_BS2B_CROSSFEED_LEVEL_DESC + EN Set the crossfeed level and cut-off frequency. The default preset is closest to the virtual speaker placement with azimuth 30 degrees and the removal of about 3 meters, while listening by headphones. Chu Moy's preset is is close to the parameters of a Chu Moy's crossfeeder. Jan Meier's preset is close to the parameters of a crossfeeder implemented in Jan Meier's CORDA amplifiers. + +PLUGIN_BS2B_CROSSFEED_LEVEL_DEFAULT + EN Default (700Hz/260us, 4.5 dB) + +PLUGIN_BS2B_CROSSFEED_LEVEL_CHUMOY + EN Chu Moy's preset (700Hz/260us, 6.0 dB) + +PLUGIN_BS2B_CROSSFEED_LEVEL_JANMEIER + EN Jan Meier's preset (650Hz/280us, 9.5 dB)