Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 3 123 LastLast
Results 1 to 10 of 30
  1. #1
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,098

    Sample rate for PCM when resampling

    Hi - I was trying to find a solution for the following issue:

    When LMS has to downsample a file because the player does not support its sample rate (eg more then 44.1KHz), the samplerate indicated in the slimproto header is the original rate, not the downsampled one. For any self-describing format, this is not an issue, but for for pcm, the player has no way to know the real sampling rate, so playback sounds like chipmunk. I'm not trying to argue if LMS should send the actual rate or the original one in slimproto, maybe it's by design to let the player display the original file data, but one way to fix that would be to add in the content-type of the stream sent by LMS, the actual sample rate as well (audio/L16;rate=xxx). Today, LMS just sends audio/L16 as a content-type. Can somebody points me a bit where, in the LMS code, this is done so that I can propose a patch? I know marcoc did something for squeezelite, but it does not seem to fill the need of raw PCM and non-local files.

    Thanks
    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

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    19,694

    Sample rate for PCM when resampling

    > rate as well (audio/L16;rate=xxx). Today, LMS just sends audio/L16 as a
    > content-type. Can somebody points me a bit where, in the LMS code, this
    > is done so that I can propose a patch? I know marcoc did something for
    > squeezelite, but it does not seem to fill the need of raw PCM and
    > non-local files.


    And using PCM is a necessity?

    TBH: there are dark corners in our code which I tend not to visit.
    That's certainly one of them... It's certainly somewhere in Slim/Player.

    --

    Michael

  3. #3
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,053
    If the player is a UPnP player then the spec says PCM is a required format option while FLAC is not (and usually unsupported).
    ---
    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. #4
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,098
    Quote Originally Posted by mherger View Post
    > rate as well (audio/L16;rate=xxx). Today, LMS just sends audio/L16 as a
    > content-type. Can somebody points me a bit where, in the LMS code, this
    > is done so that I can propose a patch? I know marcoc did something for
    > squeezelite, but it does not seem to fill the need of raw PCM and
    > non-local files.


    And using PCM is a necessity?

    TBH: there are dark corners in our code which I tend not to visit.
    That's certainly one of them... It's certainly somewhere in Slim/Player.

    --

    Michael
    Quote Originally Posted by pippin View Post
    If the player is a UPnP player then the spec says PCM is a required format option while FLAC is not (and usually unsupported).
    I like the term "dark corners" :-)

    One of the reason why some want to use PCM is that this is the only option for the plugin to support replay gain
    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

  5. #5
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,053
    Why is that?
    ---
    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

  6. #6
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,098
    Quote Originally Posted by pippin View Post
    Why is that?
    Because it's just a bridge that forwards what it receives from LMS, it does not decode the audio (only my airplay bridge does that) and UPnP devices do not support replay gain. But when I receive pcm from LMS, I can apply replay gain on the samples directly (then audio is forwarded to the uPnP player as pcm, wav or aif)
    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

  7. #7
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,053
    Ah, understand
    ---
    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

  8. #8
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,098
    Quote Originally Posted by mherger View Post
    > rate as well (audio/L16;rate=xxx). Today, LMS just sends audio/L16 as a
    > content-type. Can somebody points me a bit where, in the LMS code, this
    > is done so that I can propose a patch? I know marcoc did something for
    > squeezelite, but it does not seem to fill the need of raw PCM and
    > non-local files.


    And using PCM is a necessity?

    TBH: there are dark corners in our code which I tend not to visit.
    That's certainly one of them... It's certainly somewhere in Slim/Player.

    --

    Michael
    I think I've found the place, this is in Slim::Web::HTTP::generateHTTPResponse, around line 1133
    Code:
    } elsif ($path =~ /^(?:stream\.mp3|stream)$/o) {
    			# Bug 15380, return correct content-type depending on what we're streaming
    			if ( my $sc = $client->controller()->songStreamController() ) {
    				if ( my $song = $sc->song() ) {
    					my $type = $song->streamformat();
    					$response->content_type( $Slim::Music::Info::types{$type} );
    				}
    			}
    Where I need to add "rate=' . $obj->samplerate . ';channels=' . $obj->channels" to content_type, hopping that the $obj values are the transcoded ones and not the original ones.

    Now, I need to test but I've never used LMS from the source code directly. Any quick instruction how to do that?
    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

  9. #9
    Senior Member pippin's Avatar
    Join Date
    Oct 2007
    Location
    Berlin
    Posts
    14,053

    Sample rate for PCM when resampling

    Step 1: use any OS but Windows
    Step 2: there is no step 2

    Seriously: if you want to develop anything directly on LMS you probably want to try a different OS.
    Pretty easy to run LMS on a Pi or in a VM on a Windows machine these days...
    ---
    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

  10. #10
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    3,098
    Quote Originally Posted by pippin View Post
    Step 1: use any OS but Windows
    Step 2: there is no step 2

    Seriously: if you want to develop anything directly on LMS you probably want to try a different OS.
    Pretty easy to run LMS on a Pi or in a VM on a Windows machine these days...
    I have LMS running on a Linux Ubuntu VM, a MacOS VM and a few Pi but on my Linux box, I thought the whole Perl source code was in /usr/share/squeezebox but I don't seem to find it there. Only CPAN and a few binaries. I'll look around better

    [edit]: don't know why, I had an old tar archive that I was using for search and did not realize that the slimserver.pl file was missing, so I thought that archive was not made to be "executable". I downloaded a fresh one and it's fine
    Last edited by philippe_44; 2017-03-27 at 19:32.
    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

Posting Permissions

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