endolith / waveform-analysis

Functions and scripts for analyzing waveforms, primarily audio. This is currently somewhat disorganized and unfinished.
MIT License
255 stars 82 forks source link

how to use thdcalculator.py? #24

Open peterpain1216 opened 1 year ago

peterpain1216 commented 1 year ago

when i entered :python3 thdcalculator.py mytestfile.wav, nothing happened.

then i use: python3 thd_analyzer_launcher.py mytestfile.wav, i got this error:

Exception: name 'analyze_channels' is not defined

sorry for being a noob, how to use the scripts properly? thanks

peterpain1216 commented 1 year ago

python3 wave_analyzer_launcher.py mytestfile.wav

this script works fine for me.

endolith commented 1 year ago

Yeah it appears to not be finished, sorry. I'm not sure why I pushed it that way. For now you can load the WAV into an array and process it with THDN() https://github.com/endolith/waveform_analysis/blob/master/waveform_analysis/thd.py#L44 and it will return the ratio.

endolith commented 1 year ago

Or just use the old version: https://gist.github.com/endolith/246092

That works as you would expect:

λ python thdncalculator.py  "THD 75 harmonic -60 dB.wav"
Analyzing "THD 75 harmonic -60 dB.wav"...
Frequency: 40.000000 Hz
THD+N:     0.1109% or -59.1 dB