svoid audioRestorationDemo_v1() { S text = //"please tell me something nice"; "you can almost understand this now"; bool sine = false; double seconds = 1.0; new ContinuousOscillators_TestAudioRestoration test; test.showImage(true); var co = test.co; S waveName; test.separateFrequencies(true); test.separateRealAndImag(false); test.cumulative(true); co.renderUsingSine = false; if (sine) { test.setAudio(seconds, new SineSoundSource(440.0, test.inputSampleRate)); //if (true) ret; waveName = "sine"; } else { test.loadMP3(new GSay(text).audioFile()); waveName = text; } //test.co.setFrequencies(pianoFrequencies88()); test.co.setFrequencies(map toFrequency(geometricIterator(55.0, test.inputSampleRate, 2.0))); test.silence = 0.01; //test.minFreq = 440; //test.maxFreq = 440*4; test.wavOut = javaxDataDir("Restored Audio/" + waveName + ".restored." + (test.co.renderUsingSine ? "sine" : "square") + ".wav"); test.run(); /* double interval = co.sampleRate/880; print(+interval); int n = 3; L period = map(x -> x/32767.0, asList(takeFirst(iceil(interval*n), test.resampled))); L partSum = AutoCreateList(Average); for i over period: { var sample = period.get(i); int part = ifloor(i/interval*4); var sum = partSum.get(part); sum.add(sample); printVars(+i, +part, sample := formatDouble2(sample), sum := formatDouble2(sum!)); } pnl(partSum); for (int i = 0; i+3 < l(partSum); i += 4) { double[] vals = new[2]; for phase to 2: { double a = partSum.get(i+((4-phase)&3))!; double b = partSum.get(i+((5-phase)&3))!; double c = partSum.get(i+((6-phase)&3))!; double d = partSum.get(i+((7-phase)&3))!; printVars(+a, +b, +c, +d); double hi = avg(a, b), lo = avg(c, d); double val = hi-lo; vals[phase] = val; print("i=" + i + ", phase " + phase + ": " + formatDouble2(hi) + " - " + formatDouble2(lo) + " = " + formatDouble2(val)); } print("c=" + renderComplexWithAngle(complex(vals))); } */ // test linear interpolation /*for (t : countIterator(0.0, 2.0, 0.1)) print(t + "=" + co.audio.sampleSum(0, 0, t));*/ }