It might be possible to make a ladder filter of any integer order because of its iterative structure. I’m not sure if it’s possible to create an arbitrary integer number of variables and assign values to them in the parser though. It might even be possible to do something that isn’t just integer-order…
That’s a great find, I wasn’t finding anything that close to legible as in easy to understand or at least close to there. I personally don’t understand it very well though I did managed to replicate some audacity functions at a elemental level, and echo is very much similar at a basic level. I’ll have a look at those in hope of finding something that’s easy to translate.
DSP in general is very tough, almost like magic. In music technology I see people doing some crazy things but a lot of the source code is closed and going through textbooks of material (mostly hard maths) is painfully slow. I’m still trying to find a way to convert a low pass like that into a high pass… Maybe this might help. One pole, one zero LP/HP — Musicdsp.org documentation
Soft saturation is really easy to implement but we don’t really need it - it’s a contrast enhancement. It’s a specific kind of waveshaper, and we already have that thanks to the curves graphs. A compressor isn’t as easy to make but it would have a very unusual effect.
We should note that we’ve got an advantage that musicians don’t: our signals aren’t live and we already have all the data we need. We don’t have to care about latency, so we can take samples anywhere within the image.
I have an audio background so a lot of my thinking about image processing is translated into audio terms in my head.
There are two main differences between images and audio (besides the 1D/2D thing).:
Images have all positive values and audio has negative and positive values. Audio has rapid fluctuations from positive to negative, which is quite different to image data which, even if it fluctuates, tends to be smoother.
Audio processing generally is one sample at a time, with no knowledge of future samples. Images have all the pixels available to you at once.
So, for this filter to be accurate, I would need to find a way to convert the unrolled data in a way that audacity sees the sound. Yeah, let’s not bother figuring that out.
Thanks for the low/high pass filter though I’m not sure about what is cut-off frequency or even stimulate it. That’s part of the reason that this filter would be a collaborative project since the number of audio filters is huge, and it can be difficult to understand the algorithm especially for me with no background in coding for audio processing.
@Iain I do understand what you are saying, as I have a long music background, in school and community. But I am a visual and auditory learner (mostly the latter). Could you provide a numerical and audio example? That would make it crystal clear. Thanks!
So each pixel is the average of all the preceding pixels weighted by distance from the current pixel.
By adjusting the proportion of current and previous samples in the calculation (F) you can determine how much effect distant pixels have on the current pixel. Similar to a Gaussian blur radius.
High frequencies in images is related to what photographers call sharpness. That is, difference in adjacent pixels. Mid frequencies are related to ‘local contrast’ that is a difference in pixel values over several pixels.
A small blur radius reduces high frequencies/sharpness, and larger blur radius affects mid-frequencies/local-contrast. So cut-off frequency is comparable to blur radius.
I had tested it, it appears that lowpass/highpass filter either turns the image gray. Adding cut 0,255 as post-process step seem to lead to more interesting result.
Also, about/just did added the code into OP. And sample picture there too.
I see that there’s differences. Which begs the question of why are the output different? I did took out the > with the assumption that the output should be similar. With rep_linear_echo, I didn’t see a difference.
A IIR filter (the kind we are discussing) accumulates the values of all previous samples/pixels, so you need to process them sequentially. The advantage of this is you only need to have 2 samples in memory and only a few operations for each sample processed.
In other words, if you wanted to do this non-sequentially, you would need to hold the whole image in memory and the complexity of processing would increase for each pixel.
I think that is part of why I have been scratching my head. I haven’t had a chance to observe the filters in action yet. I just need an idea of what it looks like, visually, sonically and figuratively.
In my mind, subtracting the previous value truncates values. How would it allow highs to be passed through? I am imagining the 1d audio fragment as a string. Lately, my brain has been cloudy, so maybe I am missing the obvious.
High frequencies are highly-frequent fluctuations from sample to sample. This creates significant differences between samples.
Low frequencies are infrequent fluctuations between samples. A low frequency signal means each sample is very similar to the previous one.
If you want to remove high frequencies and let low frequencies passed (a low pass filter) then averaging adjacent samples reduces the highly frequent fluctuations from sample to sample.
If you want to remove low frequencies and let high frequencies passed (a high pass filter) then you want to remove the similarities between samples and keep the differences. So a simple way to do that is to find the difference between (subtract) adjacent samples.
I couldn’t find any tutorials on YouTube which give you audio examples straightaway, they come with all sorts of explanations first instead of digging into what you actually get. I found a loop here https://freepd.com/music/Bit%20Bit%20Loop.mp3 and I used a section of it for some examples: loop1 is unedited, loop1-lp500 has a low pass at 500 Hz and loop1-hp2000 has a high pass at 2000 Hz. Both filters are second-order and neither are resonant.