I’m using the processing.sound library to make a synth,
but when I use the “this” keyword it gives me an error:
The constructor "SinOsc(Timbre)" does not exist
MCVE
import processing.sound.*;
class Timbre {
  SinOsc freqF;
  Timbre() {
    freqF = new SinOsc(this);
  }
}
Timbre sound;
void setup() {
  sound = new Timbre();
}
Code
class Timbre {
  float harmU;
  float harmD;
  float harmT;
  float harmQ;
  SinOsc freqF;
  SinOsc freqU;
  SinOsc freqD;
  SinOsc freqT;
  SinOsc freqQ;
  Timbre(float U, float D, float T, float Q) {
    harmU = U;
    harmD = D;
    harmT = T;
    harmQ = Q;
    freqF = new SinOsc(this);
    freqU = new SinOsc(this);
    freqD = new SinOsc(this);
    freqT = new SinOsc(this);
    freqQ = new SinOsc(this);
  }
  void playFreq(float freq) {
    freqF.set(freq, 1, 0, 0);
    freqU.set(freq*harmU, 1/harmU, 0, 0);
    freqD.set(freq*harmD, 1/harmD, 0, 0);
    freqT.set(freq*harmT, 1/harmT, 0, 0);
    freqQ.set(freq*harmQ, 1/harmQ, 0, 0);
    freqF.play();
    freqU.play();
    freqD.play();
    freqT.play();
    freqQ.play();
  }
  void stopFreq(float freq) {
    freqF.stop();
    freqU.stop();
    freqD.stop();
    freqT.stop();
    freqQ.stop();
  }
}
import processing.sound.*;
Timbre sound;
void setup() {
  sound = new Timbre(2,3,4,5,);
  sound.playFreq(440);
}
Please send help
PS: I’ve tried the following code too:
Extra
import processing.sound.*;
class Timbre {
  SinOsc freqF;
  Timbre(Object sketch) {
    freqF = new SinOsc(sketch);
  }
}
Timbre sound;
void setup() {
  sound = new Timbre(this);
}
And this:
Extra 2
import processing.sound.*;
class Timbre {
  SinOsc freqF;
  Timbre(SinOsc tmp) {
    freqF = tmp;
  }
}
SinOsc tmp = new SinOsc(this);
Timbre sound;
void setup() {
  sound = new Timbre(tmp);
}
Note that the second one doesn’t error, but it doesn’t play any sound.