Another Harmonic Distortion measurement/drawing tool.. for Linux & written in Perl

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Another Harmonic Distortion measurement/drawing tool.. for Linux & written in Perl

Subj. I made this script to easily perform measurements while sound interface card attached to Linux headless ARM board. It works from console, access card via alsa, requires alsa-utils, sox and gnuplot (to draw spectrums into gif files). Also it requires several additional modules to be installed into Perl with cpan: Audio::Wav, Math::FFT, Math::Trig, Math::Round.

Also it has feature - unlike most other similar software it outputs not only levels but also phases of first 3 harmonics, making possible to see different distortions kinds that are impossible to distinguish using power spectrum representation only. And difference between them really hearable - mostly due to coupling with non-linearity of acoustics. For example in attachements there're pics taken on test of emitter follower built using PNP (BD140) and NPN (BD139) transistors (other elements are same) - and clearly visible that even harmonics have opposite phasing, while almost same level.
 

Attachments

  • distortions_1000_npn.gif
    distortions_1000_npn.gif
    40.4 KB · Views: 376
  • distortions_2000_npn.gif
    distortions_2000_npn.gif
    46.7 KB · Views: 361
  • distortions_1000_pnp.gif
    distortions_1000_pnp.gif
    46 KB · Views: 343
  • distortions_2000_pnp.gif
    distortions_2000_pnp.gif
    40.4 KB · Views: 358
  • DistortionsAnalyzer.zip
    5.3 KB · Views: 67
Is it possible to show it as a secondary waveform under the primary
What do you mean secondary and primary? Distortions 'look' waveform shown schematically on spectrum, its useful cuz its not obvious how distortion products phases got from FFT actually 'look' on waveform.
However, there is simple experiment that can perform anyone. I attached zip with 2 scripts (they also require sox). makeharm2.sh script generates sequence of two kind of mixes interleaved. Each mix contains two sine waves: one of base frequency 1KHz and another one is smaller amplitude of 2KHz. The level of enmixed 2KHz can be specified from command line or defaulted to -30db and same for both mix kinds. But phase of that 2KHz is opposite in that mixes. And when that mixes played as interleaved sequence - its possible to easily hear the difference. My experiments shows that 2nd harmonic hears 'nicer' (less noticeable) when it phased so that waveform 'blunted' at the bottom (this corresponds to 180* by my analyzer) and shurpened at upper. But if upper waveform edge is blunted - then 2md harmonic heared more noticeable. Most interesting that at some level bottom-blunted waveform sounds more clear than actually clear sine waveform. I guess that it caused by opposite phasing with 2nd harmonic that caused by non-linearity of speakers/headphones. So if phase of 2nd harm is same as speakers - them sums, but when they're opposite - then they will subtract each other and actual resulted 'in-air waveform' can be even more clean than when electrical waveform feeded to speakers is less distorted. Whet exactly 2nd harm phase will be produced by some amp highly depends on its schematic, and simple follower can produce 2nd harmonic of opposite phased depending on selected transistor and mode.
There is also script makeharm3.sh that plays combination of same mixes but with 1Khz/3Khz frequencies, but the difference between its mixes is much less noticeable, probably due to my speakers/headphones much more linear by 3rd harmonic than by 2nd. But on high volume level difference is more noticeable and it seems to me that 3rd harmonic that sharpens waveform (on both ends - cuz its 3rd harmonic) sounds better than those that blunts waveform and this is quite logical due to mechanical reasons of speakers distortions. However almost all transistors amplifiers 3rd harmonic distortion product looks as waveform rounding that is same phased as speakers' distortions so they're summed together.
PS when experimenting make sure that both base (1K) and enmixed (2K/3K) frequencies are on the same band of multiband speaker, otherwise different components of signal will be player via different speaker drivers and phase can be altered much.
 

Attachments

  • makeharm.zip
    725 bytes · Views: 42
Last edited:
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.