sfztools / sfizz

SFZ parser and synth c++ library, providing a JACK standalone client
https://sfz.tools/sfizz/
BSD 2-Clause "Simplified" License
418 stars 58 forks source link

Effects #73

Open jpcima opened 4 years ago

jpcima commented 4 years ago

Let's fill in some info regarding effects as we figure out the implementation and controls, on wiki as well as here.

jpcima commented 4 years ago

Add image: Bitred reference vs Oversampling 2x bitred2x

jpcima commented 4 years ago

Regarding the strings effect, see Simulation of piano sustain-pedal effect by parallel second-order filters

paulfd commented 4 years ago

For the Gibbs type effect on these, and also for LFOs synthesis, I recall something I studied at one point from this article right here. Searching back for it I found a master's thesis which might be more pedagogical in the approach. The required polynomials could possibly be tabulated.

I'll cross-post this in the LFO discussion.

jpcima commented 4 years ago

It seems another instance of the same processes used in music DSP, expressed in different ways. (you know, the usual :grin:) I list you a few refs that are oriented towards this problem. Minimum phase band limited step Polynomial band limited step Band limited ramp

I've also posted a plugin that contain some slightly improved implementations of these effects. (has a basic step function and oversampling) https://gitlab.com/jpcima/bitcrusher

jpcima commented 4 years ago

To elaborate on this matter of bitcrushing/lofi effects:

Anti-aliasing is not critical in these effects, they are a part of the tone. I have it, Cakewalk has it also. The thing is that antialising behavior is not controlled in such a way that both of effects match, you can hear a very evident tone difference between both, despite the waves more or less matching visually on the scope.

For now, the "big boss" of effects is the strings one. It'll be nice if RGC can provide info of what this one really is.

I suspect it to be in fact a convolution with a fixed IR signal. As I tested it on simple signals, the parameter strings_number did not seem to affect anything. The piano paper above links a webpage with a IR file of Steinway piano. http://research.spa.aalto.fi/publications/papers/dafx08-pedal/

(on this topic, there exist also an IR convolver effect in the lot, that accepts a sound file.)

jpcima commented 4 years ago

The strings effect is a sympathetic string resonator.

To make it, one has to instantiate N waveguide string oscillators in parallel. It's physical models which are tuned starting at the note C1 and up from there. There are as many of them as the opcode strings_number indicates, 36 being typical. strings_wet_onccN (0-100) sets the strength of resonance.

The dry signal is fed as excitation signal into the waveguide oscillator bank to make them generate, and then outputs are summed with the dry signal.

The harmonics have a more of less strong damping, so the input must not be applied equally, it must have its gain adapted by harmonic. Secondly, a sound should only strongly resonate with other strings which are harmonically related to its fundamental.

Jaffe 1983 Smith 1993

paulfd commented 4 years ago

I guess this is closed by #84 or do you want to keep it to track additional effects? This string resonator sounds interesting.

The harmonics have a more of less strong damping, so the input must not be applied equally, it must have its gain adapted by harmonic.

If I had to and without checking the state of the art, I would do string resonance by creating a "basis" of resonance for each note in the piano using their reference frequency, interpolate this over frequency, and then use the spectrogram as a impulse to act as a gain on the basis components.

jpcima commented 4 years ago

do you want to keep it to track additional effects?

Yes.

If I had to and without checking the state of the art, I would do string resonance by creating a "basis" of resonance for each note in the piano using their reference frequency, interpolate this over frequency, and then use the spectrogram as a impulse to act as a gain on the basis components.

It sounds an interesting idea. Do you want to extract this information based on existing piano sample sets?

alcomposer commented 4 years ago

srings is very much a piano resonance opcode.

It would be exciting to have in future either a custom_mode for strings or a strings_custom opcode, which would allow setting custom tuned frequencies of multiple waveguides. (To allow Sitar etc sort of resonance)

jpcima commented 4 years ago

Below are measurements of the disto effect for depth=0 (default) to depth=100. This is an amplitude transfer function. (with X input signal and Y the output)

It can be seen the function is symmetric but it works like a schmitt trigger. When the function goes over ±3/4 amplitude, it switches to the other curve. The steepness of this curve is varied by disto_depth.

Also there's a spiral effect at the start, which may have something to do with filtering part of this effect. (disto_tone 0-100)

dataset.zip

default depth=0 depth=25 depth=50 depth=75 depth=100

jpcima commented 4 years ago

I attach the disto curves, cleaned and both parts separated, to use it for curve fitting. Link of model to use: https://en.wikipedia.org/wiki/Generalised_logistic_function

disto-separated.tar.gz

jpcima commented 4 years ago

An initial curve fit with 3 parameters. Not too bad for a start. curvefit.py.gz curvefit2.py.gz

jpcima commented 4 years ago

Attaching the current experimental fverb fverb5.dsp.gz fverb4.dsp.gz fverb3.dsp.gz fverb2.dsp.gz

jpcima commented 4 years ago

We have 4 new entries recently

@paulfd, feel free examining any of these if you want

Regarding fverb, there remains to do:

ephemer commented 3 years ago

Hi @jpcima @paulfd, could you elaborate on how these effects are to be used in sfizz?

We are building sfizz as a standalone (non-VST etc.) library and would like to use the same set of (piano) samples in two ways: one with reverb with certain parameters and one without (or with different reverb parameters).

From what I saw in #84 these effects seem to be specified in the sfz file. Is there a way to add/alter them programatically as well via the public C/C++ API? If not, are there any examples you could point me to of how to correctly set up the parameters in the sfz file(s)? (The reverb effect in particular would be extremely useful).

paulfd commented 3 years ago

Hi, sorry I missed this comment. There is no way to add effects programmatically for now, although the OSC interface might be extended for this (if you feel like it you may do so !).

In an SFZ file, here is a very minimal example adding the fverb effect on the main bus.

<region>
    sample=*sine

<effect> 
    type=fverb
    reverb_input=100
    reverb_dry=100
    reverb_wet=10 

We could probably have better defaults for the reverb, but these will make it sound :) You can consult sfzformat.com for other effects and their opcodes. Right now there are no effect modulation but these will come.