Home of the Squeezebox™ & Transporter® network music players.
Page 3 of 3 FirstFirst 123
Results 21 to 30 of 30
  1. #21
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    535
    Try to follow this:


    When a Song is opened:

    Code:
    ($transcoder, $error) = Slim::Player::TranscodingHelper::getConvertCommand2(
    			$self,
    			$format,
    			\@streamFormats, [], \@wantOptions);
    in Slim::Player::TranscodingHelper::getConvertCommand 2:

    Code:
    my $samplerateLimit = $song ? Slim::Player::CapabilitiesHelper::samplerateLimit($song) : 0;
    	SAMPLELIMIT: if ($samplerateLimit) {
    		foreach (@$need) {
    			last SAMPLELIMIT if /D/;
    		}
    		push @$need, 'D';
    	}
    
    ...
    
    $transcoder = {
    			command          => $command,
    			profile          => $profile,
    			usedCapabilities => [@$need, @$want],
    			streamMode       => $streamMode,
    			streamformat     => (split (/-/, $profile))[1],
    			rateLimit        => $rateLimit || 320,
    			samplerateLimit  => $samplerateLimit || 44100,
    			clientid         => $clientid || 'undefined',
    			groupid          => $clientprefs ? ($clientprefs->get('syncgroupid') || 0) : 0,
    			name             => $client ? $client->name : 'undefined',
    			player           => $player || 'undefined',
    			channels         => $track->channels() || 2,
    			outputChannels   => $clientprefs ? ($clientprefs->get('outputChannels') || 2) : 2,
    		};
    in Slim::Player::CapabilitiesHelper::samplerateLimit

    Code:
    sub samplerateLimit {
    	my $song     = shift;
    	
    	my $srate = $song->currentTrack()->samplerate;
    	
    	return undef if ! $srate;
    
    	my $maxRate = 0;
    	
    	foreach ($song->master()->syncGroupActiveMembers()) {
    		my $rate = $_->maxSupportedSamplerate();
    		if ($rate && ($maxRate && $maxRate > $rate || !$maxRate)) {
    			$maxRate = $rate;
    		}
    	}
    	
    	if ($maxRate && $maxRate < $srate) {
    		if (($maxRate % 12000) == 0 && ($srate % 11025) == 0) {
    			$maxRate = int($maxRate * 11025 / 12000);
    		}
    		return $maxRate;
    	}
    	
    	return undef;
    }
    So $transcoder->{samplerateLimit} is the minimum value among the track sample rate and the sample rate limit of any player in the sync group. If track is undefined, i.e remote stream, 44100.

    then Song::Open continues, few lines below:

    Code:
    my $command = Slim::Player::TranscodingHelper::tokenizeConvertCommand2(
    					$transcoder, $sock ? '-' : $track->path, $self->streamUrl(), $usepipe, $quality
    				);
    that replace placeholders with actual values:

    Code:
    my ($transcoder, $filepath, $fullpath, $noPipe, $quality) = @_;
    	
    	...
    
    	foreach my $v (keys %vars) {
    		my $value;
    		
    		if ($v eq 's') {$value = "$start";}
                    ...
    		elsif ($v eq 'D') {$value = $transcoder->{'samplerateLimit'} / 1000;}
                    ...
    
    		foreach (values %subs) {
    			s/%$v/$value/ge;
    		}
    	}
    
    ...
    
    	main::INFOLOG && $log->is_info && $log->info("Using command for conversion: ", Slim::Utils::Unicode::utf8decode_locale($command));
    
    	return $command;
    }
    Then, if the song is not a track, Downsample option is set to 44100.

    BUT if this is not the line going to be executed (as is in my case when upsampling), then you have the error.

    To understand why it could happen, try to follow stream mode and capabilities rules (that's a real damn dark corner).
    Last edited by marcoc1712; 2017-04-02 at 04:51.
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

  2. #22
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,365
    Quote Originally Posted by marcoc1712 View Post
    Try to follow this:
    ...
    To understand why it could happen, try to follow stream mode and capabilities rules (that's a real damn dark corner).
    Thanks Marco - I'll try to understand all this, but it's probably going to take a while for me ...

    To your other comment on squeezelite patch, do you know when LMS is supposed to send a file with a WAV/AIFF header? I all my experiences developping bridges, I always got a raw PCM flow when pcm was the selected codec and files are wav or aiff (except with a "bug" in 7.7 where there is 8 unwanted bytes at the beginning of the stream when sending aiff). In fact, it does not seem to me that slimproto gives you any hint of what you receive, except PCM and endianness. Do you assume wav vs aiff purely based on endianness? Still, I never received a header when streaming in PCM, whatever the source format was.

    For example, the convert.conf rules for flac to pcm is

    flc pcm * *
    # FT:{START=--skip=%t}U:{END=--until=%v}
    [flac] -dcs --force-raw-format --endian=little --sign=signed $START$ $END$ -- $FILE$

    Which seems to me that the --force-raw-format prevents a wav header to be added by flac
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5

  3. #23
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,202
    Isn't the file just being sent if you play a file that's on the same machine as server and player?
    ---
    learn more about iPeng, the iPhone and iPad remote for the Squeezebox and
    Logitech UE Smart Radio as well as iPeng Party, the free Party-App,
    at penguinlovesmusic.com
    New: iPeng 9, the Universal App for iPhone, iPad and Apple Watch

  4. #24
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    535
    Quote Originally Posted by philippe_44 View Post
    Thanks Marco - I'll try to understand all this, but it's probably going to take a while for me ...

    To your other comment on squeezelite patch, do you know when LMS is supposed to send a file with a WAV/AIFF header? I all my experiences developping bridges, I always got a raw PCM flow when pcm was the selected codec and files are wav or aiff (except with a "bug" in 7.7 where there is 8 unwanted bytes at the beginning of the stream when sending aiff). In fact, it does not seem to me that slimproto gives you any hint of what you receive, except PCM and endianness. Do you assume wav vs aiff purely based on endianness? Still, I never received a header when streaming in PCM, whatever the source format was.

    For example, the convert.conf rules for flac to pcm is

    [code]

    flc pcm * *
    # FT:{START=--skip=%t}U:{END=--until=%v}
    [flac] -dcs --force-raw-format --endian=little --sign=signed $START$ $END$ -- $FILE$

    Which seems to me that the --force-raw-format prevents a wav header to be added by flac
    I always convert to WAV (or AIFF) viaC-3PO plugin, that is the same as using custom-convert.conf lines like:
    Code:
    flc pcm * 00:20:00:00:00:17 
      # FRI
      [flac] -dcs --totally-silent $START$ $END$ -- $FILE$ | [sox] -q -t wav - -t wav -b 24 -  gain -h rate -v -L -b 90.7 96000
    
    wav pcm * 00:20:00:00:00:17
      # FRT:{START=--skip=%t}U:{END=--until=%v}
      [flac] -cs --totally-silent --compression-level-0 $START$ $END$ -- $FILE$ | [sox] -q -t flac - -t wav -b 24 -  gain -h rate -v -L -b 90.7 96000
    
    aif aif * 00:20:00:00:00:17
      # FR
      [sox] -q -t aif $FILE$ -t aif-b 24 -  gain -h rate -v -L -b 90.7 96000
    I capability is used when input is flac, so I could listen to Qobuz and T when wav, so I could use cue sheets. Too bad, You could not use both when transcoding.

    Note that in the profile name I use pcm instead of wav, but is just the same, becouse Transcoding helper will replace wav with pcm anyway.

    N.B:

    I did not test above lines, probably they needs some hack.
    Last edited by marcoc1712; 2017-04-03 at 08:00.
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

  5. #25
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    535
    Quote Originally Posted by pippin View Post
    Isn't the file just being sent if you play a file that's on the same machine as server and player?
    Don't know, my server is in the basement and the listening room in the attic, but I think you need 'local player plugin' to do that. When trascoding, at least, file is opened by the server and streamed to the player.
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

  6. #26
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,365
    Quote Originally Posted by pippin View Post
    Isn't the file just being sent if you play a file that's on the same machine as server and player?
    Only if you have enabled the "loc" extension that Triode created. This is a capability that the player has to report. For my plugins, I had to disable it, so I don't have access to the actual file
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5

  7. #27
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,365
    Quote Originally Posted by marcoc1712 View Post
    I always convert to WAV (or AIFF) viaC-3PO plugin, that is the same as using custom-convert.conf lines like:
    Code:
    flc pcm * 00:20:00:00:00:17 
      # FRI
      [flac] -dcs --totally-silent $START$ $END$ -- $FILE$ | [sox] -q -t wav - -t wav -b 24 -  gain -h rate -v -L -b 90.7 96000
    
    wav pcm * 00:20:00:00:00:17
      # FRT:{START=--skip=%t}U:{END=--until=%v}
      [flac] -cs --totally-silent --compression-level-0 $START$ $END$ -- $FILE$ | [sox] -q -t flac - -t wav -b 24 -  gain -h rate -v -L -b 90.7 96000
    
    aif aif * 00:20:00:00:00:17
      # FR
      [sox] -q -t aif $FILE$ -t aif-b 24 -  gain -h rate -v -L -b 90.7 -f 96000
    I capability is used when input is flac, so I could listen to Qobuz and T when wav, so I could use cue sheets. Too bad, You could not use both when transcoding.

    Note that in the profile name I use pcm instead of wav, but is just the same, becouse Transcoding helper will replace wav with pcm anyway.

    N.B:

    I did not test above lines, probably they needs some hack.
    That makes sense now. I purposely did not require for a custom-convert.conf because I did not want user to have to tinker with that on top of the rest. My plugins are already complicated enough to tweak sometimes .
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5

  8. #28
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    535
    Quote Originally Posted by philippe_44 View Post
    That makes sense now. I purposely did not require for a custom-convert.conf because I did not want user to have to tinker with that on top of the rest. My plugins are already complicated enough to tweak sometimes .
    You could hide this step into your plugin, as C-3PO does, no needs to use cutom-convert.conf. If I where you, I'll consider to use a 'special' file format to transcode to and use it just in your plugins.
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

  9. #29
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,365
    Quote Originally Posted by marcoc1712 View Post
    You could hide this step into your plugin, as C-3PO does, no needs to use cutom-convert.conf. If I where you, I'll consider to use a 'special' file format to transcode to and use it just in your plugins.
    ah, I did not know that this could be hidden - in what sense? One thing as well with my plugins is that the binary helper is made to work on an independent machine, with no Perl script to help (a bit like the difference between "squeezelite" and "local player")
    LMS 7.7, 7.8 and 7.9 - 5xRadio, 3xBoom, 4xDuet, 1xTouch, 1 SB2. Sonos PLAY:3, PLAY:5, Marantz NR1603, JBL OnBeat, XBoxOne, XBMC, Foobar2000, ShairPortW, JRiver 21, 2xChromecast Audio, Chromecast v1 and v2, , Pi B3, B2, Pi B+, 2xPi A+, Odroid-C1, Odroid-C2, Cubie2, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5

  10. #30
    Senior Member
    Join Date
    Dec 2009
    Location
    Albinea (Bologna Area) Italy
    Posts
    535
    Quote Originally Posted by philippe_44 View Post
    ah, I did not know that this could be hidden - in what sense? One thing as well with my plugins is that the binary helper is made to work on an independent machine, with no Perl script to help (a bit like the difference between "squeezelite" and "local player")
    You could feed the transcoding table in lMS (the one considered by transodingHelper when looking for the command to apply to reproduce the specific selected song) in different ways:

    a. via standard convert.conf
    b. via generic custom-convert.conf
    c. via plugin specific convert.conf
    d. via direct write into that table from code, like that:

    Code:
     my $newProfile= "flc-pcm-*-*";
    
     $Slim::Player::TranscodingHelper::commandTable{ $newProfile } = $myCommand;
     $Slim::Player::TranscodingHelper::capabilities{ $newProfile } = $myCapabilities;
    where

    $myCommand is a string and $myCapabilities an hash like this:

    Code:
    my $capabilities = { 
    	#	I => 'noArgs',   # Qubuz or .cue.
    	#	I => 'FILE=-',   # Is the Daphile way, needs a patch to LMS.
    	#	F => 'FILE=-f %f', 
    	#	R => 'FILE=-f %F', 
    		F => 'noArgs', 
    		R => 'noArgs',
    	#	T => 'START=-s %s', 
    	#	U => 'END=-w %w', 
    		D => 'RESAMPLE=-r %d'
    	};
    try to dump:

    Slim::Player::TranscodingHelper::Conversions();
    %Slim::Player::TranscodingHelper::capabilities;

    to see how actual situation is.

    Of corse you could also remove profiles form the table or disable them:

    Code:
    sub _disableProfile{
    	my $profile = shift;
        
    	my @disabled = @{ $serverPreferences->get('disabledformats') };
    	my $found=0;
    	for my $format (@disabled) {
    		
    		if ($format eq $profile){
    			$found=1;
    			last;}
    	}
    	if (! $found ){
    		push @disabled, $profile;
    		$serverPreferences->set('disabledformats', \@disabled);
    		$serverPreferences->writeAll();
    		$serverPreferences->savenow();
    	}
    }
    __________________________________________________ __________
    SB+, Klimo Merlino + Kent Gold, Monitor Audio Studio 20 Gold SE+, Klimo reference and DIS Interconnect.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •