Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Nov 2014
    Posts
    18

    Playing streams of various PCM formats

    Hello,

    I imagine this is basic stuff and was answered before, but I searched for both wav and pcm and didn't find any posts... so sorry if this is redundant.

    I'm trying to write a plugin that can play raw PCM audio from a URL (format can't be determined by URL or content) and want to be able to tell the plugin how to correctly decode the PCM (i.e. it's 24 bit, 2 channel, big-endian, 44100...) I'm not sure what things I need to implement in the plugin to identify which format to LMS.

    Can anyone point me in the right direction?
    I couldn't find a plugin I thought was doing this with PCM.

    I'm not even sure what the correct approach to this should be. Should I be using the custom-convert, for example?
    Am I inventing my own format to do that (because I don't want to override all wav/pcm handling, just for this plugin, and even then, it can change depending on what my source is sending.

    I thought defining the type and relevant attributes (i.e. rate, endian, etc.) would make the most sense, but I can't figure out how to do it.

    Any help would be greatly appreciated.
    Thanks!

    P.S. I should have mentioned that I'm starting with a protocol handler derived from "use base qw(IO::Handle);"
    I hope that's OK. I didn't know where else to start and I have to retrieve the audio in chunks a little bit at a time and this seemed like the best way to do that.
    Last edited by littla; 2022-08-15 at 09:16. Reason: Add more information

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

    Playing streams of various PCM formats

    > I'm not even sure what the correct approach to this should be. Should I
    > be using the custom-convert, for example?
    > Am I inventing my own format to do that (because I don't want to
    > override all wav/pcm handling, just for this plugin, and even then, it
    > can change depending on what my source is sending.


    I don't know your exact use case. But yes, using your own
    protocolhandler might be one reasonable approach. You'd define one PH
    per exact format. The PH then would tell LMS what bitrate to use,
    channels etc. A custom-convert file might be part of that solution.

  3. #3
    Senior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    7,968
    Quote Originally Posted by mherger View Post
    > I'm not even sure what the correct approach to this should be. Should I
    > be using the custom-convert, for example?
    > Am I inventing my own format to do that (because I don't want to
    > override all wav/pcm handling, just for this plugin, and even then, it
    > can change depending on what my source is sending.


    I don't know your exact use case. But yes, using your own
    protocolhandler might be one reasonable approach. You'd define one PH
    per exact format. The PH then would tell LMS what bitrate to use,
    channels etc. A custom-convert file might be part of that solution.
    You can look at the tidal plugin (wimp) which is part of the core LMS distribution. Itĺs a good example of what you can do, especially on the protocol handler part. But you have many other examples in the Slim/Plugin directory. I just know that this one is up to date with recent LMS capabilities.
    LMS 8.2 on Odroid-C4 - SqueezeAMP!, 5xRadio, 5xBoom, 2xDuet, 1xTouch, 1xSB3. Sonos PLAY:3, PLAY:5, Marantz NR1603, Foobar2000, ShairPortW, 2xChromecast Audio, Chromecast v1 and v2, Squeezelite on Pi, Yamaha WX-010, AppleTV 4, Airport Express, GGMM E5, RivaArena 1 & 3

  4. #4
    Junior Member
    Join Date
    Nov 2014
    Posts
    18

    Thanks everyone!

    Thank you mherger and philippe_44!

    I ended up with this working: (in case anyone else has the same question)

    sub new {
    my $class = shift;
    my $args = shift;

    my $client = $args->{'client'};
    my $song = $args->{'song'};
    my $url = ($song->can('streamUrl') ? $song->streamUrl : $song->{'streamUrl'}) || $args->{'url'};

    my $self = $class->SUPER::new;

    $song->samplerate(44100);
    $song->samplesize(16);
    $song->channels(2);
    # Specify the decoding parameters
    $song->currentTrack()->samplerate(48000);
    $song->currentTrack()->samplesize(24);
    $song->currentTrack()->channels(2);
    $song->currentTrack()->endian(1);

    ${*$self}{'song'} = $song; # Return the Song data to the protocol handler! (essential)
    return $self;
    }

    I'm not sure it's the best way to do it... but it's working, so that's good. :-)

Posting Permissions

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