Lossless streaming?

    • March 17, 2023 at 3:39 pm #5516
      Bob Olhsson

        I’ve been exploring FLAC along with Amazon lossless streaming. It can sound really good, but half the time Radio Swiss Jazz sounds better streaming 96kbps AAC+ at 48 kHz!

        Why is this?

      • March 17, 2023 at 4:33 pm #5517

        I sure as hell wouldn’t know why.  But I do have a question…

        So what does “better” mean?  Are you comparing to the original pre-compressed audio?  The lossless should sound exactly the same, otherwise it ain’t lossless.

        Now if “better” means something other than faithful to the original, then maybe the audio processed by the lossy encoding has a perceptually useful effect.

        When I think of testing these kind of perceptual options, I think it should be as we would with Monster Cable or something like that.  It should be blind (or Stan Lipshitz would insist double blind) and it should be AB testing not ABX.  And half the time A and B should be identical sounds, which is what keeps the test subjects honest.

        So you hear sound A and you hear sound B.  You can even repeat hearing sound A and sound B.  Then the only question that the test subject has to answer is: “Are these two sounds identical?  Or are they different?”  It’s a yes or no answer, and the answer is either correct or incorrect.

        We subtract the number of false positives from the number of true positives and we subtract the number of false negatives from the number of true negatives and report those two numbers for each test subject.  If these two differences are a decent positive number (in proportion to the number of test sounds), then it can be inferred that this subject can accurately hear the difference when there is a difference.

        But objectively testing for “sounds better” becomes a much more difficult thing.  What’s “better” for you might not be what sounds better to me.  I dunno.

      • March 17, 2023 at 8:38 pm #5518
        Bob Olhsson

          “Better” to me means dynamics, imaging, openness and low distortion. I realize this may be mostly a matter of garbage in = garbage out. It’s also probably about common signal processing they are not doing.

          • March 18, 2023 at 4:26 am #5519

            So would the original audio (before it’s sent to FLAC or AAC or MP3 or any other kinda data compression algorithm) would that audio be the best, then, in terms of all these subjective properties of dynamics, imaging, openness, and distortion?

        • March 18, 2023 at 5:30 pm #5521
          Phil Koenig

            FLAC is bit-for-bit identical with PCM wavs.  I can’t vouch for AAC though; I never use it.

          • March 18, 2023 at 7:34 pm #5522

            AAC is lossy, of course.  So what comes outa the decoder ain’t gonna be bit-for-bit identical with the original going into the encoder.  But FLAC and any other lossless codec should be bit-for-bit.  If it is not bit-for-bit identical, then a glitch happened somewhere, but alpha and beta testing should have uncovered any bugs that would do that.

            If a lossless coding algorithm is working, the worst you can toss it is broadbanded white noise.  It will likely not compress at all.  Some algs might result in a “compressed” file that is longer than the original.

          • March 18, 2023 at 8:32 pm #5523
            James Johnston

              FLAC should always sound better than AAC, bearing in mind I’m the guy who invented the biggest part of AAC.

              AAC is better than any of the other codecs out there, as far as I know, still IF YOU HAVE A GOOD ENCODER.

              But, if you can get lossless, get lossless.  Geeeze, louise.  I’ve been saying this about codecs (many of which I invented) since 1989 if not before that.

              If the lossless sounds worse, something’s wrong with the input. EOF.

              • March 24, 2023 at 9:14 pm #5574
                Alexey Lukin

                  I’ve heard that Opus has a slight edge in quality over AAC. It’s also patent-free, but it’s more recent and much less popular than AAC.

              • March 19, 2023 at 3:56 pm #5524
                Bob Olhsson


                  It just seems like most streamed music is pretty bad sounding. What can we do to encourage more engaging sounding recordings? At this point most young people have never experienced any.

                  • March 19, 2023 at 4:22 pm #5525

                    128 kbits/second is a lotta reduction in information than, say a raw CD (not including redundancy for error correction): 2 ch × 44100 sample/sec × 16 bits/word, which is 1378 kbits/second.  More than 10 times more.

                    Now, I know about two mathematical processes that have been used for lossless encoding since ca. 1990.  These would be Linear Predictive Coding to make a very good guess at what the next sample value will be, then coding only the difference between the actual sample value and the guess.  If that difference is small, then fewer bits are needed to code it.  And then entropy coding (like Huffman coding) can be used on the LPC difference data.  White noise that’s uniform pdf (essentially what comes out of a good random number generator) will not compress this.

                    But for bandlimited audio that has a meaningful predictable spectrum, you can maybe cut the required data to a third or a quarter.  So I dunno how else FLAC does it.  They might be bandsplitting like lossy algs do, and I know they separate the sound into independent frames, so all of the analysis and bit-allocation rules happen to a short snippet of audio with no regard to the adjacent snippets of audio.

                    There is Shannon Information Theory that sets a limit on how much you can losslessly compress something.  And Gerzon and Craven sorta turned it around to say how many dB S/N ratio you can squeeze into a binary data stream.

                    But FLAC should sound exactly like if you just got the .wav file of the original and played it back through the same hardware and sound system.  Once decoded, they should be exactly the same bits.

                  • March 24, 2023 at 4:45 pm #5569
                    Bob Katz

                      Bob O. noted that a lossy stream of a given piece of music sounded better to him than the high res lossless flac. I respond: That makes sense, actually. Since lossy hides a lot of flaws within its own distortions and defects. Distortion masks other distortion. Lossy (to my ears) at low bit rate as in typical streaming 64 to 128 kbps, softens the sound. So if there was distortion or a crappy recording, the lossy playback could hide it better! But the lossless flac would reveal all the distortion in the crappy recording in all its ugly glory 🙁

                      Next, Bob O asked:  “It just seems like most streamed music is pretty bad sounding. What can we do to encourage more engaging sounding recordings?”

                      I answer: It’s not just streamed music, it’s a large proportion of the entire collection of popular music is pretty bad sounding. I don’t know how we can encourage more engaging recordings, but I do know that by making loudness normalization universal in streaming, with similar targets, then there will be room for the more engaging recordings to survive and be played by all the listeners. That way they will be engaged by the more engaging recordings and may be catch on. So my answer is, loudness normalization is an enabler…. you can lead a horse to water but you can’t make him drink. But at least we can enable, lead the listener to the water, and I think that will help.

                  • March 19, 2023 at 10:05 pm #5526
                    James Johnston

                      FLAC uses, last I saw, an adaptive LPC system, which is not at all a bad choice, with the error signal integerized then compressed via information-theoretic approach to make it lossless.

                      The trick in FLAC (and any other lossless encoder) is to make the code give invariant results across a wide variety of platforms.

                      I think FLAC uses Arithmetic coding, but I could be wrong, it maybe LZW or a derivative. I knew the answer to this once.

                      As an aside, it is not hard to determine the entropy of a given signal when it is being predicted in given length blocks. The Spectral Flatness Measure provides this information. It is ‘1’ for a flat (ergo unpredictable, i.e. full entropy) signal, and is always in practice considerably smaller than ‘1’.

                      The SFM is calculated by taking the ratio of the geometric mean and arithmetic mean of the power spectrum.  The number you get is for absolutely PERFECT prediction, matched perfectly to that block of signal. Needless to say, that’s a bound you’ll never reach.

                      • March 24, 2023 at 5:06 pm #5571
                        James Johnston

                          Bob K, I have to disagree.  The things “lost” in an AAC stream (or MP3, I won’t address other methods) are not too likely to mitigate noise in an original, if anything, it’s more likely it will push the noise floor UP and make it more audible.  Remember the “throws stuff out” is actually adding noise to the original.

                          I have heard a misbegotten codec remove some background noise, but let me tell you, the piano fade into that missing noise was “quaint”, and that’s a euphemism.


                          This has to be the original provided to the FLAC (or other lossless) codec. There are many, they all have very close to exactly the same rate, and that’s because the mathematics is pretty obvious to signal processing types, and the entropy can be estimated to start with.

                          • March 25, 2023 at 9:56 am #5576
                            Bob Katz

                              I can’t seem to find my post that JJ disagrees with and I think I looked through the whole thread. Maybe it was in another thread where we discussed noise-shaped dither.

                              Anyway, I think he disagreed with only part of my post — regarding source noise and lossy coding. I do recall I mentioned that I don’t think a lossy codec will have a problem being fed from a noise-shaped dithered source. Then JJ mentioned that a lossy codec will, if anything, bring up a source noise floor.

                              So let me ask: JJ, in your opinion, do you think that a 16-bit noise shaped source could suffer in some way when lossy coded? We wouldn’t suddenly hear or notice the HF noise of the dithering? It couldn’t be that bad 🙁

                          • March 24, 2023 at 9:12 pm #5573
                            Alexey Lukin

                              FLAC uses Rice coding. It is less efficient than arithmetic, but faster and patent-free.

                          • March 20, 2023 at 9:34 pm #5528

                            Hay, JJ, BobK, BobO, have you heard about FSLAC?  http://www.ecodis.de/audio.htm#fslac

                            I was just fiddling around trying to find more tech info on FLAC (like exactly how they do the LPC and how they do the entropy coding and if there are other tricks in there) and discovered this FSLAC thing.  When things get noisier, it turns out that lossless coding gets less efficacious and that’s where FSLAC might cut a few perceptual corners so that the maximum bit rate is constrained.

                            Now, conceivably, someone with golden ears might be able to hear the difference between the original and the FSLAC, but it would be only at noisy frames of audio.

                          • March 20, 2023 at 10:01 pm #5529
                            Bob Olhsson

                              I never heard of it and “semi-lossless” sounds pointless to me.

                            • March 24, 2023 at 5:01 pm #5570
                              James Johnston

                                Semi-lossless makes some sense if you’ve got a rate maximum, it’s better than “breaking down”, and should be able to strictly reduce the bit depth of the signal when the rate max is hit.  Of course lossless is better, unless you simply can’t get it from here to there.


                              • March 25, 2023 at 2:46 pm #5577
                                Brian Peters

                                  I don’t understand why we care about lossy codecs anymore. With the advanced of our tech servicing the internet providers where they are stuffing an incredible amount of data channels down a wire or fiber using DOCSIS, soon to be DOCSIS 4.0. Our phones and computers easily decode these signals with an error rate of 1*10-9 per sample. I’d say that’s pretty good and that is with the extra baggage of forward error code correction. Audio is so tiny compared to HD video why not use the tech the video streams use! Quam256 up and down is going to happen within 2 years for Spectrum. All that is required is for the streaming library companies to set up with the internet providers.

                                  • March 26, 2023 at 12:07 am #5579

                                    It seems to me that the commodity prices such as internet bandwidth, MIPS and gigabytes on a computer, or even with real estate on silicon goes down as the supply goes up and up with Moore’s Law, that there never is really enough internet bandwidth, MIPS and gigabytes, or zillions of transistors on a chip.

                                    We always want more.  If you’re Spotify or whoever, terabits are dollars.

                                  • March 27, 2023 at 12:10 pm #5583
                                    Bob Katz

                                      For 2 channel at 48 khz/24 bit I fully agree with Brian. The bandwidth is there. Alex Kosiorek of Arizona Public Radio just streamed a concert in full fidelity on Sunday. So it’s happening now.

                                  • March 27, 2023 at 2:31 am #5581
                                    James Johnston

                                      Well, you know, it’s interesting. Back when I started working on coding, it was voice coding, and 16 kb/s was “way too much” for some applications. Things changed, transmission methods improved, and now we needed 9.6kb/s for speech.  Then 7.2 then 4.8 kb/s, even as the transmission rate improved and improved more.

                                      At the same time, the argument was “coding will cease being necessary”.  I kind of think that myself, but it’s been since 1976 and CODING IS STILL NECESSARY and some of the rates are LOWER than they were then. The price of transmission has dropped by so much (2000 for 300 bits/second modem, plus long distance charges) to what?  What does it even cost to send 300 bits/second? Is there anything within 5 orders of magnitude even still in existence?

                                      The same as memory. First processor I built required 32 “1×1024” memory chips.   They were blisteringly fast, 190 nanoseconds. Almost 5MHz.  Yeah. And they were, for the time, blistering fast.

                                      Now? Could anyone provide a 1k memory chip? 🙂

                                      But coded speech and music seem to be expanding. But I do wish it was all lossless coding now.

                                    • March 27, 2023 at 9:41 am #5582
                                      Bob Olhsson

                                        There is certainly a place for it with video streaming.

                                    You must be logged in to reply to this topic.