This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| getting_started_vividshaper [2026/09/09 20:35] – [Math functions] lars | getting_started_vividshaper [2026/09/09 21:00] (current) – [Filter functions] lars | ||
|---|---|---|---|
| Line 312: | Line 312: | ||
| ===== Filter functions ===== | ===== Filter functions ===== | ||
| + | There are three different filters available in VividShaper: | ||
| - | The lowpass/ | + | These can either be applied on the actual waveform |
| <code Lua> | <code Lua> | ||
| - | wave[x] | + | filter1 |
| + | filter2 = VSBandpass(cutoffFreq, | ||
| + | filter3 = VSHighpass(cutoffFreq, | ||
| </ | </ | ||
| - | It can be quite difficult | + | If you want to apply the lowpass filter on the actual waveform, you will do this with the VSBiquad function: |
| <code Lua> | <code Lua> | ||
| - | biquadcoeff | + | wave[1] |
| - | biquadcoeff = VSBandpass(cutoffFreq, | + | |
| - | biquadcoeff = VSHighpass(cutoffFreq, | + | |
| </ | </ | ||
| - | A very important thing is that you need to provide each of these helper functions with the current note. If you play a note at a low frequency, you may actually play under the cutoffFreq so that no filter should be applied at all for a lowpass filter. That means the filter effect on the wave depends not only on the cutoff frequency and the resonance, but also on the playback frequency (i.e. the note). | + | Since this filter |
| - | A full example comes here: | + | The other method is to use the filter as an insert effect, processing the oscillator output continuously. In this case, the filter retains its state from one waveform cycle to the next. This is particularly important for resonance: instead of being baked into a single repeating waveform, the resonant response can build up and ring across successive cycles, producing a more dynamic filter response over time. |
| + | |||
| + | Say we want to apply the highpass-filter above as an insert on oscillator 1. Then we will write it like this: | ||
| + | |||
| + | <code Lua> | ||
| + | afilter[1] = filter3 | ||
| + | </ | ||
| + | |||
| + | You can even combine the two methods. Say you first filter the wave with a lowpass filter, then you apply the bandpass filter as an insert: | ||
| + | |||
| + | <code Lua> | ||
| + | filter1 = VSLowpass(cutoffFreq, | ||
| + | filter2 = VSBandpass(cutoffFreq, | ||
| + | wave[1] = VSBiquad(wave[1], | ||
| + | afilter[1] = filter2 | ||
| + | </ | ||
| + | |||
| + | You can even apply the same filter twice: | ||
| + | |||
| + | <code Lua> | ||
| + | filter1 = VSLowpass(cutoffFreq, | ||
| + | wave[1] = VSBiquad(wave[1], | ||
| + | afilter[1] = filter1 | ||
| + | </ | ||
| + | |||
| + | Both the waveform and the insert filters VividSynths are biquad filters. A biquad filter consists of five different coefficients and depending on how you set them you can create either a lowpass, bandpass, or a highpass filter. The different filter functions return an array with 11 values. The first five values are used by the waveform filter (i.e. VSBiquad()) and the second five values are used by the insert filter. The final value is just a value to turn on or off the insert filter (0 or 1). You don't really need to understand how this works since the filter functions calculate the biquad parameters for us. | ||
| + | |||
| + | In previous versions, you also needed to provide the current note to the filter, like this: | ||
| + | |||
| + | <code Lua> | ||
| + | filter1 = VSLowpass(cutoffFreq, | ||
| + | </ | ||
| + | |||
| + | From v2.0, you don't have to do that any longer, as notein is default. However, you can still provide a note value to obtain the effect of a filter that follows the note in terms of the cutoff-frequency: | ||
| + | |||
| + | |||
| + | <code Lua> | ||
| + | filter1 = VSLowpass(cutoffFreq, | ||
| + | </ | ||
| + | |||
| + | A full example comes here for how to apply the waveform filter: | ||
| <code Lua> | <code Lua> | ||
| -- Patch: Filter example | -- Patch: Filter example | ||
| wave[1] = VSSaw(1,0) | wave[1] = VSSaw(1,0) | ||
| - | vol[1] = VSADSRE(1, | + | vol[1] = VSADSRE(1, |
| - | biquadcoeff = VSLowpass(300, | + | biquadcoeff = VSLowpass(300, |
| wave[1] = VSBiquad(wave[1], | wave[1] = VSBiquad(wave[1], | ||
| </ | </ | ||