Re: [LAD] Click-free fade-in algorithm for synths?

2019-09-25 Thread Neil C Smith
On Tue, 24 Sep 2019 at 19:38, Johannes Lorenz  wrote:
>
> A note-on event can lead to clicks in synths, which is often fixed by a
> fade-in algorithm.

No idea if it's useful in this case, or whether it duplicates anything
anyone else has said, but I use a form of the switch-and-ramp idea by
Miller Puckette to handle discontinuities in hot-swapped DSP code.

http://msp.ucsd.edu/techniques/latest/book-html/node63.html

Best wishes,

Neil

-- 
Neil C Smith
Artist & Technologist
www.neilcsmith.net

PraxisLIVE - hybrid visual live programming
for creatives, for programmers, for students, for tinkerers
www.praxislive.org
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] Click-free fade-in algorithm for synths?

2019-09-25 Thread lacuna_
 

let me correct:

 

 
>>For counting / finding zero-X it's simply this:  
>> if {sample[now]*sample[before]==negative

if {sample[now]*sample[before]<=0
 

 



Gesendet: Mittwoch, 25. September 2019 um 15:10 Uhr
Von: lacu...@gmx.net
An: "Johannes Lorenz" 
Cc: linux-audio-dev@lists.linuxaudio.org
Betreff: Re: [LAD] Click-free fade-in algorithm for synths?




>> For example, in zynaddsubfx, we count the ascending zero crossings and
>> calculate the fade-in length upon it [1]. Then, an S-curve of that
>> length is multiplied with the signal. Counting zero crossings prevents
>> clicking on lower notes, and it makes higher notes more punchy.

 

You are experiencing different phenomena:


- Groove: by dividing / multiplying frequencies to rhythm, envelope-times ect. - it just grooves.
In fact this is a very basic part of Electronic Dance Music.

- On lower notes the envelope might be slow here = no clicking
- Did you try syncing the oscillator with the note-on trigger? this gives a consistent "punch" and you can start it at 0, -1, +1, whatever - your choice.
Free running oscillators are more "groovy" and "alive".
- "Punch" is archived with the hold-stage in an AHDSR-envelope. Minimoog has that, - it overdrives the envelope, which rersults in a plateu.


For counting / finding zero-X it's simply this:  
 if {sample[now]*sample[before]==negative

Of course the result depends very much on the resolution (samplewise and bitwise).
Small buffersizes shouldn't be any problem anyway!? But yes for counting you have to wait, find and count.

Actually you do know the count of zerocrossings, as you know the frequency the oscillator swings!? So you don't have to mesure it!


Interesting topic... what are you working on? What is your goal?

 

 

Gesendet: Dienstag, 24. September 2019 um 20:38 Uhr
Von: "Johannes Lorenz" 
An: linux-audio-dev@lists.linuxaudio.org
Betreff: [LAD] Click-free fade-in algorithm for synths?

A note-on event can lead to clicks in synths, which is often fixed by a
fade-in algorithm.

If the attack rate for a synth's signal is 0, the synth shall not click,
and still fade in as fast as possible. What is the best algorithm for
fading in a signal, that scales also with small buffersizes, like 32
samples per buffer (at 44100 samples/s)?

For example, in zynaddsubfx, we count the ascending zero crossings and
calculate the fade-in length upon it [1]. Then, an S-curve of that
length is multiplied with the signal. Counting zero crossings prevents
clicking on lower notes, and it makes higher notes more punchy. That
algorithm works very well for a buffersize of 256 samples (at 44100
samples/s), but it fails at 32 samples (since the zero crossings of 32
samples are often not representive).

Any papers, or experience with other synths? We currently need a good
solution for (at least) zynaddsubfx and the triple oscillator in LMMS.


Links:
[1]
https://github.com/zynaddsubfx/zynaddsubfx/blob/4e36e765f677dbc689461889e502d015c22966a5/src/Synth/ADnote.cpp#L1202-L1222
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev




 

 

___ Linux-audio-dev mailing list Linux-audio-dev@lists.linuxaudio.org https://lists.linuxaudio.org/listinfo/linux-audio-dev



___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] Click-free fade-in algorithm for synths?

2019-09-25 Thread lacuna_

>> For example, in zynaddsubfx, we count the ascending zero crossings and
>> calculate the fade-in length upon it [1]. Then, an S-curve of that
>> length is multiplied with the signal. Counting zero crossings prevents
>> clicking on lower notes, and it makes higher notes more punchy.

 

You are experiencing different phenomena:


- Groove: by dividing / multiplying frequencies to rhythm, envelope-times ect. - it just grooves.
In fact this is a very basic part of Electronic Dance Music.

- On lower notes the envelope might be slow here = no clicking
- Did you try syncing the oscillator with the note-on trigger? this gives a consistent "punch" and you can start it at 0, -1, +1, whatever - your choice.
Free running oscillators are more "groovy" and "alive".
- "Punch" is archived with the hold-stage in an AHDSR-envelope. Minimoog has that, - it overdrives the envelope, which rersults in a plateu.


For counting / finding zero-X it's simply this:  
 if {sample[now]*sample[before]==negative

Of course the result depends very much on the resolution (samplewise and bitwise).
Small buffersizes shouldn't be any problem anyway!? But yes for counting you have to wait, find and count.

Actually you do know the count of zerocrossings, as you know the frequency the oscillator swings!? So you don't have to mesure it!


Interesting topic... what are you working on? What is your goal?

 

 

Gesendet: Dienstag, 24. September 2019 um 20:38 Uhr
Von: "Johannes Lorenz" 
An: linux-audio-dev@lists.linuxaudio.org
Betreff: [LAD] Click-free fade-in algorithm for synths?

A note-on event can lead to clicks in synths, which is often fixed by a
fade-in algorithm.

If the attack rate for a synth's signal is 0, the synth shall not click,
and still fade in as fast as possible. What is the best algorithm for
fading in a signal, that scales also with small buffersizes, like 32
samples per buffer (at 44100 samples/s)?

For example, in zynaddsubfx, we count the ascending zero crossings and
calculate the fade-in length upon it [1]. Then, an S-curve of that
length is multiplied with the signal. Counting zero crossings prevents
clicking on lower notes, and it makes higher notes more punchy. That
algorithm works very well for a buffersize of 256 samples (at 44100
samples/s), but it fails at 32 samples (since the zero crossings of 32
samples are often not representive).

Any papers, or experience with other synths? We currently need a good
solution for (at least) zynaddsubfx and the triple oscillator in LMMS.


Links:
[1]
https://github.com/zynaddsubfx/zynaddsubfx/blob/4e36e765f677dbc689461889e502d015c22966a5/src/Synth/ADnote.cpp#L1202-L1222
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev




 

 
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] Click-free fade-in algorithm for synths?

2019-09-25 Thread Fons Adriaensen
On Tue, Sep 24, 2019 at 08:38:19PM +0200, Johannes Lorenz wrote:

> For example, in zynaddsubfx, we count the ascending zero crossings and
> calculate the fade-in length upon it [1]. Then, an S-curve of that length is
> multiplied with the signal. Counting zero crossings prevents clicking on
> lower notes, and it makes higher notes more punchy. That algorithm works
> very well for a buffersize of 256 samples (at 44100 samples/s), but it fails
> at 32 samples (since the zero crossings of 32 samples are often not
> representive).

That could be a good method, but why should this (or anything a synth 
does) depend on period size ? Implementation may be a bit simpler if
it does, but that's poor excuse (IMHO :-)...

Ciao,

-- 
FA


___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] Click-free fade-in algorithm for synths?

2019-09-25 Thread Fons Adriaensen
On Tue, Sep 24, 2019 at 02:26:53PM -0600, Paul Davis wrote:
 
> There's fundamentally no such thing as a zero crossing. You might have two
> samples on either side of zero, but you still don't have a sample *at*
> zero, so in the general case, truncating one of them to zero and
> starting/ending there is still going to give you distortion and/or noise.
> Obviously there may be cases where one of them is close enough to zero for
> this not to be be an issue, but it's not a general method.

Even if you would have an exact zero sample, that would not avoid a
click. It would only ensure that the click has a 1/f^2 spectrum
instead of 1/f (so it would contain less HF).

From a synth I'd expect a controllable and precisely defined fade-in,
not something that tries to be clever. If the fade-in time has to
depend on frequency (it usually does if the frequency can change over
a large range), that should be programmable or 'voltage controlled'
just as anything else.

Ciao,

-- 
FA

___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev


Re: [LAD] Click-free fade-in algorithm for synths?

2019-09-25 Thread Will J Godfrey
On Tue, 24 Sep 2019 19:12:47 -0400
Tim  wrote:

>On 9/24/19 4:26 PM, Paul Davis wrote:
>> 
>> 
>> On Tue, Sep 24, 2019 at 12:38 PM Johannes Lorenz > > wrote:
>> 
>> Counting zero crossings prevents
>> clicking on lower notes, and it makes higher notes more punchy.
>> 
>> 
>> There's fundamentally no such thing as a zero crossing. You might have 
>> two samples on either side of zero, but you still don't have a sample 
>> *at* zero, so in the general case, truncating one of them to zero and 
>> starting/ending there is still going to give you distortion and/or 
>> noise. Obviously there may be cases where one of them is close enough to 
>> zero for this not to be be an issue, but it's not a general method.
>> Ardour applies declick fades every time the transport starts and stops. 
>> You can read about how we do it here:
>> 
>> https://github.com/Ardour/ardour/blob/master/libs/ardour/ardour/disk_reader.h#L135
>> https://github.com/Ardour/ardour/blob/master/libs/ardour/disk_reader.cc#L1445
>> https://github.com/Ardour/ardour/blob/master/libs/ardour/amp.cc#L163  
>
>Hi Paul. Thanks, I was going to mention that.
>
>We had a similar conversation a few years ago when I was adding
>  anti-zipper noise to MusE, and I inquired about zero-crossing methods.
>
>I replied that TV and amplifier electronic volumes use zero-crossing,
>  so why not use it?
>
>But I conceded the very point you mention above, ie. where exactly is
>  the crossing point.
>And it is dependent on frequency so you get a different attack result
>  each time.
>
>In a TV or amp volume chip it's OK but here, meh...
>
>So in the end, looking at the code given above, I can see I did much
>  the exact same thing as Ardour, using a fixed coefficient value
>  driven by time passage (sample rate).
>
>Cheers.
>Tim.


Just like to add, that on a complex waveform with a strong harmonic content it's
quite likely to cross the zero point 2-3 times during each cycle of the
fundamental.

-- 
It wasn't me! (Well actually, it probably was)

... the hard part is not dodging what life throws at you,
but trying to catch the good bits.
___
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
https://lists.linuxaudio.org/listinfo/linux-audio-dev