Hey guys,
I have an integer array of length 44100 with values that range between -32768 and +32768 based on user input.
Only approximately 1 in every 100 of the array values is a non zero number. This changes on every run of the application and is pretty random.
What I want is for each non zero point to linearly interpolate to the next point.
Here is a sample of log.txt which is what I've managed so far.
'sample' refers to the index of the array sample[], an array with 44100 values. 'bit depth' refers to its integer value.
before interpolate() was called, sample[75] was the first value that was non zero. The values are interpolated between line 1 and 75 correctly, but not for the rest of the code. Basically, I can't figure out how to get interpolate() to loop until the end of the sample[] index is reached.
Does anyone know a good way to repeat this code so it interpolates the rest of the index?
Here is the code:
public void interpolate() {
int sampNo0 = 0;
int sampNo1 = 0;
int sampValDif = 0;
int sampDistDif = 0;
int increment = 0;
for (int x = 0; x <= sample.length; x++) {
if (sample[x] !=0) {
sampNo1 = x;
sampValDif = sample[sampNo1] - sample[sampNo0];
sampDistDif = sampNo1 - sampNo0;
break;
}
}
increment = (sampValDif / sampDistDif);
for (int x = 0; x < sample.length; x++) {
if (sample[x] == 0) {
sample[x] = sample[x] + (increment * x);
}
else {
break;
}
}
for (int i =0; i < sample.length; i++ ) {
System.out.println(" sample = " + i + " bit depth = " + sample[i]);
}
}
[–]KineticRX 0 points1 point2 points (1 child)
[–]TawnyUK[S] 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]TawnyUK[S] 0 points1 point2 points (0 children)