Hola, yes of course. The class that I have in another tab is right here below, here it goes:
import ddf.minim.*;
import ddf.minim.ugens.*;
Minim minim;
AudioOutput out;
SeisData seisData;
float freqValues;
void setup() {
size(640, 360, P3D);
seisData = new SeisData();
seisData.loadData();
minim = new Minim(this);
out = minim.getLineOut(Minim.STEREO, 2048);
}
void draw() {
background(0);
stroke(255);
seisData.iterate(); //Calling iteration/timing method from object(contains i)
println(seisData.i); //When I run println(i) from here I get crazy timing/ iteration
float freqValuesLoaded = seisData.freqValuesLoaded;
freqValues = freqValuesLoaded;
ToneInstrument myNote = new ToneInstrument(freqValues, 0.5, out);
println(seisData.i);
out.playNote(0.5, 2.6, myNote);
}
class SeisData { // Start of class
Table seisCsv;
TableRow row;
float freqValues;
float freqValuesLoaded;
boolean load = true;
int i = 0;
float interval = 5000; // I used this long interval to verify more easily the timing function.
long timer;
SeisData() {
}
public void loadData() {
seisCsv = loadTable("CU.SDDR.1_HOUR_BHZ.ascii_SLIST.csv", "header");
}
void iterate() {
if (seisCsv==null) return;
timer = 0;
if (millis() - timer > interval ) {
timer = millis();
i++; //When I run println(i) from here I get correct timing.
load=true;
}
if (load) {
TableRow row = seisCsv.getRow(i);
freqValuesLoaded = row.getFloat(0);
load = false;
}
}
}
class ToneInstrument implements Instrument // Start of Instrument class
{
Oscil sineOsc;
Oscil fm;
AudioOutput out;
// constructors for this instrument
ToneInstrument( float frequency, float amplitude, AudioOutput output ) {
// equate class variables to constructor variables as necessary
out = output;
// create new instances of any UGen objects as necessary
sineOsc = new Oscil( frequency, amplitude, Waves.SINE); //sine aqui
fm = new Oscil(10, 0.3, Waves.TRIANGLE); //tri aqui ( 10, 2, Waves.SINE ) ex: frequencyModulation
fm.offset.setLastValue(40); //have to adjust values was 10 was 40 was 15
fm.patch(sineOsc.frequency);
}
// every instrument must have a noteOn( float ) method
void noteOn( float dur ) {
// and patch to the output
sineOsc.patch( out );
}
// every instrument must have a noteOff() method
void noteOff() {
// and unpatch the output
// this causes the entire instrument to stop calculating sampleframes
// which is good when the instrument is no longer generating sound.
sineOsc.unpatch( out );
fm.unpatch( out);
}
}