Setting frequency in Minim

Hi, I don't know how to change the frequency of a given Oscil. Can anybody help me guess how? Thanx. The code:

import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.ugens.*; 

Minim minim;

AudioOutput out;
Oscil myOscil;

void setup()
{
  size(300, 300);  

  minim = new Minim(this);

   out = minim.getLineOut(Minim.STEREO, 512); 
   myOscil = new Oscil( 220, 0.3, Waves.SINE );
   myOscil.patch(out);
}

void draw()
{
  background(0); 
}


void keyPressed()
{
  switch(key) {
    case '1': myOscil.setFreq(+10); break;
    case '2': myOscil.setFreq(-10);; break;
  }
}

void stop()
{
  out.close();
  minim.stop();  
  super.stop();
}
Tagged:

Answers

  • Excuse me, I didn´t explain that what I wanted was to increase and decrease the frequency of the wave by pressing the key 1 and the key 2. Thanx.

Sign In or Register to comment.