• WANTED: Happy members who like to discuss audio and other topics related to our interest. Desire to learn and share knowledge of science required. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

Phono Cartridge Response Measurement Script

JP

Major Contributor
Forum Donor
Joined
Jul 4, 2018
Messages
2,466
Likes
2,659
Location
Brookfield, CT
This thread is intended to consolidate the technical discussion and further development of Scott Wurcer's frequency response measurement script to a central area. I'd like to keep this discussion about the tool rather than specific cartridges.

I'll edit this and the subsequent reserved posts in the coming weeks with relevant info, background, links, etc.

Measurement Library thread is here.
 
Last edited:
The script code is now located at https://sjplot.com




This is an example plot:

Version 16.3 Example.png


These instructions are for the official Python distribution, which is what I use. You can use whatever distribution you like (Brew, Anaconda, etc.) however I won’t be able to help you with any issues. On the other hand, I’m not a heavy Python user so my help would likely be of limited value anyway.

As of this writing I recommend Python 3.10.9 as 3.11.1 is not supported by Numba, which is a dependency for librosa. You should do your own research on which version you want to run as I won’t necessarily always keep this information current. The good news is you can simply remove and reinstall a different version if you run into package compatibility issues.

To get 3.10.9, go to https://python.org/downloads. Scroll to the section titled “Looking for a specific release?” and click the download link for Python 3.10.9.
Mac-1.png


On the next page scroll down to “Files” and choose the macOS 64-bit universal2 installer.
Mac-2.png


Double-click the installer package from your Downloads folder and follow the defaults to complete installation.
Mac-3.png
It’s a good idea to keep all the files in the same directory as the script so that you don’t have to worry about specifying paths. For our purposes here we’ll name this folder Plots and place it in the Documents folder. You can name it and put it wherever suits you.
Mac-4.png



Next we need to install a few libraries. To do this, open Terminal and run the following three commands:


Code:
pip3 install --upgrade pip

pip3 install librosa

pip3 install matplotlib


You’ll want to ensure these processes complete successfully. Installing librosa will install two other required libraries, NumPy and SciPy, so there’s no need to do these separately.

Next launch IDLE, and select File, New File.

Mac-5.png




Copy and paste the script code from this post in to the “untitled” window, and select File, Save As.

Mac-6.png




Name the script something that makes sense to you, such as FR14.py – FR for Frequency Response, and 14 as example of the version. It doesn’t really matter, but make the extension .py, and be sure to save it in the folder you created above, which is ~Documents/Plots in our example.

Mac-7.png




At this point everything should be set for your first plot. Details of the file requirements for what you want to measure will be at the top of the script file, as will be an explanation of all the settings.

Copy your wav file in to the Plots folder and specify its name in the _FILE variable of the script. Don’t forget to update the Infoline to describe your plot. Then simply select Run, Run Module. You’ll be prompted to save the modified script file, after which the script will run.

MAc-8.png



The next time you run IDLE, simply select File, Open, and select the saved script file.

Windows Installation Instructions.
 
Last edited:
  • Fix axis label for amplitude difference. For channels that aren't normalized to 0, the signs may be incorrect.
  • Add (I)RIAA filters for 192kHz.
  • Add filter for Denon XG-7001 (in 17 Beta).
  • Auto-detect channel order.
  • Do not show "crosstalk" in the legend for mono files.
  • Consider showing phase correlation between the fundamental and crosstalk.
  • Add the ability to process two files for plots sets of both left and right channels on the same figure.
  • Improve y-axis scaling logic.

17.0
  • Added two new plot styles: (4) a dual plot with FR zoom and dual-axis, and (5) a small FR-only plot
  • Added EQ filter for Denon XG-7001 (filter courtesy of @stereoplay)
  • Corrected +/- annotation to be relative to the normalization frequency for the respective file rather than file_1 being relative to file_0. IOW, this no longer factors channel balance in to file_1 calcs.
  • If file0norm = 0, there will be a magenta "X" at 0dB on the plot at the normalization frequency. This denotes that each file was normalized individually, and what the normalization frequency was.
  • If file0norm = 1, there will be a vertical magenta line at the normalization frequency to denote that file_1 was normalized to file_0 level at the normalization frequency, and what the normalization frequency was.
  • (Internal) refactored the plot axes to make them iterable.

16.5
  • Added version to plot image.

16.4
  • Fixed plot scaling error with mono files.

16.3 Beta
  • Removed pre-filter.

16.2 Beta
  • Fixed copy/paste error with plot style 1

16.1 Beta
  • Added equipment info line to describe the capture signal chain.
  • Crosstalk @1kHz outputs on the console line.
  • Adjusted font sizes.

16 Beta
  • Added the ability to process two files, each file representing a channel. File_0 is left, and if specified file_1 is right.
  • Added the ability to normalize each file independently, or to normalize both to file_0.
  • Fixed cosmetic and layout issues.
  • Plotdataout will output data for both files.
  • Date/Time on plot is now the date/time the plot was generated instead of the input file date/time.

15.3 Alpha
  • Added the ability for an Butterworth HP pre-filter. Variable prefilterfreq is the filter frequency and prefilterorder is the order of the filter. If prefilterfreq = 0 no filter will be applied. Be careful to ensure the filter isn't attenuating frequencies of interest.

15.2 Alpha
  • Let matplotlib decide the location for the legend box in plot style 2 instead of hard-coding.

15.1 Alpha
  • Fixed axis colors for plot style 1.

15 Alpha
  • Detects mono or stereo file. If stereo the script will assume the right channel is crosstalk and will plot it as such. If you want to plot R<L, you'll need to swap channels prior to plotting.
  • Script will SRC files <96kHz to 96kHz, but will not SRC files above 96kHz. The only (I)RIAA filters in the script presently are for 96kHz.
  • Variable onekfstart will star the plot at 1kHz if set to 1. Variable endf is the highest frequency to plot. The basement for this setting is around 3000.
  • Plot style 3 will not plot crosstalk.
14 Alpha - Internal only.

13 Beta
  • Full range plots.
  • Compensation for STR-100.
  • RIAA and inverse RIAA implemented separately for bass and treble.
  • SRC all files to 96kHz (temporary to make filtering easier).

Code:
 
Last edited:
APPENDIX

Comparison plots of all STR-100 versions.

B&K QR2009 and QR2010 comparison plots.

Code:
[a0, a1, a2]
[b0, b1, b2]

Sample Rate = 96k

     10kHz Attenuation (-13.73dB)

          [1., -0.66168391, -0.18158841]
          [1., 0.3655731, 0.01499662]

          ^ Gain at 1kHz: 18.0272664dB

          Unity gain at 1kHz:

               Standard

                    [1., -0.66168391, -0.18158841]
                    [0.125497963890536, 0.0458786797031512, 0.0018820452752401]

                    (biquad-m *track* 1.2549796389053600E-01 4.5878679703151200E-02 1.8820452752400900E-03 1.0000000000000000E+00 -6.6168391000000000E-01 -1.8158841000000000E-01)

               Inverse

                    [1., 0.3655731, 0.01499662]
                    [7.96825676687663, 5.27246729339089, 1.44694307676887]
 
                    (biquad-m *track* 7.9682567668766300E+00 -5.2724672933908900E+00 -1.4469430767688700E+00 1.0000000000000000E+00 3.6557310000000000E-01 1.4996620000000000E-02)

 
      Roll-off and Shelf (50.05Hz and 500.5Hz)

           [1., -0.60450091, -0.39094593]
           [1., -0.57552742, -0.37960478]

           ^ Gain at 1kHz: 0.83242476dB

           Unity gain at 1kHz:

                Standard

                     [1., -0.60450091, -0.39094593]
                     [0.908612614639649, -0.522931473883012, -0.344913691685509]

                     (biquad-m *track* 9.08612614639649000E-01 -5.22931473883012000E-01 -3.44913691685509000E-01 1.00000000000000000E+00 -6.04500910000000000E-01 -3.90945930000000000E-01)

                Inverse

                     [1., -0.57552742, -0.37960478]
                     [1.1005790409333, -0.665301031771105, -0.430266896696176]

                     (biquad-m *track* 1.10057904093330000E+00 -6.65301031771105000E-01 -4.30266896696176000E-01 1.00000000000000000E+00 -5.75527420000000000E-01 -3.79604780000000000E-01)


To chain biquads in Audacity Nyquist prompt:

(setf *track* (biquad-m *track* b0 b1 b2 a0 a1 a2)) (biquad-m *track* b0 b1 b2 a0 a1 a2)

Chain in the order above - 10kHz attenuation, and then roll-off and shelf.
 
Last edited:
How to run the script in Windows

3/26/23 NOTE: There may be an issue with the latest version of Anaconda released a few days ago. Avoid the 2023.03 release of Anaconda for now and use an earlier, proven version (the previous release was 2022.10). There is likely a compatibility issue involving the updated version of the soundfile library that comes with it.

Use the 2022.10 release located here: https://repo.anaconda.com/archive/


1. Download and install Anaconda from here: https://www.anaconda.com/products/distribution
  • Install with default, recommended settings
  • Latest versions of Anaconda come with most of the required libraries (e.g. mathplotlib, scipy, numpy)
    • However, you will need to manually install librosa
Untitled.jpg


2. Open Anaconda Navigator and install librosa library
  • Anaconda Navigator is in your apps list on the Start menu if you are using a recent version of Windows
    • Usually in a folder named "Anaconda3 (64-bit)"
  • Open CMD.exe Prompt from within Anaconda Navigator (Home) as seen in the image above and run the following command:
conda install -c conda-forge librosa

Untitled3.jpg

  • Remember, especially if you are only using python to run this script: if it ain't broke, don't fix it
    • Don't upgrade components for the sake of upgrading
      • You are just fine if you are using, say, Python 10.9 and Spyder 5.2.2
    • Updates can lead to library incompatibility issues (e.g. missing .dll error) and you may have to re-install everything
3. Run sub-program Spyder
  • You can open Spyder from within Anaconda Navigator (Home) but once all set up you can run Spyder directly as a standalone Windows app
Untitleds.jpg


4. Open the script in Spyder and customize with minor edits
  • If you have the script and sweep recording files in different folders, find and adjust the following variables used for left and right channel sweeps, respectively:
file_0 = 'wavefile1.wav'
file_1 = 'wavefile2.wav'
  • Use full path names
file_0 = ''/Users/USER/Desktop/Folder/wavefile1.wav'
file_1 = ''/Users/USER/Desktop/Folder/wavefile2.wav'
  • Provide detailed information about your set-up with the following variables:
infoline = 'Cart / Load / Record'
equipinfo = 'Arm -> Phonostage -> ADC'
  • infoline: to make the measurements useful to others please provide as much information as possible
    • Loading information (e.g. total capacitance and resistance) is particularly important
      • Accounting for cable capacitance is strongly encouraged as it affects the frequency response of MM cartridges
    • The DER EE DE-5000 LCR meter is highly recommended for measuring your cartridge channels as well as cable capacitance
      • It is an extremely useful tool with which to check if your cartridge meets spec or is functioning properly
      • Regular multimeters exaggerate cable capacitance
  • The following is an example of the information I would provide
infoline = 'Shure V15 V-MR | L & R | 1.25g (No Brush) | 47kΩ | 210pF | CBS STR-100'
equipinfo = 'Denon DP-35F - Wayne Kirkwood Flat MM - E1DA Cosmos ADC'
  • Adjust additional variables, including the following
riaamode
riaainv
str100
  • Your test record and recording characteristics (e.g. RIAA equalization) determine your settings
    • Please see the script itself for information regarding these settings and options
  • If you want output larger images, increase the dpi variable in the following line toward the end of the script (e.g. 96 to 300):
plt.savefig(infoline.replace(' / ', '_') +'.png', bbox_inches='tight', pad_inches=.75, dpi=96)
5. Run the script when ready
  • Press the green play button on top (F5)

-----------------------------------------

So you got cute and tried updating or changing something you shouldn't have, and uninstalling and reinstalling doesn't get you back.
The most sure-fire thing to do is a perform a full uninstall of Anaconda. Here's how to do it:
  • Open Anaconda Navigator and open CMD.exe Prompt
    • Then type the following:
conda install anaconda-clean
  • When that is finished running, type the following:
anaconda-clean --yes
  • This sets-up a thorough Anaconda uninstall
  • After this, uninstall Anaconda as you normally would
  • Restart your computer
  • Great. Now get rid of as many of the leftover files that are causing problems as possible
    • Go to your equivalent of these two folders:
C:\Users\NAME
C:\Users\NAME\AppData
  • In "C:\Users\NAME" delete anything associated with "anaconda" "conda" "spider" etc.
Untitled75.jpg

  • In this example, I deleted:
.conda
.ipython
.matplotlib
.spyder-py3
anaconda3
and the file .condarc
  • In "C:\Users\NAME\AppData" go to both "local" and "roaming"
    • You may see folders like the following:
Local: conda, spyder, pip
Roaming: jupyter
  • Delete those
  • Restart your computer
  • Install Anaconda and librosa EXACTLY as the instructions say
    • Hopefully you are up and running again
 
Last edited:
Presently working on implemeting:
  • Full-range plots
  • SRC to 96k to simplify the math and logic. Later I may add SRC to 192k for files >96k as we're plotting 2H and 3H
  • The ability to apply RIAA, inverse RIAA, and for both the ability only apply bass turnover and shelf
  • General restructuring in to functions for hygiene and to extend utility, e.g. plotting multiple axis

These next three plots are:
  1. Full-range plot of the (simulated) recording characteristic of JVC TRS-1007, which is RIAA bass turnover and shelf without treble emphasis. This applies to many test records. FILE
  2. Cartridge FR plot of a flat layback from a TRS-1007 sweep track. FILE
  3. The same layback as #2 but with RIAA bass turnover and shelf applied via the script.

TRS-1007 Recording Characteristic.png

20Hz-20kHz Test Flat.png

20Hz-20kHz Test 318 3180.png



*** The IIR filters I'm using were done by Scott. Background and method are published here: https://linearaudio.net/record-replay-riaa-correction-digital-domain.
 
Last edited:
There may be a better solution but it was the first thing that worked for me when I was trying to run it. Inelegant, sure, but at least it doesn't get in the way of the rest of the code. Anyways, it's our problem, not yours, lol.

Well, I would like it to be as easy as possible for folks so that more people use it; all in the pursuit of standardized measurements. I can make it detect the OS, etc. but when I get time to work on it, I want to work on the fun stuff.
 
This thread is intended to consolidate the technical discussion and further development of Scott Wurcer's frequency response measurement script to a central area. I'd like to keep this discussion about the tool rather than specific cartridges.

I'll edit this and the subsequent reserved posts in the coming weeks with relevant info, background, links, etc.
Where is the original discussion of this topic? Can you provide a link? Is crosstalk measured too?

Inter-channel crosstalk data is essential in evaluating phono cartridges. Minor resonances clearly show up in crosstalk.
 
Last edited:
Where is the original discussion of this topic? Ca nyou provide a link? Is crosstalk measured too?

Inter-channel crosstalk data is essential in evaluating phono cartridges. Minor resonances clearly show up in crosstalk.

I'll add the background info and links to the original discussion on diyAudio when I can. WYSIWYG.
 
Great thread. Who can aid the step by step procedure for Mac OS? I have tried to learn more of Python and Terminal stuff, but I realise I need a good book for this.
 
Great thread. Who can aid the step by step procedure for Mac OS? I have tried to learn more of Python and Terminal stuff, but I realise I need a good book for this.

I can after I finish up this version. Maybe someone else can jump in interim.
 
This space is reserved for a visually-aided overview of how to use the CBS STR-100 test record with Audacity in order to create a file ready for the script.

Most of the test records being used on this site (the "eBay" ones) are issue 3 (new), which is the only version that is recommended. The record has a highly visible sweep oscillator switching at around 5kHz. In addition, it is not a good record to use for crosstalk measurements. Distortion measurements are limited compared to the very best test records, but they go down to about -40dB for the 2nd harmonic, which is more than good enough to tell you about the general quality of the cartridge. Some batches of the CBS STR-100 test records have pressing issues that affect the results above 10kHz. This is compounded by the fact that a lot of copies are slightly warped as they have been stored in shrink wrap for decades. Record flatteners can certainly help and are recommended, but expect issues to remain. Despite all of this, the test record can provide you with excellent and useful measurements and is one of the very best still available today.

Worst case scenario:

Here is a comparison of the first batch I bought from eBay using a Shure V15 V-MR. #1 has the nastiest issue. However, it is still very much usable because the issue is obvious. Nonetheless, even if you have an off copy, the differences are generally within 0.5dB. Set-up alone can have a similar effect.
CBS STR-100 COMPARISONgif.gif

This all being said, this new batch look good, so YMMV. (These are not to be compared to those above.)
CBS STR-100 GOOD COPIES.gif

The CBS STR-100 issue 3 (new) (the "eBay" version) test record compares favorably with the most accurate--and adjusted--test records, with the biggest difference being a 0.5 dB bell dip from around 5-10kHz. (And the addition of whatever quirk your record may have above 10kHz, of course.) Expect a corrective EQ curve in the future.

You will need to record the first track of the CBS STR-100, which is comprised of a left channel sweep and a right channel sweep. The important thing to do is to remove the initial calibration tone before each respective sweep and cut at the end of the sweep. Cut right where the sweep begins and ends, not necessarily where the calibration tone ends. There should be no silence, only the sweep. Normalizing the file can help you find the spots. Then separate and save the left and right channel sweeps as separate .wav files to load onto the script, making sure you swap the channels for the right channel sweep so that it is the main track on top.

It is strongly advised that you keep a copy of the full, stereo, two-channel recordings as a backup.

There is a setting in the script (riaainv) that enables the processing your file with an inverse-RIAA filter in the likely case that your phono preamp uses RIAA. However, in case they are useful to you, RIAA and Inverse-RIAA nyquist filters for 96k recordings on Audacity are attached here. They are based on the biquads posted above. These filters are to replace ALL previously distributed ones, which have minor errors at best and are way off at worst. These are the most precise filters available on the web.
 

Attachments

  • RIAA & IRIAA Filters.zip
    590 bytes · Views: 166
Last edited:
What is the hardware setup for this? Any old turntable/alignment of the cartridge will do???
Yes, any turntable and cartridge will do. Detailed information including loading settings and cable capacitance is necessary to ensure useful results. Loads and loads of them in this thread, starting around here:


Note that these will need to be re-adjusted with the changes JP is making in order to optimize the results, including the new IRIAA filter. There will be a new thread dedicated to cartridge measurements in the near future. It's going to be a terrific collection. Let's hope ASR can become a good, hospitable place for turntable and cartridge discussion.

The test record makes or breaks this as it usually does. JP uses a nearly impossible to find JVC TRS-1007. We plebs use the CBS STR-100 found on eBay for $17. (If this thread takes off expect prices to sky rocket once they sell out). A project is slowly underway to compare the JVC and CBS records properly, but they are both pretty good even with their quirks.

Ideally you want to record at 96k to get the full 2nd harmonic. 192k or so for 3rd. You may have to run a IRIAA filter depending on the record and/or phono preamp.
 
Last edited:
Is it this thread?


No - the development of it started around here: https://www.diyaudio.com/community/thre ... st-5749320
 
In regard to the CBS STR 100 test record, it is indeed what most people use as they are still easy to get, particularly from the eBay seller 92hdcma. This record worked reasonably well when we were plotting from 1kHz, but full-range plots will present some interesting hurdles:

CBS STR 100 Recording Characteristic.png


"The resultant curve for a typical high-fidelity pickup is shown in Fig. 1. Note that in the STR 100 record the 500-Hz break is sharp; the modulation below 500-Hz is precisely at constant amplitude; above 500-Hz at constant velocity. Thus, ideally response can be verified if the trace follows two straight lines - one rising at 6dB per octave up to 500Hz and the other horizontal above 500Hz."

Doc - Jan 18 2023 - 8-44 PM[11].jpeg


STR 100 Test Flat.png

^ FILE

There's a lot of LF modulation in this record, such that if I try to correct it the LF "grunge" is the largest bin in each time slice which renders the method useless. Rather than pre-filtering and figuring out a transfer function (which I've never done before), it may be easier, at least for now, to just apply an amplitude correction to each bin between 40Hz and 500Hz. That math is easy.

Below illustrates the problem. Top two are flat, and the bottom two I applied RIAA base turnover and shelf.

Screen Shot 2023-01-19 at 12.31.16 PM.png
 
Last edited:
What is the hardware setup for this? Any old turntable/alignment of the cartridge will do???

As @USER said the hardware really isn't critical as long as it's not broken. For full range measurements folks will want to pay attention to arm/cartridge matching as that can definitely affect performance <30Hz or so. I should work on adding an LF FFT inset so people can see where that resonance is and eyeball the Q. This doesn't matter with the currently released version as it plots from 1kHz. The most difficult part for people is being able to determine what the actual load their setup presents to an MM and also MI types, as that can affect HF performance to a large degree.

I'll write more later on how it works if I can rope that @SIY guy in to being my technical editor so I don't wind up saying anything really stupid. In a nutshell it's time slicing the signal and returning the largest bin for a given slice, which are then interpolated/averaged. Slices are Fs/100 in the current version but small slices don't work for LF and large slices don't work for HF. This next version uses ranges of slices that gives us 5Hz bins (smallest that'll work) for 0-50Hz, 10Hz for 50-100, 20Hz for 100-1kHz, and 100Hz for 1kHz+.

I've even used it as a bit of a verification tool by playing spot frequencies and doing a controlled ramp down of the platter speed. "Controlled" meaning I needed the end speed to be a certain percentage of normal speed. This is a 20kHz spot ramped down 50%, so the "sweep" is 20kHz to 10kHz. A perfectly flat cartridge would adhere to a 6dB/oct line.

150MLX_150pF 47k_STR-170 Fake Sweep.png
 
Back
Top Bottom