Sample level npass filter
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unixlike
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unixlike

 Posts: 162
 Joined: Fri Jun 23, 2017 12:45 pm
 Operating System: Windows 10
Sample level npass filter
An npass filter is a filter that reduces certain frequencies.
A sample level filter is a filter that only checks neighboring samples by a small amount.
Sample level lowpass filter: An output sample x are input samples (x1)×0.25, (x)×0.5 and (x+1)×0.25 added together. There is a checkbox for x1 and x+1 to overflow (first1=last, last+1=first).
Sample level highpass filter: An output sample x are input samples (x1)×0.25, (x)×0.5 and (x+1)×0.25 added together. There is a checkbox for x1 and x+1 to overflow (first1=last, last+1=first).
A sample level filter is a filter that only checks neighboring samples by a small amount.
Sample level lowpass filter: An output sample x are input samples (x1)×0.25, (x)×0.5 and (x+1)×0.25 added together. There is a checkbox for x1 and x+1 to overflow (first1=last, last+1=first).
Sample level highpass filter: An output sample x are input samples (x1)×0.25, (x)×0.5 and (x+1)×0.25 added together. There is a checkbox for x1 and x+1 to overflow (first1=last, last+1=first).

 Posts: 162
 Joined: Fri Jun 23, 2017 12:45 pm
 Operating System: Windows 10
Re: Sample level npass filter
And it is impossible to reproduce with current Audacity, as there isn't any exact volume input in Normalize (the dB input is limited to 2 decimal places, not even 16bit precision; please implement more decimal places AND an unencoded volume input).

 Posts: 162
 Joined: Fri Jun 23, 2017 12:45 pm
 Operating System: Windows 10
Re: Sample level npass filter
In fact, it's possible to generalize these samplelevel npass filters, producing a family of npass filters that work by duplicating, shifting, amplifying and combining.
For example, here is a cosine generalization that is essentially twice the size of the original samplelevel lowpass filter: (x3)×0.03661165, (x2)×0.125, (x1)×0.21338835, (x)×0.25, (x+1)×0.21338835, (x+2)×0.125 and (x+3)×0.03661165 added together.
What will happen, if a sinc generalization is used?
For example, here is a cosine generalization that is essentially twice the size of the original samplelevel lowpass filter: (x3)×0.03661165, (x2)×0.125, (x1)×0.21338835, (x)×0.25, (x+1)×0.21338835, (x+2)×0.125 and (x+3)×0.03661165 added together.
What will happen, if a sinc generalization is used?
Re: Sample level npass filter
If you really want to do this sort of thing, you need to use MatLab, or Octave, or Nyquist.
Of those three, Nyquist is by far the easiest to learn and use, and it is built into Audacity.
The other two are unrelated to Audacity, and have their own support channels.
Looking at your original post, if we ignore the bit about "overflow", then it is a kind of averaging filter that may be achieved in just a few lines of Nyquist code.
These examples can be run in the Nyquist Prompt effect, and require a fairly recent version of Audacity. They are not full plugins, though they could easily be made into full plugins, but are to illustrate how you would approach this type of task in Audacity. I don't use MatLab or Octave, so I can't help with either of those.
If all you are interested in is the frequency response of the filter, then it is even easier:
It gets a little more complicated to add the "overflow" samples, and in most cases it will just create a click at the start and/or end, but it can be done like this:
Of those three, Nyquist is by far the easiest to learn and use, and it is built into Audacity.
The other two are unrelated to Audacity, and have their own support channels.
Looking at your original post, if we ignore the bit about "overflow", then it is a kind of averaging filter that may be achieved in just a few lines of Nyquist code.
These examples can be run in the Nyquist Prompt effect, and require a fairly recent version of Audacity. They are not full plugins, though they could easily be made into full plugins, but are to illustrate how you would approach this type of task in Audacity. I don't use MatLab or Octave, so I can't help with either of those.
Code: Select all
;version 4
;control type "Filter type" choice "Low pass,High pass" 0
(setf type (1+ (* type 2)))
(defun filter (sig)
(let ((d (/ len)))
(sum
(mult type 0.25 (extract (* 2 d) 1 sig))
(mult 0.5 (extract d 1 sig))
(mult type 0.25 sig))))
(multichanexpand #'filter *track*)
Code: Select all
;version 4
;control type "Filter type" choice "Low pass,High pass" 0
(if (= type 0)
(lowpass2 *track* (/ *soundsrate* 4) 0.57)
(highpass2 *track* (/ *soundsrate* 4) 0.57))
Code: Select all
;version 4
;control type "Filter type" choice "Low pass,High pass" 0
;control loop "Loop boundary values" choice "Yes,No" 0
(setf type (1+ (* type 2)))
(defun sample (val)
(sndconst (* type 0.25 val) 0 *soundsrate* (/ *soundsrate*)))
(defun sampleval (sig n)
(if (= loop 0)
(absenv (sref sig (/ n *soundsrate*)))
0))
(defun filter (sig)
(let ((d (/ len))
(first (sampleval sig 1))
(final (sampleval sig (1 len))))
(if (= loop 0)
(sum
(sample final)
(mult type 0.25 (extract (* 2 d) 1 sig))
(mult 0.5 (extract d 1 sig))
(mult type 0.25 sig)
(atabs (/ ( len 1) *soundsrate*) (cue (sample first))))
(sum
(mult type 0.25 (extract (* 2 d) 1 sig))
(mult 0.5 (extract d 1 sig))
(mult type 0.25 sig)))))
(multichanexpand #'filter *track*)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

 Posts: 162
 Joined: Fri Jun 23, 2017 12:45 pm
 Operating System: Windows 10
Re: Sample level npass filter
The purpose of the integer overflow for these filters is to allow seamless processing on loops.
Re: Sample level npass filter
Normally one would process the audio before making the loop.Piotr Grochowski wrote:The purpose of the integer overflow for these filters is to allow seamless processing on loops.
If you are starting with a seamless loop and you want to apply effects, then a useful technique is to to repeat the loop 2 times (total of three times, then apply the effects, then make a new loop from the middle 1/3rd. This technique works with most effects, without requiring specially modified effects.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

 Posts: 162
 Joined: Fri Jun 23, 2017 12:45 pm
 Operating System: Windows 10
Re: Sample level npass filter
What about existing songs that are loop–friendly? What about generated noise?steve wrote:Normally one would process the audio before making the loop.Piotr Grochowski wrote:The purpose of the integer overflow for these filters is to allow seamless processing on loops.
Isn't it more convenient to have a loop–friendly effect in the first place?steve wrote: If you are starting with a seamless loop and you want to apply effects, then a useful technique is to to repeat the loop 2 times (total of three times, then apply the effects, then make a new loop from the middle 1/3rd. This technique works with most effects, without requiring specially modified effects.
With your percentage amplification effect written in Nyquist, it becomes possible to reproduce the sample–level n–pass filters and other n–pass filters that work by duplicating, shifting, amplifying and adding: duplicate the song to make it triple, shift the second song one sample to the left (or cut a sample from beginning and paste at the end for the loop–friendly variant), shift the third song one sample to the right (or cut a sample from the end and paste at the beginning for the loop–friendly veriant), amplify the first song to 50%, amplify the second and third songs to 25% and Mix And Render.
Re: Sample level npass filter
That depends on whether you expect someone else to convert the effects to "loop friendly" for you, or if you convert them yourself. If you expect someone to do it for you, you are likely to be waiting a very long time. If you do it yourself, then you may find it easier to apply effects either before making the loops, or after mixing down the looped track.Piotr Grochowski wrote:Isn't it more convenient to have a loop–friendly effect in the first place?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)