top | item 46591385

(no title)

pxndxx | 1 month ago

Sampling does not lose information below the Nyquist limit, but quantization does introduce errors that can't be fixed. And resampling at a different rate might introduce extra errors, like when you recompress a JPEG.

discuss

order

dietr1ch|1 month ago

I see I lose data on the [18kHz..) range, but at the same time as a male I'm not supposed to hear that past in my early 30s, sprinkle concerts on top and make it more like 16kHz :/

At least I don't have tinnitus.

Here's my test,

    ```fish
    set -l sample ~/Music/your_sample_song.flac  # NOTE: Maybe clip a 30s sample beforehand
    set -l borked /tmp/borked.flac # WARN: Will get overwritten (but more likely won't exist yet)

    cp -f $sample $borked

    for i in (seq 10)
        echo "$i: Resampling to 44.1kHz..."
        ffmpeg -i $borked -ar 44100 -y $borked.tmp.flac 2>/dev/null
        mv $borked.tmp.flac $borked

        echo "$i: Resampling to 48kHz..."
        ffmpeg -i /tmp/borked.flac -ar 48000 -y $borked.tmp.flac 2>/dev/null
        mv $borked.tmp.flac $borked
    end

    echo "Playing original $sample"
    ffplay -nodisp -autoexit $sample 2>/dev/null
    echo "Playing borked file $borked"
    ffplay -nodisp -autoexit $borked 2>/dev/null

    echo "Diffing..."
    set -l spec_config 's=2048x1024:start=0:stop=22000:scale=log:legend=1'
    ffmpeg -i $sample -lavfi showspectrumpic=$spec_config /tmp/sample.png -y 2>/dev/null
    ffmpeg -i $borked -lavfi showspectrumpic=$spec_config /tmp/borked.png -y 2>/dev/null

    echo "Spectrograms,"
    ls -l /tmp/*.spec.png
    ```

brudgers|1 month ago

In the audio world, quantization is usually discussed in terms of bit-depth rather than sample rate.

mort96|1 month ago

Yeah, they know and their comment reflects that knowledge. They're saying that if we had infinite bit depth, we could arbitrarily resample anything to anything as long as the sample rate is above the Nyquist frequency; however we don't have an infinite bit depth, we have a finite bit depth (i.e the samples are quantized), which limits the dynamic range (i.e introduces noise). This noise can compound when resampling.