[HOWTO] Sonograms of HiRes FLACs and DXDs & Resampler Test

OSS specific Linux discussion (x86/amd64)

Moderators: cesium, dev, kodachi, hannu

[HOWTO] Sonograms of HiRes FLACs and DXDs & Resampler Test

Postby igorzwx » Fri Oct 07, 2011 4:43 pm

1. Digging into "digital crap" with SoX

Penknife in the hands of a skilled surgeon is far better than a very sharp lancet.
Перочинный ножичек в руках искусного хирурга далеко лучше иного преострого ланцета.
Kozma Prutkov, Fruits of Reflection (1853-1854).
Козьма Прутков, Плоды раздумья: Мысли и афоризмы.


Free HiRes audio files (audiophile reference recordings) are available for download on the 2L website.
HiRes Download - test bench
http://www.2l.no/hires/index.html
To download audio please provide the username HD and the password 2L

We invite you to join us in this evaluation of future consumer delivery formats. FLAC is a lossless encoding of WAV-files derived directly from our production original used for the SACD and Pure Audio Blu-ray. All resolutions and encodings are derived from the same original DXD source files. Please send us an e-mail and share your experience on your practical experience with these file formats. Enjoy the music!

WARNING: These HiRes audio files are not supposed to be studied by the deaf, blind, and the stupid.
If ALSA/PulseAudio users do not hear the difference, they may discuss their problems on Ubuntu/Arch Linux forums.

There are two sorts of HiRes audio files available for download on the 2L website:
1. the original recordings,
2. the results of downsampling to different low quality formats, such as 24bit/96kHz and 24bit/192kHz

The DXD 24BIT 352.8kHz Waves are said to be recorded with PYRAMIX digital audio workstation http://www.lindberg.no/english/recording.htm
The original recordings, i.e. DXD Waves, are said to be converted to "digital crap" through the help of Weiss SARACON Sampling Rate Converter http://www.lindberg.no/english/editing.htm

First of all, we have to try a nice piece of anti-digital art:
W.A.Mozart: Violin concerto in D major (KV 218) - Allegro 9:24
Performers: Marianne Thorsen, TrondheimSolistene, Øyvind Gimse
From the album: MOZART (2L38SACD)

It might be obvious that Morten Lindberg selected special files for "evaluation of future consumer delivery formats".
Mozart's "Violin concerto in D major" proved to be the hardest nut to crack for any resampler. It is the first in the list, and there is a reason for this.
NOTE: The deaf, blind, and the stupid may not notice the difference.

Step 1: Download the files (2L-038-SACD):
[FLAC 24bit 96kHz] Mozart - Violin concerto in D major - Allegro 2L38_01_96kHz.flac
http://www.lindberg.no/hires/test/2L38_01_96kHz.flac
[WAV DXD 24bit 352.8kHz] Mozart - Violin concerto in D major (KV 218) - Allegro Stereo WAV DXD 24BIT 352.8kHz 2L38_01_DXD.wav
http://www.lindberg.no/hires/test/2L38_01_DXD.zip

Step 2: Rename them as follows:
01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.flac
01_2L_Mozart_24bit_352.8kHz.wav

Thus, you have the samples for "evaluation":
01_2L_Mozart_24bit_352.8kHz.wav is the original recording.
01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.flac seems to be an example of "future consumer delivery formats", a kind of "digital crap of the future".

Morten Lindberg tends to claim that downsampling produces "degeneration":
Comparing them in our studio we find only subtle differences from DXD (24BIT/352.8kHz) down to 192kHz and 96kHz. The obvious degeneration is from 96kHz down to 48kHz. http://morten.lindberg.no/19537/

It is not completely true, because "denaturation of sound" is already obvious on sonograms of 96kHz FLACs.
It is obvious on sonograms and it is audible, of course. Otherwise, 192kHz FLACs would not make much sense.
NOTE: The deaf, blind, and the stupid may not notice the difference.

Before we dig deeper into the nature of crap, a word about the proper tools. Of course, every scientific research requires certain tools to succeed, not just tools but relevant tools. There are, perhaps, exact scientific instruments, which might be utilized for the purpose. If they are missing, one may try what is available. There is a kind of penknife, with which to dig into the crap: SoX, "the Swiss Army knife of sound processing programs" http://sox.sourceforge.net/ Since SoX is free, "open source", and "cross-platform", it can be used for education purposes. Although, of course, it might obvious that the deaf lunatics are not able to learn anything, except for "religious knowledge", or Cargo Cult Science http://calteches.library.caltech.edu/51/2/CargoCult.pdf That is why they constantly fail to learn from experience. The story of PulseAudio proves this point.

Keep in mind that sonograms represent Fourier series rather then "frequencies". If huge distortions are noticeable on sonograms, it means that the particular resampler, such as Weiss SARACON Sampling Rate Converter, or other sort of "software crap" (softcrap), failed miserably.

The distortions of "digital crap" inside 96kHz FLACs are so huge that they can be easily detected with SoX sonograms.
Since the distortions had been produced by the softcrap resampler, they look similar to overtones, in the sense that they are somehow localized inside certain bands:
35kHz - 40kHz huge distortions
29kHz - 32kHz huge distortions
14kHz - 20kHz huge distortions

We have already observed a similar phenomenon with the Audacity/Nyquist resampler.
It might be natural to presume that there are big distortions below 14kHz, which might not be easily detected with SoX sonograms. There are likely to be big distortions, and there are obvious distortions below 14kHz. Although, of course, the deaf, blind, and the stupid may fail to notice them.

Step 3: Apply the secret esoteric command:
Code: Select all
$ sox -S "01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.flac" -n remix 2 spectrogram -S 00:05 -d 00:03.1 -c "Created by SoX  FILE: 01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.flac" -o "sonogram_01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.png" stat

This will produce a sonogram: sonogram_01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.png
The sonogram shows information only from the second (right) channel, and of 3.1 seconds of audio starting from 5 seconds in.

Step 4: Crop the picture with a magic command:
Code: Select all
$ convert -crop 944x576+0+15 *96kHz_Weiss_SARACON_SRC.png 48kHz_sonogram_01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.png

Code: Select all
$ pacman -Qo convert
/usr/bin/convert is owned by imagemagick 6.7.2.8-1

The audible range of frequencies is said to be 20Hz to 20kHz http://en.wikipedia.org/wiki/Hearing_range
You may want to zoom into this range to see the audible distortions of "genuine digital crap".

Step 5: Zoom into the audible range of frequencies [20Hz - 20kHz]:
Code: Select all
$ sox -S "01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.flac" -n remix 2 spectrogram -Y 1100 -S 00:05 -d 00:03.1 -c "Created by SoX  FILE: 01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.flac" -o "sonogram_01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC_2.png" stat

Code: Select all
$ convert -crop 944x576+0+527 *96kHz_Weiss_SARACON_SRC_2.png 24kHz_sonogram_01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC_2.png


Step 6: Build sonograms of the original DXD Wave with the following commands:
Code: Select all
$ sox -S "01_2L_Mozart_24bit_352.8kHz.wav" -n remix 2 spectrogram -Y 1100 -S 00:05 -d 00:03.1 -c "Created by SoX  FILE: 01_2L_Mozart_24bit_352.8kHz.wav" -o "sonogram_01_2L_Mozart_24bit_352.8kHz.png" stat

Code: Select all
$ convert -crop 944x576+0+527 *352.8kHz.png 90kHz_sonogram_01_2L_Mozart_24bit_352.8kHz.png

Code: Select all
$ sox -S "01_2L_Mozart_24bit_352.8kHz.wav" -n remix 2 spectrogram -Y 2050 -S 00:05 -d 00:03.1 -c "Created by SoX  FILE: 01_2L_Mozart_24bit_352.8kHz.wav" -o "sonogram_01_2L_Mozart_24bit_352.8kHz_2.png" stat

Code: Select all
$ convert -crop 944x576+0+1551 *352.8kHz_2.png 44kHz_sonogram_01_2L_Mozart_24bit_352.8kHz_2.png

Step 7: Compare sonograms of "digital crap" and the original DXD Wave.

CONCLUSION: Mozart's "Violin Concerto no. 4 in D major" (KV 218) can be used in a "blind test" with deaf lunatics. Although, of course, they are not intelligent enough to accept an idea that they need to undergo a medical examination before it is too late.

Mozart's "Violin Concerto no. 4 in D major" (KV 218) can also be utilized for:
1. testing resamplers (e.g. GRC3 SRC);
2. testing audio systems and Sennheiser headphones.
Sennheiser HD 598 Headphones
Technical Data:
Frequency response 12 – 38500 Hz
THD, total harmonic distortion < 0.1 % (1 kHz/100 dB SPL)
http://www.sennheiser.co.uk/uk/home_en. ... nes_504633

NOTE: If you want to zoom into a sonogram, you may need to increase its resolution.
The official SoX manual is here: http://sox.sourceforge.net/sox.html
ImageMagick Tutorial is here: http://xahlee.org/img/imagemagic.html

The sonograms are in the Attachment (updated):
Code: Select all
48kHz_sonogram_01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.png
24kHz_sonogram_01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC_2.png
44kHz_sonogram_01_2L_Mozart_24bit_352.8kHz_2.png
90kHz_sonogram_01_2L_Mozart_24bit_352.8kHz.png

NOTE: The deaf, blind, and the stupid may not need to study the sonograms.
Attachments
sonogram_01_2L_Mozart_24bit_96kHz_Weiss_SARACON_SRC.tar.gz
[updated] Resolution: 944x576 pixels
(625.66 KiB) Downloaded 652 times
90kHz_sonogram_01_2L_Mozart_24bit_352.8kHz.png.tar.gz
[updated] Resolution: 944x576 pixels
(303.53 KiB) Downloaded 644 times
44kHz_sonogram_01_2L_Mozart_24bit_352.8kHz_2.png.tar.gz
[updated] Resolution: 944x576 pixels
(314.68 KiB) Downloaded 711 times
Last edited by igorzwx on Fri Dec 02, 2011 3:51 pm, edited 17 times in total.
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] SONOGRAMS of HiRes FLACs and DXD Waves with SoX

Postby igorzwx » Sun Oct 09, 2011 3:41 am

2. Scientific study of "digital crap"

(156) Throwing pebbles into the water, look at the ripples they form on the surface, otherwise, such occupation becomes an idle pastime.
Бросая в воду камешки, смотри на круги, ими образуемые; иначе такое бросание будет пустою забавою.
Kozma Prutkov, Fruits of Reflection (1853-1854).
Козьма Прутков, Плоды раздумья: Мысли и афоризмы.

There is another sort of "digital crap" which is said to be better than any other sort of crap.
It is also available for download on the 2L website http://www.2l.no/hires/index.html

Since the crap is available, and it is free, anyone can study the quality of crap with sonograms, and decide for himself (or herself) which crap is better. Although, of course, the scientific study of crap is a privilege for the elect. The deaf, blind, stupid, and ignorant may better abstain from scientific studies, because such studies might be dangerous for health, if performed incorrectly. The users of ALSA/PulseAudio may discuss their problems on Ubuntu/Arch Linux forums.

Step 1: Download the best sort of crap from the 2L website:
[FLAC 24bit 192kHz] Mozart - Violin concerto in D major - Allegro 2L38_01_192kHz.flac
http://www.lindberg.no/hires/test/2L38_01_192kHz.flac
username: HD
password: 2L

Step 2: Rename it as follows:
01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC.flac

Step 3: Build sonograms of the best sort of crap:
Code: Select all
$ sox -S "01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC.flac" -n remix 2 spectrogram -S 00:05 -d 00:03.1 -c "Created by SoX  FILE: 01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC.flac" -o "sonogram_01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC.png" stat

Code: Select all
$ convert -crop 944x576+0+15 *192kHz_Weiss_SARACON_SRC.png 96kHz_sonogram_01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC.png

Code: Select all
$ sox -S "01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC.flac" -n remix 2 spectrogram -Y 1100 -S 00:05 -d 00:03.1 -c "Created by SoX  FILE: 01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC.flac" -o "sonogram_01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC_2.png" stat

Code: Select all
$ convert -crop 944x576+0+527 *192kHz_Weiss_SARACON_SRC_2.png 48kHz_sonogram_01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC_2.png

WARNING: These HiRes audio files are not supposed to be studied by the deaf, blind, and the stupid.
If ALSA/PulseAudio users do not hear the difference, they may discuss their problems on Ubuntu/Arch Linux forums.
Attachments
96kHz_sonogram_01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC.png.tar.gz
[updated] Resolution: 944x576 pixels
(295.43 KiB) Downloaded 622 times
48kHz_sonogram_01_2L_Mozart_24bit_192kHz_Weiss_SARACON_SRC_2.png.tar.gz
[updated] Resolution: 944x576 pixels
(313.69 KiB) Downloaded 827 times
Last edited by igorzwx on Tue Oct 11, 2011 7:05 pm, edited 2 times in total.
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] SONOGRAMS of HiRes FLACs and DXD Waves with SoX

Postby igorzwx » Sun Oct 09, 2011 11:52 pm

3. The CD format and the Stupid Theorem

Many things are incomprehensible to us not because our comprehension is weak, but because those things are not within the frames of our comprehension.
Многие вещи нам непонятны не потому, что наши понятия слабы; но потому, что сии вещи не входят в круг наших понятий.
Kozma Prutkov, Fruits of Reflection (1853-1854).
Козьма Прутков, Плоды раздумья: Мысли и афоризмы.


Mozart's "Violin concerto in D major" (KV 218) in CD format can be obtained in many different ways:
1. It can be purchased.
2. You may ask Morten Lindberg to upload the file you need for testing.
3. You can downsample the original DXD Wave with GRC3 SRC, or SoX, or else.

Step 1: Rename the file as follows:
01_2L_Mozart_16bit_44.1kHz_GRC3_SRC.flac

Step 2: Build the sonogram you need:
Code: Select all
$ sox -S "01_2L_Mozart_16bit_44.1kHz_GRC3_SRC.flac" -n remix 2 spectrogram -S 00:05 -d 00:03.1 -c "Created by SoX  FILE:  01_2L_Mozart_16bit_44.1kHz_GRC3_SRC.flac" -o "sonogram_01_2L_Mozart_16bit_44.1kHz_GRC3_SRC.png" stat

Code: Select all
$ convert -crop 944x576+0+15 *GRC3_SRC.png CD_sonogram_01_2L_Mozart_16bit_44.1kHz_GRC3_SRC.png

Notice that the width and the height of the sonogram are now divisible by 16 (Image Size: 944x576 pixels). This means that it can be easily zoomed with your preferable image viewer.
If you compare this sonogram with the sonogram of the original DXD Wave, and you may see that the Stupid Sampling Theorem is really true in an absolute sense http://en.wikipedia.org/wiki/Nyquist%E2 ... ng_theorem

Have you ever tried to resample images with Adobe Photoshop, or GIMP?

Do you really want to modify the image?
Resizing will cause drastic changes to the content of the image, and avoiding or minimizing the change should be of greatest importance. Perhaps just a slight Shave of the edges, or a more general Crop of the image will produce a better and more desirable outcome than a wholesale resize of the image. It generally will look better.
The resize operator has been very carefully designed to try to produce the best possible result for real world images. That is not to say you can't use it for diagrams, or line drawings, though for that type of image you may need to use some of the more advanced options we'll look at later. http://www.imagemagick.org/Usage/resize/#resize

Code: Select all
$ pacman -Qo convert
/usr/bin/convert is owned by imagemagick 6.7.2.8-1

Step 3: Resize the sonogram of the original DXD Wave with ImageMagick
Code: Select all
$ convert -resize 240x160 44kHz_sonogram_01_2L_Mozart_24bit_352.8kHz_2.png downsized_44kHz_sonogram_01_2L_Mozart_24bit_352.8kHz_2.png

This produces a downsized image (944x576 → 240x160).

Thus, we have:
1. downsized_44kHz_sonogram_01_2L_Mozart_24bit_352.8kHz_2.png (downsized sonogram of DXD Wave)
2. CD_sonogram_01_2L_Mozart_16bit_44.1kHz_GRC3_SRC.png (sonogram of CD format)

Now you can compare the downsized sonogram of the original DXD Wave with the sonogram of CD format.
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby keantoken » Tue Oct 11, 2011 1:11 am

If only the sonograms could be made with a logarithmic frequency axis, it would be more useful.

It is an interesting idea to use an image program to resample an audio file. But why don't image programs have FFT resampling capabilities?

- keantoken
keantoken
Member
 
Posts: 35
Joined: Fri Jul 08, 2011 2:54 am

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby igorzwx » Tue Oct 11, 2011 1:41 am

keantoken wrote:But why don't image programs have FFT resampling capabilities?


It might be an education problem, a lack of mathematical knowledge, perhaps.
In Germany, they have been trying to do something about this problem:
http://en.wikipedia.org/wiki/Programme_ ... Assessment
It seems to be a kind of ritual practice, which is believed to be effective.
The authorities should demonstrate to the public that they are doing something about problems.
Edwin L. Woollett - Maxima by Example
DETAILED EXAMPLES OF THE USE OF THE MAXIMA COMPUTER ALGEBRA SYSTEM
http://www.csulb.edu/~woollett/

Edwin L. (Ted) Woollett
Professor Emeritus, Physics & Astron., CSULB
Ph.D. - Kansas State Univ, 1965
Computational Physics

Chapter 11: Fast Fourier Transform Tools.
Chapter 11 and the software file qfft.mac have been revised and greatly simplified to allow use of the new simplified Maxima package fft.lisp, effective with Maxima ver. 5.19.0, August 2009. The latex code file is made available for the convenience of instructors who would like to incorporate parts of Ch. 11 in their class notes and handouts.
[PDF] Edwin L. Woollett - Maxima by Example - Ch.11. Fast Fourier Transform Tools
11.1 Examples of the Use of the Fast Fourier Transform Functions fft and inverse fft. We discuss the use of Maxima's fast Fourier transform package fft.lisp, which ... http://www.csulb.edu/~woollett/mbe11fft.pdf

Fourier Analysis (classic wave equations and corresponding graphs)
Fourier analysis is a fascinating activity. It deals with the essential properties of periodic waveforms of all kinds, and it can be used to find signals lost in apparently overwhelming noise. As just one example of its usefulness, if SETI (the Search for Extraterrestrial Intelligence) should ever detect an alien signal, that discovery will be made using Fourier analysis. http://www.arachnoid.com/maxima/fourier_analysis.html

Fast Fourier Transform – Acoustics of Music – Part 5
Welcome to Part 5 of our series Acoustics of Music. This article will describe the Fast Fourier Transform tool or the FFT Meter which is part of the Steinberg computer program called Wavelab v6.0. http://donrathjr.com/fast-fourier-transform/

Code: Select all
$ yaourt wxmaxima
1 extra/wxmaxima 11.08.0-1 [installed]
    A wxWidgets GUI for the computer algebra system Maxima
==> Enter n° of packages to be installed (ex: 1 2 3 or 1-3)
==> -------------------------------------------------------
==>

$ yaourt gnuplot
1 extra/gnuplot 4.4.3-1 [installed]
    Plotting package which outputs to X11, PostScript, PNG, GIF, and others
==> Enter n° of packages to be installed (ex: 1 2 3 or 1-3)
==> -------------------------------------------------------
==>
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby igorzwx » Sat Oct 15, 2011 12:13 am

4. The nature of crap

To understand the nature of "digital crap" we need to perform a "scientific experiment".
This can be done as follows:
1. create a very simple wave,
2. apply a very simple transformation to it,
3. study sonograms.

Step 1: Open Audacity and set "Project Rate (Hz)" to 96000kHz

Step 2: Audacity → Edit → Preferences → Quality → Default Sample Rate/Format → 96000kHz/24bit

Step 3: Audacity Menu -> Generate -> Silence (5 seconds are enough)

Step 4: Audacity Menu -> Effects -> Nyquist prompt

Type the command:
Code: Select all
(mult (hzosc 5000) 0.90)

or copy-and-paste it to Nyquist prompt (paste with Ctrl+V), and execute it.

This produces a sine wave of 5kHz.

Step 5: Export the result as 24bit 96kHz wave "5kHz_sine.wav".

Now, we are going to clip the sine wave of 5kHz.

Step 6: Mark the entire wave: Ctrl+A

Step 7: Audacity Menu -> Effects -> Nyquist prompt

Type the command:
Code: Select all
(clip s 0.89)

or copy-and-paste it to Nyquist prompt (paste with Ctrl+V), and execute it.

Step 8: Export the result as 24bit 96kHz wave "5kHz_sine-clipped.wav".

We can study the spectrum of the clipped wave with Audacity.

Step 9: Mark the entire wave: Ctrl+A

Step 10: Audacity Menu -> Analyze -> Plot Spectrum

Step 11: Change the "resolution" as follows:
Code: Select all
Size: 2048
Axis: Linear frequency

You will see odd overtones of 5kHz (5kHz, 15kHz, 25kHz, 35kHz, 45kHz) and some other frequncies above and below 5kHz, for example: 1kHz (see the screenshot). This means that, if a resampler clipped a 50kHz sine wave, distortions might be seen on sonograms around 10kHz. This may explain distortions produced by Weiss SARACON Sampling Rate Converter.

Step 12: Build sonograms of "5kHz_sine.wav" and "5kHz_sine-clipped.wav":
Code: Select all
$ sox -S "5kHz_sine.wav" -n spectrogram -c "Created by SoX  FILE: 5kHz_sine.wav" -o "sonogram_5kHz_sine.png" stat

Code: Select all
$ sox -S "5kHz_sine-clipped.wav" -n spectrogram -c "Created by SoX  FILE: 5kHz_sine-clipped.wav" -o "sonogram_5kHz_sine-clipped.png" stat


CONCLUSION: If a digital signal consists of many different frequencies, a transformation of it (such as clipping, resampling, and the like) can produce a lot of overtones and other "frequencies", which all together might be perceived as "digital noise". More exact resamplers produce less noise. If noise is "small", it can be filtered out. This is how resamplers work. This is how they produce "digital crap".

It might be stating the obvious, but the OSS4 SRC should clip certain frequencies simply because it is a resampler. This might be the reason why a standalone version of GRC3 SRC is not available for download. Otherwise, OSS4 users may study it and file bugs, if distortions are obvious on sonograms.

SRC Comparisons
http://src.infinitewave.ca/
Test of Sampling Rate Converters
http://src.infinitewave.ca/help.html
Attachments
sonogram_5kHz_sine-clipped.png.tar.gz
(11.78 KiB) Downloaded 621 times
sonogram_5kHz_sine.png.tar.gz
(7.57 KiB) Downloaded 623 times
Odd_overtones_of_5kHz_Screenshot.png.tar.gz
(28.84 KiB) Downloaded 614 times
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby igorzwx » Sun Oct 23, 2011 8:43 am

5. Наш ответ Чемберлену: audible distortions with libsamplerate (Secret Rabbit Code)

The Russian SRC test was designed by Dr. Alexey Lukin, Department of Computational Mathematics & Cybernetics of Moscow State University.
The results were published on the Canadian website of "digital crap producers" http://www.infinitewave.ca

SRC Comparisons [Test Design/Software: Alexey Lukin]
http://src.infinitewave.ca/
http://src.infinitewave.ca/help.html
http://src.infinitewave.ca/faq.html

It makes sense to read "Help" and "FAQ", although they might be incomprehensible for normal human beings.

We are invited to believe that the results of the test are not biased:
Are these results biased? I’ve heard that test designer Alexey Lukin is working at iZotope – is this why iZotope is showing (one of) the best results?
This web-site has been started without any participation of Alexey Lukin. It originally featured only 1 kHz tone spectra after conversion from 96 kHz to 44.1 kHz. Alexey Lukin joined the team later and proposed several new tests, such as a sine chirp and pre-post ringing test.
http://src.infinitewave.ca/faq.html


We can also create a very special test and make it "open source". Why not?

Requirements:
1. Test should be very simple and very effective.
2. It should be so simple that it could be easily reproduced by any Ubuntu user.
3. It should be an "open source" test, which can be performed with "open source" software.

NOTE: Our test is not "biased", because it is designed to kill all resamplers, except for "very scientific" ones.

Step 1: Install the "open source" tools, with which to perform the test:
Code: Select all
$ sudo pacman -S octave libsamplerate sox imagemagick

Step 2: Create the magic script "rabbit-shooter.sh" with a text editor:
Code: Select all
#! /usr/bin/octave -qf
#
# file: rabbit-shooter.sh
#
# a sample Octave program to generate odd overtones of 1kHz
#
# designed to demonstrate "audible distortions" produced by Secret Rabbit Code (aka libsamplerate)
# published on the OSS4 forum on 23 October 2011.
#
# Source of the "sine-wave" script: http://www.tty1.net/blog/2009-09-04-audio-with-gnu-octave_en.html
#
# How to use:
# 1. make the script "executable"
# 2. run from terminal: ./rabbit-shooter.sh
# 3. this will produce a special audio file: rabbit-shooter.wav  [32bit 96kHz]
#
# You do not need to listen to it, of course.
# If you are very intrigued, you can open it with Audacity and plot the spectrum: Audacity → Analyze → Plot Spectrum
# Do not forget to mark the entire wave: Ctrl+A
#
# NOTE: GNU Octave should be installed, of course. Otherwise, the magic script would not work.
# Arch Linux:  sudo pacman -S octave

bps = 32;      % bits per sample
sps = 96000;      % sample rate [samples/s]
freq = 1000;      % frequency of the tone [Hz]
nsecs = 5;      % number of seconds of the audio file
amplitude = 0.99;   % amplitude of the signal

nsamples = sps*nsecs;

time = linspace(0, nsecs, nsamples);
wave = amplitude*tanh(25*sin(time*2*pi*freq))';

% create the amplitude window (creates the fade in and fade out when multiplied with the sine wave)
a = b = floor(.3*nsamples);
window = [linspace(0,1,a), ones(1,nsamples-a-b), linspace(1,0,b)]';

wavwrite(wave.*window, sps, bps, 'rabbit-shooter.wav')

The magic script is in the Attachment. It is a very simple GNU Octave script with a few commands and math functions: tanh, sin and the like.

Step 3: Make the script "rabbit-shooter.sh" executable and run it from terminal:
Code: Select all
$ ./rabbit-shooter.sh

This will produce a special audio file: rabbit-shooter.wav (32bit/96kHz)
You do not need to listen to it, of course. If you are very intrigued, you can open it with Audacity and plot the spectrum:
1. mark the entire wave: Ctrl+A
2. Analyze → Plot Spectrum.

Step 4: Build a sonogram with SoX:
Code: Select all
$ sox -S "rabbit-shooter.wav" -n spectrogram -c "Created by SoX  FILE: rabbit-shooter.wav" -o "sonogram_rabbit-shooter.png" stat

Step 5: Zoom into the audible range of frequencies:
Code: Select all
$ sox -S "rabbit-shooter.wav" -n spectrogram -Y 1100 -d 00:02 -c "Created by SoX  OPTIONS: -Y 1100 -d 00:02  FILE: rabbit-shooter.wav" -o "sonogram_rabbit-shooter_Y_d2.png" stat

Code: Select all
$ convert -crop 944x576+0+527 *Y_d2.png 24kHz_sonogram_rabbit-shooter_Y_d2.png

Step 6: Convert the "rabbit-shooter.wav" to 44.1kHz with libsamplerate (Secret Rabbit Code)
Code: Select all
$ sndfile-resample -to 44100 -c 0 rabbit-shooter.wav rabbit-shooter_44.1kHz_libsamplerate.wav
Input File    : rabbit-shooter.wav
Sample Rate   : 96000
Input Frames  : 480000

SRC Ratio     : 0.459375
Converter     : Best Sinc Interpolator

Output file   : rabbit-shooter_44.1kHz_libsamplerate.wav
Sample Rate   : 44100

Output has clipped. Restarting conversion to prevent clipping.

Output Frames : 220499

Step 7: Build sonograms:
Code: Select all
$ sox -S "rabbit-shooter_44.1kHz_libsamplerate.wav" -n spectrogram -c "Created by SoX  FILE: rabbit-shooter_44.1kHz_libsamplerate.wav" -o "sonogram_rabbit-shooter_44.1kHz_libsamplerate.png" stat

Code: Select all
$ sox -S "rabbit-shooter_44.1kHz_libsamplerate.wav" -n spectrogram -d 00:02 -c "Created by SoX OPTIONS: -d 00:02  FILE: rabbit-shooter_44.1kHz_libsamplerate.wav" -o "sonogram_rabbit-shooter_44.1kHz_libsamplerate_d2.png" stat

If you compare the sonograms, you may notice obvious distortions produced by libsamplerate (Secret Rabbit Code) in the range: 20Hz - 7kHz.

Now you can see that the Stupid Sampling Theorem is really true in an absolute sense http://en.wikipedia.org/wiki/Nyquist%E2 ... ng_theorem

SoX SRC also produced distortions:
Code: Select all
$ sox --norm rabbit-shooter.wav rabbit-shooter_44.1kHz_SoX_SRC.wav rate 44100

Code: Select all
$ sox -S "rabbit-shooter_44.1kHz_SoX_SRC.wav" -n spectrogram -c "Created by SoX  FILE: rabbit-shooter_44.1kHz_SoX_SRC.wav" -o "sonogram_rabbit-shooter_44.1kHz_SoX_SRC.png" stat

Code: Select all
$ sox -S "rabbit-shooter_44.1kHz_SoX_SRC.wav" -n spectrogram -d 00:02 -c "Created by SoX OPTIONS: -d 00:02  FILE: rabbit-shooter_44.1kHz_SoX_SRC.wav" -o "sonogram_rabbit-shooter_44.1kHz_SoX_SRC_d2.png" stat


___________________-
EDIT:
WARNING: The sonograms are not supposed to be studied by the blind, stupid and ignorant.
If M$ Windows users do not see distortions on certain sonograms, they may need to visit doctors.
Attachments
sonograms_SoX_SRC.tar.gz
(169.68 KiB) Downloaded 623 times
sonograms.tar.gz
(284.06 KiB) Downloaded 626 times
rabbit-shooter.sh.tar.gz
(981 Bytes) Downloaded 614 times
Last edited by igorzwx on Mon Oct 24, 2011 8:11 am, edited 1 time in total.
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby Alexey Lukin » Mon Oct 24, 2011 7:07 am

Igor, I don't see any distortion in your spectrograms. Can you circle it or describe what you think the distortion is? Perhaps you just see some side lobes of the spectrum, which can be easily eliminated by using a more powerful weighting window during your spectrogram calculation.
Alexey Lukin
New Member
 
Posts: 2
Joined: Mon Oct 24, 2011 7:04 am

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby igorzwx » Mon Oct 24, 2011 7:26 am

Alexey Lukin wrote:Igor, I don't see any distortion in your spectrograms. Can you circle it or describe what you think the distortion is? Perhaps you just see some side lobes of the spectrum, which can be easily eliminated by using a more powerful weighting window during your spectrogram calculation.


Hi Alexey!

1. If you do not see, you may need to visit doctors.
2. If you pretend to be a demagogue, you may try to explain why SoX produces other spectrograms without distortions.
3. If you do not know what is "tanh", you may ask kids to explain.
4. If you want to learn Linux, you may try Arch LiveCD.

Perhaps, you might have failed to notice the warning on the first page.
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby Alexey Lukin » Mon Oct 24, 2011 8:14 am

My bad, didn't notice the warnings :)
Alexey Lukin
New Member
 
Posts: 2
Joined: Mon Oct 24, 2011 7:04 am

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby igorzwx » Tue Oct 25, 2011 12:05 am

How to plot graphs of mathematical functions with wxMaxima

Step 1: Install wxMaxima and GnuPlot
Code: Select all
$ sudo pacman -S wxmaxima gnuplot

Now you can plot a graph of a certain function:
Code: Select all
y = 0.99*tanh(25*sin(t*2*Pi*1000))   
Time interval = [0.0, 0.01 sec]

Step 2: Open wxMaxima and execute the magic command:
Code: Select all
plot2d([0.99*tanh(25*sin(t*2*%pi*1000))], [t,0.0,0.01], [y,-1,1], [plot_format, gnuplot], [gnuplot_term, png], [gnuplot_out_file, "~/Desktop/tanh_sin.png"])$

This will produce a picture: ~/Desktop/tanh_sin.png
If you are not blind and stupid, you may notice that GnuPlot failed to intepolate it correctly. To improve the quality of interpolation, you may need to increase resolution, that is, "sample rate" and "bit depth". The correct curve should be smooth, without "sharp corners", see: http://en.wikipedia.org/wiki/Smooth_function

The mathematical formula of the wave is defined. Therefore, the "exact" wave of 32bit/44.1kHz can be easily built with GNU Octave, or MATLAB. To build it with GNU Octave, you have to change the parameter "sps" (sample rate) in the magic script "rabbit-shooter.sh". The "exact" wave of 32bit/44.1kHz has "sharp corners", of course, because the sample rate (44.1KHz) is not sufficient to make it smooth. Therefore, if you build a sonogram of it with SoX, the result is a strange picture with "strange distortins". The sonograms of downsampled waves are much more "smooth", because the resamplers are not exact.

In short, the method works like "litmus test" http://en.wikipedia.org/wiki/Litmus The smallest deviations from the "exact wave" can be easily detected with SoX sonograms, because the slightest deviations are dramatically emphasized by certain "non-linear phenomena". The method works similar to the "strange attractor" http://en.wikipedia.org/wiki/Lorenz_attractor It is a kind of "no-linear magic", of course". It is a very precise method to measure the exactitude of resamplers. You can simply reduce (or increase) the "sharpness" of the mathematical formula, which defines the test wave, (by changing coefficients in the Octave script "rabbit-shooter.sh") and compare sonograms. The stupid and ignorant may try "powerful weighting windows" (or other sort of crap) instead. The M$ Windows users may preach their "scientific beliefs" on Windows forums.

To summarize:
It might be obvious that "linear logic" does not work with non-linear functions. The kids, who did not study math in the primary school, failed to notice this. Although, of course, they might be smart enough to pretend to be "scientists" in order to fool competitors on the market. The so-called "scientific knowledge" tends to be used to justify "closed source" tests and other deceptions. This is how the market works. It is virtually impossible to make profits, if you do not fool naive customers and competitors. If the "digital crap" is justified by the Stupid Sampling Theorem, it is "consumable" from the "scientific point of view":
The Nyquist–Shannon sampling theorem states that perfect reconstruction of a signal is possible when the sampling frequency is greater than twice the maximum frequency of the signal being sampled, or equivalently, when the Nyquist frequency (half the sample rate) exceeds the highest frequency of the signal being sampled. If lower sampling rates are used, the original signal's information may not be completely recoverable from the sampled signal.[2] For example, if a signal has an upper band limit of 100 Hz, a sampling frequency greater than 200 Hz will avoid aliasing and allow theoretically perfect reconstruction.
The full range of human hearing is between 20 Hz and 20 kHz.[3] The minimum sampling rate that satisfies the sampling theorem for this full bandwidth is 40 kHz. The 44.1 kHz sampling rate used for Compact Disc was chosen for this and other technical reasons. http://en.wikipedia.org/wiki/Sampling_r ... ng_theorem
Attachments
tanh_sin.png.tar.gz
(4.04 KiB) Downloaded 606 times
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby igorzwx » Wed Oct 26, 2011 10:43 pm

How to subtract two waves with SoX and measure the difference

Since the mathematical formula of the wave is defined, it is possible to measure the difference between the exact wave and the downsampled one in a very precise way.

It is not difficult to prove that distortions are audible, because the difference is really huge. It is so huge that it is sufficient to subtract two waves and build a sonogram of the difference. Since the difference is incredibly huge, we have to verify the method in some way. Otherwise, you may not believe your eyes, when you see the sonogram of the difference.

We can easily subtract two waves with SoX and measure the difference, the manual is here:
http://www.diyaudio.com/forums/pc-based ... ost1922646

However, we should also test the exactitude of subtraction to see whether SoX is doing it precisely or not. The test is very simple: the sum of a wave with its inversion should be equal to zero.

This means that we should also create the inverted wave. It is not difficult. All the waves can be created with two Octave scripts: "rabbit-shooter.sh" and "rabbit-shooter44.sh" (in the Attachment).

Step 1: Install the "open source" tools, with which to perform the test:
Code: Select all
$ sudo pacman -S octave libsamplerate sox


Step 2: Make the scripts "rabbit-shooter.sh" and "rabbit-shooter44.sh" executable and run them from terminal:
Code: Select all
$ ./rabbit-shooter.sh
$ ./rabbit-shooter44.sh

This will produce three audio files:
rabbit-shooter.wav [32bit 96kHz]
rabbit-shooter_44.1kHz_exact.wav [32bit 44.1kHz]
rabbit-shooter_44.1kHz_exact_inverted.wav [32bit 44.1kHz]

You do not need to listen to them, of course. If you are very intrigued, you can open them with Audacity and plot the spectrum:
1. mark the entire wave: Ctrl+A
2. Analyze → Plot Spectrum.

It makes sense to build sonograms of all waves and study the output on terminal to ensure that the test is performed correctly.

Step 3: Build sonograms with SoX:
Code: Select all
$ sox -S "rabbit-shooter.wav" -n spectrogram -c "Created by SoX  FILE: rabbit-shooter.wav" -o "sonogram_rabbit-shooter_96kHz_exact.png" stat
$ sox -S "rabbit-shooter_44.1kHz_exact.wav" -n spectrogram -c "Created by SoX  FILE: rabbit-shooter_44.1kHz_exact.wav" -o "sonogram_rabbit-shooter_44.1kHz_exact.png" stat


Step 4: Convert the "rabbit-shooter.wav" to 44.1kHz with libsamplerate (Secret Rabbit Code)
Code: Select all
$ sndfile-resample -to 44100 -c 0 rabbit-shooter.wav rabbit-shooter_44.1kHz_libsamplerate.wav
Input File    : rabbit-shooter.wav
Sample Rate   : 96000
Input Frames  : 480000

SRC Ratio     : 0.459375
Converter     : Best Sinc Interpolator

Output file   : rabbit-shooter_44.1kHz_libsamplerate.wav
Sample Rate   : 44100

Output has clipped. Restarting conversion to prevent clipping.

Output Frames : 220499


Step 5: Build a sonogram of it:
Code: Select all
$ sox -S "rabbit-shooter_44.1kHz_libsamplerate.wav" -n spectrogram -c "Created by SoX  FILE: rabbit-shooter_44.1kHz_libsamplerate.wav" -o "sonogram_rabbit-shooter_44.1kHz_libsamplerate.png" stat


Step 6: Subtraction Test:
Code: Select all
$ sox -V -m rabbit-shooter_44.1kHz_exact.wav rabbit-shooter_44.1kHz_exact_inverted.wav -n spectrogram -c "Created by SoX: Subtraction Test" -o "sonogram_Subtraction_Test.png" stat
sox: SoX v14.3.2
sox INFO formats: detected file format type `wav'
sox INFO formats: detected file format type `wav'

Input File     : 'rabbit-shooter_44.1kHz_exact.wav'
Channels       : 1
Sample Rate    : 44100
Precision      : 32-bit
Duration       : 00:00:05.00 = 220500 samples = 375 CDDA sectors
File Size      : 882k
Bit Rate       : 1.41M
Sample Encoding: 32-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no
Level adjust   : 0.5 (linear gain)


Input File     : 'rabbit-shooter_44.1kHz_exact_inverted.wav'
Channels       : 1
Sample Rate    : 44100
Precision      : 32-bit
Duration       : 00:00:05.00 = 220500 samples = 375 CDDA sectors
File Size      : 882k
Bit Rate       : 1.41M
Sample Encoding: 32-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no
Level adjust   : 0.5 (linear gain)


Output File    : '' (null)
Channels       : 1
Sample Rate    : 44100
Precision      : 32-bit
Duration       : 00:00:05.00 = 220500 samples = 375 CDDA sectors

sox INFO spectrogram: actual pixels/s = 160.364
sox INFO sox: effects chain: input      44100Hz 1 channels
sox INFO sox: effects chain: spectrogram 44100Hz 1 channels
sox INFO sox: effects chain: stat       44100Hz 1 channels
sox INFO sox: effects chain: output     44100Hz 1 channels
sox INFO spectrogram: PNG truncated at 4.98866 seconds
sox INFO spectrogram: PNG truncated at 4.98866 seconds
Samples read:            220500
Length (seconds):      5.000000
Scaled by:         2147483647.0
Maximum amplitude:     0.000000
Minimum amplitude:     0.000000
Midline amplitude:     0.000000
Mean    norm:          0.000000
Mean    amplitude:     0.000000
RMS     amplitude:     0.000000
Maximum delta:         0.000000
Minimum delta:         0.000000
Mean    delta:         0.000000
RMS     delta:         0.000000
Rough   frequency:  -2147483648

The result is zero, and the sonogram is completely black. This means that SoX is exact enough to perform correct subtraction.

Step 6: Build the sonogram of the difference between the exact wave and the downsampled one (libsamplerate):
Code: Select all
$ sox -V -m rabbit-shooter_44.1kHz_exact_inverted.wav rabbit-shooter_44.1kHz_libsamplerate.wav -n spectrogram -c "Created by SoX: Difference between the exact wave and the downsampled one (libsamplerate)" -o "sonogram_Difference.png" stat
sox: SoX v14.3.2
sox INFO formats: detected file format type `wav'
sox INFO formats: detected file format type `wav'

Input File     : 'rabbit-shooter_44.1kHz_exact_inverted.wav'
Channels       : 1
Sample Rate    : 44100
Precision      : 32-bit
Duration       : 00:00:05.00 = 220500 samples = 375 CDDA sectors
File Size      : 882k
Bit Rate       : 1.41M
Sample Encoding: 32-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no
Level adjust   : 0.5 (linear gain)


Input File     : 'rabbit-shooter_44.1kHz_libsamplerate.wav'
Channels       : 1
Sample Rate    : 44100
Precision      : 32-bit
Duration       : 00:00:05.00 = 220499 samples = 374.998 CDDA sectors
File Size      : 882k
Bit Rate       : 1.41M
Sample Encoding: 32-bit Signed Integer PCM
Endian Type    : little
Reverse Nibbles: no
Reverse Bits   : no
Level adjust   : 0.5 (linear gain)


Output File    : '' (null)
Channels       : 1
Sample Rate    : 44100
Precision      : 32-bit
Duration       : 00:00:05.00 = 220500 samples = 375 CDDA sectors

sox INFO spectrogram: actual pixels/s = 160.364
sox INFO sox: effects chain: input      44100Hz 1 channels
sox INFO sox: effects chain: spectrogram 44100Hz 1 channels
sox INFO sox: effects chain: stat       44100Hz 1 channels
sox INFO sox: effects chain: output     44100Hz 1 channels
sox INFO spectrogram: PNG truncated at 4.98866 seconds
sox INFO spectrogram: PNG truncated at 4.98866 seconds
Samples read:            220500
Length (seconds):      5.000000
Scaled by:         2147483647.0
Maximum amplitude:     0.458115
Minimum amplitude:    -0.457321
Midline amplitude:     0.000397
Mean    norm:          0.041584
Mean    amplitude:    -0.000000
RMS     amplitude:     0.060595
Maximum delta:         0.452702
Minimum delta:         0.000000
Mean    delta:         0.029221
RMS     delta:         0.066596
Rough   frequency:         7713
Volume adjustment:        2.183

When you see the sonogram of the difference, you may not believe your eyes.

It is not difficult to verify the test with Audacity. You can simply open waves with Audacity and zoom into them to see the shape of the waves. The shape of the exact wave is similar to that which was built with wxMaxima and GnuPlot. The shape of the downsampled wave looks very strange, it seems to be a kind of "genuine crap" (the screenshot is in the Attachment). You may try to imagine what kind of "music" of "very advanced quality" can be produced with ALSA and Audacity (it has libsamplerate inside) http://wiki.audacityteam.org/index.php?title=Resample It might be something very different from that of Weiss SARACON SRC. It seems that ALSA "musicians" are really deaf to a certain extent. In any case, they may surely need to visit doctors before it is too late:
http://www.sennheiser.com/sennheiser/ho ... ing_living
http://video.about.com/deafness/Hearing-Test.htm

CONCLUSIONS:
1. The downsampled wave is severely distorted. That is why the difference is so huge.
2. The perfect reconstruction of the signal, which was promised by the Stupid Sampling Theorem, failed to happen (as usual) http://en.wikipedia.org/wiki/Sampling_r ... ng_theorem
3. This means that audio engineers must keep trying to improve their resamplers just like our brothers in Vanuatu must keep trying to receive the promised Cargo http://www.youtube.com/watch?v=qmlYe2KS0-Y

Alexey Lukin wrote:Igor, I don't see any distortion in your spectrograms. Can you circle it or describe what you think the distortion is? Perhaps you just see some side lobes of the spectrum, which can be easily eliminated by using a more powerful weighting window during your spectrogram calculation.

If someone does not see any distortion in the sonograms, he may urgently need a medical examination. It is very probable that "powerful weighting windows", iZotope and other M$ Windows software are dangerous for health. This is how the market works. If you want to sell a software product - such as a screen reader for the blind - you have to create a market for it http://en.wikipedia.org/wiki/Screen_reader If you are going to create something, you have to destroy something else. It is a proverbial truth that creation without destruction is impossible.

The sonograms and the scripts are in the Attachment.
WARNING: The sonograms are not supposed to be studied by the blind, stupid and ignorant.
If M$ Windows users fail to see or understand something, they may discuss their problems on Windows forums.
Attachments
wxMaxima_plot_and_Audacity_screenshots_distorted_wave_shape.tar.gz
(96.61 KiB) Downloaded 648 times
sonograms_screenshot.tar.gz
(702.9 KiB) Downloaded 638 times
rabbit-shooter_scripts.tar.gz
(1.13 KiB) Downloaded 772 times
Last edited by igorzwx on Mon Oct 31, 2011 4:35 pm, edited 1 time in total.
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby igorzwx » Sun Oct 30, 2011 12:34 pm

To avoid confusion, it might be necessary to note that the Stupid Nyquist–Shannon sampling theorem has nothing to do with mathematics. It was originally designed as a calculated deception (gezielte Tauschung) to fool the stupid. If you have tried to read handbooks on Mathematical Analysis, you might have noticed that mathematical theorems have "necessary and satisfactory conditions", which are clearly defined. If the conditions are not satisfied, mathematical theorems do not apply. The conditions of mathematical theorems are mathematical constructions: formulas, equations and the like. They are not material objects of the real physical world. If the conditions of a particular theorem can never be satisfied in terms of mathematics, this theorem belongs to theology and religion (or magic), it is not a mathematical theorem.

The Stupid Nyquist–Shannon sampling theorem is a perfect example of Cargo Cult Science. That is why the promised Cargo (that is, "perfect reconstruction of a signal") constantly fails to arrive.
In the South Seas there is a cargo cult of people. During the war they saw airplanes land with lots of good materials, and they want the same thing to happen now. So they've arranged to imitate things like runways, to put fires along the sides of the runways, to make a wooden hut for a man to sit in, with two wooden pieces on his head like headphones and bars of bamboo sticking out like antennas – he's the controller – and they wait for the airplanes to land. They're doing everything right. The form is perfect. It looks exactly the way it looked before. But it doesn't work. No airplanes land. So I call these things cargo cult science, because they follow all the apparent precepts and forms of scientific investigation, but
they're missing something essential, because the planes don't land.
Richard Feynman, Cargo Cult Science (1974).
http://www.lhup.edu/~DSIMANEK/cargocul.htm

CONCLUSION: The so-called "audio engineers" invariably fail to receive the much desired Cargo, because "they are missing something essential". To be effective, the magic rituals of Cargo Cult Science must be performed correctly. Otherwise, the promised Cargo may never arrive. A slightest mistake in magic rituals may render them ineffective.
Magic has a twofold part to play. First it overcomes ignorance and impotence. When a person wants something urgently he takes all the practical steps open to him. If, notwithstanding, the goal is still out of reach, he falls back on magic to bridge the gap.
Ian Hogbin, The Island of Menstruating Men, 1970.

The "closed source" software is not a big problem. The real problem is "ignorance and impotence". The only solution to it is a powerful magic.
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby igorzwx » Tue Nov 01, 2011 11:51 am

The true secret of Cargo
When a European attempts to explain to a Kanaka the 'truth about cargo' he is merely explaining to himself how he thinks European goods are made; and the Kanaka is satisfied that the European has a special technique whereby he gains access to cargo...
The more administrative officers tried to explain to Yali the 'truth about cargo' the more he would feel... that white men had a 'secret' which they were holding back from Kanakas.
Kenelm Burridge, Mambu (1960).


It might be obvious that GnuPlot interpolated the wave, tanh(25*sin(a*t)), as precisely as the resolution permits, this is, with maximum exactitude, but libsamplerate and other resamplers interpolated it with huge distortions. This means that those resamplers have been created by the ignorant.

tanh(25sin(at)) is always a smooth function without "sharp corners" http://en.wikipedia.org/wiki/Smooth_function
However, this smooth function becomes a square wave, when the resolution is not sufficient http://en.wikipedia.org/wiki/Square_wave
The problem is that square waves have singularities of the same sort as the Heaviside step function
http://en.wikipedia.org/wiki/Heaviside_step_function
http://en.wikipedia.org/wiki/Square_wav ... efinitions

Since 44.1kHz sample rate is not sufficient to preserve the "smoothness" of certain signals, the stupid resamples go astray and produce huge distortions. To predict such distortions, one may need a mathematical knowledge at the level of the primary school. In our day, many kids have digital photo cameras. They might have already learned, perhaps, from their own experience that low resolutions inevitably cause distortions. Do not forget, however, that Cargo cultists constantly fail to learn from experience, simply because any empirical truth tends to be refused, if it contradicts the Cargo Myth and other beliefs.

Truth does depend on geography, especially mathematical truth. What is true in America is not necessarily true in Russia, and other way round. That is why Grigori Perelman tends to ignore the International Mathematical Union together with their prizes, medals, and other ritual symbols and ceremonial performances, which have been designed to imitate "exact science" http://en.wikipedia.org/wiki/Grigori_Perelman The International Mathematical Union is a social institution first of all. It must have, therefore, certain ritual symbols, magic ceremonies and other secular rites, which justify its existence as a Church of Exact Science, or, perhaps, more precisely, a Church of Exact Cargo Cult Science. The Clay Millennium Prize is a US$1 million prize for a correct solution to any of the Millennium Prize Problems. These problems were said to be the most important mathematical problems http://en.wikipedia.org/wiki/Millennium_Prize_Problems We are invited to believe that these problems are really very important, because the prize is so high. However, since the US currency has already been essentially devalued by inflation, the "impersonal market forces" may fail to establish "international mathematical truths". The validity of mathematical truths apparently depends on the efficacy of the "invisible market forces" and "exchange rates" http://en.wikipedia.org/wiki/Exchange_rate This might be the reason why mathematics became as exact as economics (in this sense). If you want your medals and awards to be accepted, you have to persuade others that you are not ignorant Cargo cultists. Otherwise, sensible people may refuse to participate in your ritual performances, such as "scientific congresses", "congregation meetings" and the like. If you were awarded a medal for "prominent lunatics", you would decline to accept the award. Right? To appear at the international congress of "Exact Cargo Cult Science" is to accept the title of "Cargo Cult Scientist". That is why Grigori Perelman refused the "highest honor in mathematics" from the self-proclaimed "mathematical community". In Anthropological terms, Grigori committed a symbolic action, that is, the action which has a "symbolic meaning". This action was designed for the purpose. The symbolic meaning is rather obvious. Think of "Jesus Christ and the money changers" http://en.wikipedia.org/wiki/Cleansing_of_the_Temple The very idea that mathematical truth can be verified in terms of money is not likely to be acceptable for a Russian mathematician. If money is now a symbol of "scientific truth", this symbol has to be devalued. Grigori deliberately desacrificed certain "ritual symbols and symbolic ceremonies", largely because, perhaps, he believed that mathematics is not a religion, or theology. Whether it was a candid symbolic action of a naive idealist or not, Grigori Perelman did refuse the honor from men of questionable honor, thereby earning the true and lasting honor of the scientific community. http://www.nytimes.com/2006/08/22/scien ... -math.html

CONCLUSION: Since mathematical truth depends on geography and "exchange rates", you have to think for yourself instead of relying on "stupid theorems" of Cargo Cult Science. If you want to achieve "analogue qualities" you have to use extremely high resolution and GnuPlot (instead of stupid resamplers). Downsampling can never be exact, it always means a reduction in sound quality. Downsampling is a kind of lossy compression, it always means a loss in sound quality. The result is similar to that of Mp3 compression http://en.wikipedia.org/wiki/Lossy_compression Downsampling with a stupid resampler, such as libsamplerate, means a dramatic loss in sound quality, although, of course, ALSA/PulseAudio users may not hear the difference. Those, who can hear the difference, tend to say something like this:
The obvious degeneration is from 96kHz down to 48kHz.
http://morten.lindberg.no/19537/

The "very scientific resampler", which can do the work perfectly, is not yet ready for use, although, of course, there is an imperfect one, which can do the work much better than anti-scientific ones.
Digital eXtreme Definition is a professional audio format that brings "analogue" qualities in 32 bit floating point at 352.8 kHz. DXD preserves 11.2896 Mbit/s (4 times the data of DSD). http://www.2l.no/hires/index.html

If a wave is recorded at 64bit/5000000kHz, a kind of "linear interpolation" might be sufficient to achieve "analogue qualities".
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm

Re: [HowTo] Sonograms of HiRes FLACs and DXD Waves [updated]

Postby igorzwx » Fri Nov 11, 2011 2:55 pm

The Russian "exact" resampler and the Gibbs phenomenon
If the fool would persist in his folly he would become wise.
William Blake.

IGNORANCE IS STRENGTH.
George Orwell, 1984.

The stupid libsamplerate fails with the square wave, and it fails dramatically, simply because it is anti-scientific. It is a kind of "genuine crap", which can only be created by absolutely ignorant Linux developers. That is why it produces huge distortions. The absolute ignorance is the ultimate freedom of thought, especially, if it is "open source" ignorance. It is the freedom to think how you want, it is intellectual liberty without any restrictions. This might be the reason why libsamplerate was implemented in ALSA, Audacity and other "open source" software. This is the obvious proof that "open source" developers are absolutely ignorant of mathematics. Ignorance and only ignorance liberates, and "open source" ignorance liberates absolutely. The "open source" Cargo cult does produce the ultimate intellectual freedom (in this sense). The story of PulseAudio proves this point.

The ALSA "musicians" seem to be perfectly content with libsamplerate largely because, perhaps, the ability to hear sound tends to deteriorate with age http://en.wikipedia.org/wiki/Sound
http://www.sennheiser.com/sennheiser/ho ... ing_living

Notice that the original wave, tanh(25sin(at)), is not a square wave. It is a perfectly smooth function without "sharp corners" and "discontinuities" http://en.wikipedia.org/wiki/Smooth_function It has, of course, a Taylor series, and its Fourier series can be easily derived from its Taylor series through the help of Maxima or Maple. However, this smooth function becomes a square wave, when the resolution is not sufficient . It becomes a square wave with discontinuities simply because the sample rate 44.1kHz is too small. That is why the Gibbs phenomenon occurs http://en.wikipedia.org/wiki/Gibbs_phenomenon

The square wave does not have a Taylor series, because it has discontinuities. It has a Fourier series which does not converge because of the same discontinuities. It is the failure of this particular Fourier series to converge that causes the Gibbs phenomenon. The anti-scientific algorithm of the stupid libsamplerate fails to converge for the same reason. It is the dramatic failure of the stupid libsamplerate that produces huge distortions. All other anti-scientific resamplers, which are based on the Stupid Nyquist–Shannon sampling theorem, are likely to demonstrate similar failures with square waves. It might be interesting to test OSS4 resamplers to see how stupid they are. The most stupid resampler might be that of iZotope.

It is not difficult to explain this phenomenon in ordinary human language. It is really very simple. No special knowledge is required. Imagine a series of smooth functions which converges to a certain function. If it converges in a normal sense (for example: the maximum difference tends to zero; this is actually what you want), the result should be a smooth function, or, at least, a continuous function (it depends on how you define the "norm"). This means that a series of smooth functions cannot converge (in a normal sense) to a discontinuous function. That is why the Gibbs phenomenon occurs, when you attempt to approximate a square wave with Fourier series. If you are trying to approximate square waves by anti-scientific methods of Cargo Cult Science (through the help of libsamplerate or other crap), the result is likely to be a dramatic failure.

Notice that discontinuities are inevitable, because digital signals are discreet signals by their very nature http://en.wikipedia.org/wiki/Discrete_signal There are scientific methods to deal with discreet signals. They have not been implemented in "open source" software simply because the "open source" developers are not intelligent enough to understand any scientific methods. They firmly believe in the efficacy of anti-scientific methods, and, therefore, such methods have been, in fact, implemented in "open source" software. The reason is obvious. Any crap is believed to be "good", if it is "open source". This explains why PulseAudio has been enforced in major Linux distros. They still believe that PulseAudio might be somehow improved, because it is "open source". They are not able to learn from experience, because "they are missing something essential". The ability to learn from experience implies a certain discipline of the mind, but any discipline means a restriction on freedom. You cannot permit yourself to indulge in utopian dreams, if you are going to learn from experience. The study of scientific methods also requires a certain discipline of the mind. If it is missing, the study of scientific books does not make much sense. Such discipline of the mind cannot be learned by reading books. It does require a very special education and training under the supervision of gurus. It might be stating the obvious, but any discipline of the mind is not compatible with the ultimate intellectual liberty and the "open source" Cargo cult ideology in general.

The Russian "exact" resampler, pcm_conv v.1.0.3.8, is quasi-scientific, and, therefore, it demonstrates a kind of Gibbs phenomenon with the same square wave. The screenshot is in the Attachment. You can compare it with pictures in Wikipedia http://en.wikipedia.org/wiki/Gibbs_phenomenon
Functional approximation of square wave using 5 harmonics http://en.wikipedia.org/wiki/File:Gibbs ... non_10.svg
Functional approximation of square wave using 25 harmonics http://en.wikipedia.org/wiki/File:Gibbs ... non_50.svg
http://en.wikipedia.org/wiki/Gibbs_phenomenon

The very old version of the Russian resampler, pcm_conv, is likely to demonstrate similar phenomena with square waves. It is still available for download: viewtopic.php?f=3&t=3543&start=45#p15974
http://en.wikipedia.org/wiki/Gibbs_phenomenon
In practice, the difficulties associated with the Gibbs phenomenon can be ameliorated by using a smoother method of Fourier series summation, such as Fejér summation or Riesz summation, or by using sigma-approximation. Using a wavelet transform with Haar basis functions, the Gibbs phenomenon does not occur..
...In signal processing, the Gibbs phenomenon is undesirable because it causes artifacts, namely clipping from the overshoot and undershoot, and ringing artifacts from the oscillations. In the case of low-pass filtering, these can be reduced or eliminated by using different low-pass filters.
In MRI, the Gibbs phenomenon causes artifacts in the presence of adjacent regions of markedly differing signal intensity. This is most commonly encountered in spinal MR imaging, where the Gibbs phenomenon may simulate the appearance of syringomyelia.

In short, the Russian resampler might be improved, but this may require some mathematical knowledge at the level of the first semester of math in a Russian university. The only problem is that "audio engineers" cannot consume this sort of knowledge, simply because they firmly believe in the truth of the Stupid Nyquist–Shannon sampling theorem and other anti-scientific theories.

CONCLUSION: Petrov's resampler is not exact. It does not produce huge distortions, but the distortions are audible (the sonogram is in the Attachment). Since the Linux users are not likely to be able to hear the difference, they may not notice such distortions. In any case, Petrov's resampler is much better than the stupid libsamplerate and other anti-scientific resamplers. The true audiophiles, however, may not agree to listen to "digital crap" of any sort, because it causes the irreversible deterioration of hearing capacity. This does not contradict common sense. On the contrary, it follows from common sense logically. If you drink vodka every day, you will never become a true wine connoisseur, because you will never be able to notice the difference. This should be obvious. The victims of psychoacoustic experiments will never be able to hear the difference, because such experiments cause permanent hearing impairment.
http://en.wikipedia.org/wiki/Psychoacoustics
http://www.sennheiser.com/sennheiser/ho ... ing_living

[PDF] Edwin L. Woollett - Maxima by Example - Ch.11. Fast Fourier Transform Tools
Page 10: 11.1.3 Example 3: FFT Spectrum of a Rectangular Wave
http://www.csulb.edu/~woollett/mbe11fft.pdf

Gibbs Phenomenon – from Wolfram MathWorld
The Gibbs phenomenon is an overshoot (or "ringing") of Fourier series and other eigenfunction series occurring at simple discontinuities. It can be reduced with the Lanczos sigma factor. The phenomenon is illustrated above in the Fourier series of a square wave.
http://mathworld.wolfram.com/GibbsPhenomenon.html
http://mathworld.wolfram.com/FourierSer ... eWave.html
http://mathworld.wolfram.com/LanczosSigmaFactor.html

Gibbs Phenomena for 1D Fourier Series - Wolfram Demonstrations Project
http://www.demonstrations.wolfram.com/G ... ierSeries/
Gibbs phenomenon
http://www.absoluteastronomy.com/topics ... phenomenon

The test was invented in the 19th century http://en.wikipedia.org/wiki/Gibbs_phenomenon You may find it in many handbooks. It is a kind of "esoteric secret", of course. The victims of psychoacoustic experiments are not supposed to be informed. Otherwise, they may not agree to participate in such experiments. The ignorance of the participants is a necessary precondition for any Cargo cult
http://www.youtube.com/watch?v=yvfAtIJbatg
http://www.lhup.edu/~DSIMANEK/cargocul.htm
http://www.telegraph.co.uk/news/newstop ... uinea.html
Cargo cults: Are you a member?
If you are a computer programmer, a faithful church goer, or a real estate developer, a lot of your practice may be based on sheer nonsense, and you may not know it. You may have fallen prey to a Cargo Cult... Cargo Cult mentality is insidious, often invisible and extremely difficult to detect. How much of your life, your beliefs, your work, your practices are the result of the Cargo Cult phenomenon? Think about it. http://isthereanybodyoutthr.com/cargo-c ... -a-member/

Interpolation is doomed to failure simply because it is impossible to produce an exact information from the absence of information. It follows that upsampling is much more problematic than downsampling. You do not need to be an expert in mathematics to understand that the Nyquist-Shannon sampling theorem is a Cargo cult mythology. An ordinary common sense should be sufficient to distinguish scientific truth from complete nonsense. It is not surprising that downsampling can produce audible distortions. You may try to imagine what kind of distortions can be produced by further upsampling of "digital crap". It is supposed to be converted to an "analogue signal" by your soundcard or DAC. Right? This kind of conversion means upsampling to an infinite sample rate. Are you going to believe that "digital crap" can be converted to "genuine sound" by invisible magic forces?
Attachments
sonogram_rabbit-shooter_44.1kHz_Petrov.png.tar.gz
audible distortions produced by Petrov's resampler
(223.08 KiB) Downloaded 628 times
Audacity_rabbit-shooter_44.1kHz_Petrov.png.tar.gz
the distorted wave shape produced by Petrov's resampler
(42.87 KiB) Downloaded 584 times
igorzwx
Known Member
 
Posts: 1000
Joined: Sun Jun 28, 2009 9:31 pm


Return to Linux

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron