libxmp / xmp-cli

Command-line mod player using libxmp
GNU General Public License v2.0
75 stars 22 forks source link

Fix stdout output to support specified driver, and add loop-until feature #61

Closed HunterZ closed 1 year ago

HunterZ commented 1 year ago

Fixes #60 and is at least a possible fix for #14. Both of these changes help with using xmp-cli as a streaming broadcast decoder:

The -c and -o options now cache off the output driver as a "guess" instead of forcing things, and then only applies it to driver_id if the user didn't explicitly specify one via -d. The idea is to allow the user to output a specific audio format to stdout instead of just raw bytes.

A -U / --loop-until option now allows looping to occur until playtime has reached the specified number of seconds. The idea is to allow short loopable mods to play for a bit longer before moving on, so that they don't blow by too quickly in a playlist.

Specific code changes:

sezero commented 1 year ago

About fixing #60: We have to seek back to start of file to write a proper wav header: How is this really helping?

HunterZ commented 1 year ago

About fixing #60: We have to seek back to start of file to write a proper wav header: How is this really helping?

85efbdb2bfda69973e69ff0a62eb3b58 ben2.wav 85efbdb2bfda69973e69ff0a62eb3b58 ben.wav


Again, liquidsoap *needs* a WAV header on stdout, period, so my only other option is to do something silly like pipe through ffmpeg for no good reason. This fix works - I just DJ'd for a half hour on anonradio.net with liquidsoap invoking xmp-cli to render songs to WAV on stdout, which it then encoded to MP3 and passed to an icecast server.

Edit: I guess the redirect test is misleading because apparently `fseek()` works when redirecting stdout to a file but not when writing to a terminal or piping to another program? I guess maybe liquidsoap is just tolerant of that data being missing, or maybe redirects to a temporary file under the hood.

Edit 2: Looks like some software is tolerant (VLC, liquidsoap) and some isn't (Cubic Player), so this is only going to be situationally useful.
sezero commented 1 year ago

@AliceLR ?

sezero commented 1 year ago

OK, then: merging after @AliceLR's approval.