faustlibraries icon indicating copy to clipboard operation
faustlibraries copied to clipboard

CZ Oscillators: add anti-aliased versions

Open magnetophon opened this issue 4 years ago • 8 comments

Is there any way to decrease the amount of repeated text, mostly in the comments?

magnetophon avatar Dec 17 '20 20:12 magnetophon

The current fund2freq implementation doesn't update when the fund jumps. I wrote an algorithm to avoid that, but I'm not sure if there's enough benefit to warrant the added complexity.

fund2freq(fund) = delta*ma.SR
with {
  rawDelta = fund-fund';
  absDelta = abs(rawDelta);
  jump = absDelta>0.5;
  posDelta =  select2(jump,absDelta,1-absDelta);
  delta = posDelta*select2(isPos,-1,1);
  isPos = (rawDelta>=0)
          <: select2( jump, _, (1-_) );
};

magnetophon avatar Dec 18 '20 00:12 magnetophon

Any news on this?

magnetophon avatar Apr 13 '21 14:04 magnetophon

Do you have any example code, showing the anti-aliased effect ? Any picture?

sletz avatar Apr 13 '21 20:04 sletz

I tested by ear.

Should I write some code that does a sweep and then make a screenshot of the spectrum?

magnetophon avatar Apr 13 '21 21:04 magnetophon

Yes this could be great.

sletz avatar Apr 13 '21 21:04 sletz

In case it's useful, here is the test program I wrote for the existing alias-suppressed sawtooth oscillators and their derivatives:

// bandlimited sawtooth tests
ol = library("oscillators.lib");
ba = library("basics.lib");
amp = 1;
freq = 100;
process = par(i,6,i*0.1+ol.sawN(i+1,freq));
// Use faust2octave to look at 20*log10(abs(fft(faustout)))'

josmithiii avatar Apr 14 '21 05:04 josmithiii

@josmithiii Thanks, but I don't get it. Isn't that just 6 detuned saws at about 100Hz? How does that help to show anti-aliassing?

magnetophon avatar Apr 14 '21 06:04 magnetophon

Here is an example together with the spectrum from Octave (it's GIF but GitHub is complaining about it - will try again if it's no good):

amp = 1;
freq = 1200;
//offset = 0.1; // for visual separation in time domain
offset = 0;
process = par(i,6,i*offset+ol.sawN(i+1,freq));

tsaw

josmithiii avatar Apr 14 '21 07:04 josmithiii