[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] Re: 30hz high pass mastering



daniel-mayer wrote
> Right, the leakage effect shouldn't be neglected. Here is an example:

Or, a graphical demonstration: if we're cutting below the bin near 440 Hz,
we could sweep a sine wave from, say, 300 to 500 Hz, measure amplitude, and
see how flat it is.

s.boot;

b = Buffer.alloc(s, (20 * (s.sampleRate / s.options.blockSize)).asInteger,
1);

(
{
	var a = {
		var freq = Line.ar(300, 500, 20, doneAction: 2),  // 10 Hz/sec
		sin = SinOsc.ar(freq),
		fft = FFT(LocalBuf(2048), sin),
		filtered, amp;
		fft = PV_BrickWall(fft, 0.020527859237537);
		filtered = IFFT(fft);
		amp = (RunningSum.ar(filtered, 1024).squared / 1024).sqrt;
		RecordBuf.kr(A2K.kr(amp), b, loop: 0);
		(filtered * 0.1).dup
	}.play,
	cond = Condition.new,
	resp = OSCFunc({ cond.unhang }, '/n_end', s.addr, argTemplate:
[a.nodeID]).oneShot;
	cond.hang;
	// getToFloatArray uses forkIfNeeded so this behaves synchronously here
	b.getToFloatArray(wait: -1, action: { |data|
		d = data;
	});
	// data are very fidgety -- naive smoothing
	e = d.clump(100).collect(_.mean);
	e.plot;
}.fork(AppClock);
)

440.linlin(300, 500, 0, 1) * b.numFrames / 100
-> 96.467

... so we would expect to see a dip around there -- and in fact, we do. But
you can also see 3 amplitude bumps below that.

[e[5..96].maxItem, e.maxItem].ampdb
-> [ -41.745872666294, -5.017100134381 ]

So, the attenuation you're getting below the cutoff is, at worst, only -36
dB compared to the peak amplitude measured over the entire test. That might
be a useful result in some cases, but it certainly isn't "radically cutting
off."

It's only within the last couple of years that I started to really
understand FFT and filters. One of the takeaways is: in analog audio,
there's no such thing as a true brickwall filter -- and, because of the
physics of sound and the math of sampling, there's no such thing in digital
audio either.

The easy way would be, as Nathan said, cascading HPFs for more dB/octave.
HPF is second-order = -12 dB/oct, so HPF.ar(HPF.ar(sig, freq), freq) would
be 4th-order = -24 dB/oct. Traditionally the cutoff frequency is defined as
the point where you get 3 dB attenuation. So:

HPF.ar(HPF.ar(sig, 60), 60)
60 Hz = -6 dB  (I'm not sure about this, but let's go with it)
30 Hz = -30 dB
15 Hz = -54 dB  (-60 dB is usually considered practically silent)
7.5 Hz = -78 dB
3.25 Hz = -102 dB  (below the noise floor for 16 bits)

You could chain more filters, but that will also increase phase distortion.
I wouldn't go above 4th-order here.


Nathan wrote
> if filter ideality is a really high priority, a pretty standard solution
> would be to design an FIR filter using a scientific computation package
> of your choice. i haven't really used custom FIR filters with SC, but
> maybe Convolution3 will do the job.

I can't speak to efficiency, but sc3-plugins does have Nick Collins' "linear
time-invariant" filter implementation, where you give the coefficients
directly, and it can go to as high an order as you want. If the feedback
coefficients are all zero, then the impulse response will be finite.

http://doc.sccode.org/Classes/LTI.html

hjh



--
Sent from: http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/SuperCollider-Users-New-Use-this-f2676391.html

_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/