I'm trying to build a synthdef that somewhat models the frequency response of my flute. To do this I play my flute using {SoundIn.ar(0)}.scope to determine the spectrum. As it turns out, it looks a lot like a sawtooth, so I get reasonable output with a fairly simple sawtooth and a bandpass filter. But, I wanted to get closer by using an additive synth with sine waves. The problem is that the spectrum of the real flute varies with respect to the note I'm playing. Playing around with that I've come up with a reasonable approximation of the amplitudes of the sine waves required. I did all this using constants as my frequency input and comparing the scope of the model to the scope of the same frequency on the flute. Here's the model:
{
var n = 10;
var freq = 260; // change this value to mock different notes from the flute
var cutoff_freq1 = 300;
var wave = Mix.fill(10,{|i|
var mult;
var div = 0.5;
case
{i == 1} {div = 1}
{and(i == 3, freq >= cutoff_freq1)} {div = 0.5}
{and(i == 3, freq < cutoff_freq1)} {div = 0.2}
{and(i == 4, freq >= cutoff_freq1)} {div = 0.1}
{and(i == 4, freq < cutoff_freq1)} {div = 0.4}
{i > 4} {div = 0.02};
mult= ((-1)**i)*(div/((i+1)));
SinOsc.ar(freq*(i+1))*mult
});
Mix.ar(wave/n);
}.scope;
i is the harmonic number. Thus, I'm creating a sawtooth, but with some of the harmonic's amplitudes modified based on the frequency of the root note.
Given that I was happy with this model I wanted to implement it as a synthdef. The freq and sig inputs are bus numbers. The problem is that when I try to instantiate it, I get the error: "ERROR: Non Boolean in test" in which it points to the first of the comparisons of fr >= cutoff_freq. I assume it's because I'm trying to compare a control signal (fr) to a constant (cutoff_freq1).
SynthDef("flute", {arg freq = 55, sig = 65;
var fr = In.kr(freq);
var n = 12;
var cutoff_freq1 = 300;
var wave = Mix.fill(n,{|i|
var mult;
var div = 0.5;
case
{i == 1} {div = 1}
{and(i == 3, fr >= cutoff_freq1)} {div = 0.5}
{and(i == 3, fr < cutoff_freq1)} {div = 0.2}
{and(i == 4, fr >= cutoff_freq1)} {div = 0.1}
{and(i == 4, fr < cutoff_freq1)} {div = 0.4}
{i > 4} {div = 0.02};
mult= ((-1)**i)*(div/((i+1)));
SinOsc.ar(fr*(i+1))*mult
});
Out.ar(sig, Mix.ar(wave/n));
})
So, two questions: 1) is this the right way to go about doing this?, 2) if so, how can I compare the input frequency against a cutoff value?
Regards,
Bill
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.