Beginners Filter brewing thread for the Soekris R2R

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Not to clutter up the more knowledgeable thread found here I started this thread to get us beginners going.

The more I read the more I realize I’m not going to be the one creating the best sounding DAC filter. But I do need to learn enough to be able to create crossovers with dam1021.

I'll try to update this first post with links and index.
Although this thread is more about what to type in where for dummies please do take Paul's (spzzzzkt) advice on background reading into account.

Quick overview of terminology and buzz words explained here at Digital Filter Terminology
Digital Filter Terminology | dspGuru.com

Some of the application used in the main filter thread:

MKROM.EXE
The mkrom utility read and process the input .txt parameter files as 64 bit floats, including the multiplier, then convert to the 2.30/3.29 fixed formats in the final step. dam1021 use 2.30 fixed point format for the FIR filters and 3.29 fixed point format for IIR filters. Post #1873
Make sure you have the latest version and note the input file name '1021filt.txt', it's hardcoded as the utility do other things, all based on the filename.
Soekris Engineering, Inc. | How to buy

GNU Octave
Heavy calculation
GNU Octave - Wikipedia, the free encyclopedia
https://www.gnu.org/software/octave/download.html
Please note if you run GNU Octave on Win7 you need to manually install package ‘signal’ from Command Window in Octave.
Post #549 has a finished script that will plot 3 different view of amplitude response + impulse plot. Thanks to Paul for sharing his insight.

SoX
Apply calculation to audiofile and output plots and text files
Paul explains how to get started with SoX in post #7
SoX - Sound eXchange | HomePage

rePhrase
Create filters and EQ
User pos have posted on Getting started with rePhrase in post #1573 #1630
rePhase | SourceForge.net


Main filter brewing thread with filters:
http://www.diyaudio.com/forums/digital-line-level/269776-filter-brewing-soekris-r2r.html
Wiki:
Soekris R2R DAC - diyAudio
 
Last edited:
I was thinking of posting in the main filter thread asking the leading lights there to each post their recommended reading list for people interested in learning the basics. A sort of 101 of filter basics. Perhaps this is a better place to ask for such recommendations.
 
Disabled Account
Joined 2005
Have a look at the first post of the filter brewing thread. There is a list of articles I've found useful at the end.

I've posted many examples of how to use SoX in the main thread..

You guys should just ask questions in the main thread. I had never made a DAC filter until about 5-6 weeks ago, so really what I know is down to reading plus lots of trial and error. Probably more heavily weighted to error ;)
 
Last edited:
Thank you spzzzzkt!

I’ve started reading. But I have to admit I’m one of those people that like to type the “Hello world” script first. See it happen and then read up on what happened.

SoX manual are focused around SoX’s primary function. Samplerate and file conversion. Still banging my head on wrong side of the front door of the application. I’ve no idea how to get at text file out of Sox. Or found a good help file explaining the effect section.

My thought was to take these baby step here not to bore those that can really help discuss design and advanced application tricks.
 
Create a Spectrogram with SOX

sox myfilename.wav -n spectrogram
Sox will now output a image file with the name spectrogram.png

See more options here: https://www.youtube.com/watch?v=k1TRq5lk0Sg


Tip for Windows users :bulb:
If you install SoX on Win7/8 it will probably install itself in your Program folder. Where you have restricted file access. :no:
You need to start cmd.exe as administrator to now work with files in this directory. I prefer to copy or move the complete SoX catalog to my Document directory. In the long run this prevent me from program failures in the future when I forget to use admin privileges on the directory.​
 
Disabled Account
Joined 2005
Thank you spzzzzkt!

I’ve started reading. But I have to admit I’m one of those people that like to type the “Hello world” script first. See it happen and then read up on what happened.

SoX manual are focused around SoX’s primary function. Samplerate and file conversion. Still banging my head on wrong side of the front door of the application. I’ve no idea how to get at text file out of Sox. Or found a good help file explaining the effect section.

Gotta love open source documentation.

The main "trick" is to use the "--plot octave" option in SoX.

What this does is generate a file that can be run in Octave to plot a graph of the frequency response. The plot file has an array "b" which contains the filter coefficients.

This is what SoX spits out:

Code:
% GNU Octave file (may also work with MATLAB(R) )
b=[ -1.4345863902477147e-09
 -2.8048760297910892e-09
 -4.2669231642866944e-09
 -5.4443716296796324e-09
...
 -5.8862386696052250e-09
 -5.4443716296796324e-09
 -4.2669231642866944e-09
 -2.8048760297910892e-09
 -1.4345863902477147e-09
];
[h,w]=freqz(b,1,4096);
plot(176400*w/pi,20*log10(h))
title('SoX effect: sinc filter freq=0-21000')
xlabel('Frequency (Hz)')
ylabel('Amplitude Response (dB)')
grid on
axis([0 176400 -175 5])
disp('Hit return to continue')
pause

I've trimmed the array because its too long to post...

If you run that in Octave it plots a nice graph.
To extract the filter coefficients, use a text editor to cut'n'paste the filter from the array.

This is an example of how I'm making filters with SoX:

Code:
sox --plot octave -r 352.8k -n output.wav synth 1 noise  sinc  -b15 -L -21k -t3800  > filterDM_Linear.m

--plot
If not set to off (the default if −−plot is not given), run in a mode that can be used, in conjunction with the gnuplot program or the GNU Octave program, to assist with the selection and configuration of many of the transfer-function based effects. For the first given effect that supports the selected plotting program, SoX will output commands to plot the effect’s transfer function, and then exit without actually processing any audio.

-r
Gives the sample rate in Hz (or kHz if appended with ‘k’) of the file.

NOTE: This needs to given as the rate after upsampling. So 352.8k for 44.1 based rates and 384k for 48 based rates. For FIR2 you need to use 2822.4k and 3072k respectively.

-n
This can be used in place of an input or output filename to specify that a ‘null file’ is to be used.

Using a null file to input audio is equivalent to using a normal audio file that contains an infinite amount of silence, and as such is not generally useful unless used with an effect that specifies a finite time length (such as trim or synth).

synth
This effect can be used to generate fixed or swept frequency audio tones with various wave shapes, or to generate wide-band noise of various ‘colours’.

Though this effect is used to generate audio, an input file must still be given, the characteristics of which will be used to set the synthesised audio length, the number of channels, and the sampling rate; however, since the input file’s audio is not normally needed, a ‘null file’ (with the special name −n) is often given instead (and the length specified as a parameter to synth or by another given effect that can has an associated length).

sinc
Apply a sinc kaiser-windowed low-pass, high-pass, band-pass, or band-reject filter to the signal. The freqHP and freqLP parameters give the frequencies of the 6dB points of a high-pass and low- pass filter that may be invoked individually, or together. If both are given, then freqHP less than freqLP creates a band-pass filter, freqHP greater than freqLP creates a band-reject filter. For example, the invocations

sinc 3k
sinc -4k
sinc 3k-4k
sinc 4k-3k

create a high-pass, low-pass, band-pass, and band-reject filter respectively.

The default stop-band attenuation of 120dB can be overridden with −a; alternatively, the kaiser-window ‘beta’ parameter can be given directly with −b.

The default transition band-width of 5% of the total band can be overridden with −t (and tbw in
Hertz); alternatively, the number of filter taps can be given directly with −n.

If both freqHP and freqLP are given, then a −t or −n option given to the left of the frequencies applies to both frequencies; one of these options given to the right of the frequencies applies only to freqLP.

The −p, −M, −I, and −L options control the filter’s phase response; see the rate effect for details.

This effect supports the −−plot global option.

A phase response setting may be used to control the distribution of any transient echo between ‘pre’ and ‘post’: with minimum phase, there is no pre-echo but the longest post-echo; with linear phase, pre and post echo are in equal amounts (in signal terms, but not audibility terms); the intermediate phase setting attempts to find the best compromise by selecting a small length (and level) of pre-echo and a medium lengthed post-echo.

Minimum, intermediate, or linear phase response is selected using the −M, −I, or −L option; a custom phase response can be created with the −p option. Note that phase responses between ‘linear’ and ‘maximum’ (greater than 50) are rarely useful.

That gives you everything needed to make a filter using SoX :)

It should be apparent from the manual sections that:

Code:
-r 352.8k -n output.wav synth 1 noise

is only used to specify the sampling rate used by sinc. It doesn't generate an output file, and the 1 second of noise is not used but is necessary to stop SoX grumbling about missing files.

The real magic is done by the combination of --plot and sinc

Here is an example I was messing with last week...

sinc -a80 -I -21.5k -t8000

This specified an intermediate phase filter (-I), with stop band attenuation of -80dB.
The -6dB point for the filter is 21.5kHz and the transition band is 8000hz wide.

And this is what you get as a result:
attachment.php


The -t parameter is slightly non-obvious. The transition band is centred on the frequency given for the -6dB point. This means that the filter starts to roll off at 21500hz minus 4000hz (17500kHz) and reaches full attenuation at 21500z plus 4000hz (25500hz)

If using the -b parameter to specify kaiser window beta the number of taps that results is the same as if you had specified -a120. However once you get over -b12.5 the attenuation is greater than -120dB. The trade off is that the slope of the filter becomes more gentle as beta increases.

Julian Dunn observed that
The minimum length of an FIR low pass filter is related to three parameters. It increases with reduced transition region width, reduced maximum pass-band error (or ripple), and with increased minimum stop-band rejection.

With SoX increasing stop band attenuation also reduces passband ripple. So you end up having to juggle stop band attenuation (or kaiser window beta), transition band width, and corner frequency to get an acceptable result which comes in under maximum number of taps.

cheers
Paul
 

Attachments

  • Example.png
    Example.png
    30.5 KB · Views: 758
Paul

Thank you for the nice introduction to SoX. It definitely helps us in experimenting digital filters.

Because of the DAM1021 project, I had started to read material related to digital design.
I ordered and read my first book in digital design: Digital Filters for Everyone.

A beginner's question: Is uploading digital filter to DAM 1021 the same as updating firmware ? (I did update the firmware) After uploading a filter, the new filter will work automatically?
 
Now there is something to digest :D
Thank you so very much Paul!

I also noticed rePhase complains about missing files. Have to investigate what she need to execute. She might even give me text files in the end.
Even though having a GUI she isn’t that mature. User interface do not mirror menus and execution buttons as we normally see in Windows applications.
 
Disabled Account
Joined 2005
Just had a thought... The default transition band of 5% is calculated from the sampling rate /2. So for 352.8k it is 5% * 176.2k = 8820hz

This is obviously not what you'll want if you are making a steep filter for 44.1kHz.

You are going to get best control by looking at your desired cutoff - say 22050hz - and -6dB point - 20750hz for example - and calculating the transition band from there. In this case there is 1300hz between -6dB and cutoff/stop band, so you would specify -20.75k -t2600.
 
Disabled Account
Joined 2005
Paul

Thank you for the nice introduction to SoX. It definitely helps us in experimenting digital filters.

Because of the DAM1021 project, I had started to read material related to digital design.
I ordered and read my first book in digital design: Digital Filters for Everyone.

A beginner's question: Is uploading digital filter to DAM 1021 the same as updating firmware ? (I did update the firmware) After uploading a filter, the new filter will work automatically?


Same as firmware upload. The filters will reload any time there is loss of sync, change of sampling rate, or change of input. All I do is change the input selecting i3 works for me.
 
Octave - Fighting the tools - The never-ending series

On Win7Pro 64bit Octave plot windows (display) hangs with Win7 warning “Not responding

If I remove ‘pause’ in the editor it seems the plot window now can receive focus.

An externally hosted image should be here but it was not working when we last tested it.


Reason might be some old window handling developed for older Windows platforms that doesn’t translate well to newer Windows.
 
Hi there,

A dummy question, in order to drive two sets of speakers (set A (high/mid) and set B (bass only)) having the dam broad works as a digital crossover.

Would it requires 2 dam broads or it's possible to make use of both the buffered and unbuffered on the single dam broad for different frequency range?

If it's require 2 dam broad, does it mean the 2 broads tap from the same i2s source at the same time? Any other components required?

Thanks in advance.
 
Disabled Account
Joined 2005
Hi there,

A dummy question, in order to drive two sets of speakers (set A (high/mid) and set B (bass only)) having the dam broad works as a digital crossover.

Would it requires 2 dam broads or it's possible to make use of both the buffered and unbuffered on the single dam broad for different frequency range?

If it's require 2 dam broad, does it mean the 2 broads tap from the same i2s source at the same time? Any other components required?

Thanks in advance.

The crossover functionality is not implemented in the current 0.9 firmware, and is slated for "a next release".

So you'll really have to wait for the next firmware revision or possibly longer before anyone is going to be able to offer informed//non-speculative advice.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.