On 30/09/16 12:00, PB peter.northerly@gmail.com wrote:
Hi,
Does anyone understand how Linux audio works, well enough to give me some pointers on this?
Hi Peter,
I'll give it go, having spent far too long with my virtual arm up the insides of Linux audio stuff while getting radio stations working :)
... Sometimes I want to listen to the material on my tiny little portable player when out and about. So I record the stream to file and copy it across. I've discovered two fairly straightforward ways of doing this. They are a bit manual, but I do not do it often so its OK.
[recording the outgoing stream using gramofile or Audacity which both produce WAV files - why?]
This is simply because these tools pick up the raw, uncompressed digital audio stream going out of your SPDIF port, /after/ any app or media player has decoded the incoming (compressed) audio stream. They do this as it's guaranteed to work (no messing with decoders, or strange interfaces) and is always available either from the low level drivers (ALSA) or a preceding audio mixer such as PulseAudio.
There is also a package called streamripper, which seems like it would do this, but I have not yet bothered. It lets you send a user string corresponding to Firefox and to input user name and password. And maybe mplayer will do it, and there is probably a way to input user name and password on VLC from a command line startup. But the above two methods work so I have not hacked around with alternatives any further.
You may have some success, it depends on how the streaming service protect their content using various Digital Rights Management (DRM) techniques (aka encryption/obfuscation). See below.
I would like to be able to save the stream in the mode in which its received. If it is, for instance 320k mp3, then I would like to save it as that, with no recoding which presumably will lower quality. But something else must be going on with gramofile, because its WAV that is written to disk. Similarly with Audacity. At what point are they getting the stream and what are they doing with it? ... And if so, how do you get to write the digital stream being received, with no conversions, just as it comes in, to file?
@see above regarding where gramofile and Audacity get their audio from and why it's always WAV (raw) at this point. These raw audio recordings will be a bit-perfect copy of what you are hearing, no loss of quality.
If you are really streaming MP3 files (not some weird AAC, WMA or other encrypted/protected format), then you /may/ be able to recover the file URL from your browser and use wget or curl to simply fetch the file. Most streaming services however go to great lengths to stop this as they don't want you taking a copy for yourself.
Typical 'protection' mechanisms are: generating the majority of the browser content dynamically using obfuscated Javascript, embedding the media player in Adobe crud ware (Flashplayer), using custom codecs or whole applications that contain decryption keys, using proprietary protocols built on Websockets.. the list is endless and this is why tools like 'streamripper' may not work.
I would continue using your existing technique(s), perhaps compressing the raw WAVs with flac or lame if you want to save disk space.
Cheers, Phil. PS: It used to be possible to use a similar recording technique on Windows XP (from the 'Stereo Mix' device). Microsoft were encouraged by the recording industry to make that much more difficult in later versions, and some sound card manufacturers removed the capability entirely from their device drivers... think yourself lucky that won't happen on Linux :)