Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

70
LINES

< > BotCompany Repo | #1033276 // audioRestorationDemo_v1

JavaX fragment (include) [tags: use-pretranspiled]

Uses 11894K of libraries. Click here for Pure Java version (20968L/136K).

1  
svoid audioRestorationDemo_v1() {
2  
  S text =
3  
    //"please tell me something nice";
4  
    "you can almost understand this now";
5  
  bool sine = false;
6  
  
7  
  double seconds = 1.0;
8  
  new ContinuousOscillators_TestAudioRestoration test;
9  
  test.showImage(true);
10  
  var co = test.co;
11  
  S waveName;
12  
  test.separateFrequencies(true);
13  
  test.separateRealAndImag(false);
14  
  test.cumulative(true);
15  
  co.renderUsingSine = false;
16  
  
17  
  if (sine) {
18  
    test.setAudio(seconds, new SineSoundSource(440.0, test.inputSampleRate));
19  
    //if (true) ret;
20  
    waveName = "sine";
21  
  } else {
22  
    test.loadMP3(new GSay(text).audioFile());
23  
    waveName = text;
24  
  }
25  
  
26  
  //test.co.setFrequencies(pianoFrequencies88());
27  
  test.co.setFrequencies(map toFrequency(geometricIterator(55.0, test.inputSampleRate, 2.0)));
28  
  test.silence = 0.01;
29  
  //test.minFreq = 440;
30  
  //test.maxFreq = 440*4;
31  
  test.wavOut = javaxDataDir("Restored Audio/" + waveName + ".restored." + (test.co.renderUsingSine ? "sine" : "square") + ".wav");
32  
  test.run();
33  
  
34  
  /*
35  
  double interval = co.sampleRate/880;
36  
  print(+interval);
37  
  int n = 3;
38  
  L<Double> period = map(x -> x/32767.0, asList(takeFirst(iceil(interval*n), test.resampled)));
39  
  L<Average> partSum = AutoCreateList(Average);
40  
  for i over period: {
41  
    var sample = period.get(i);
42  
    int part = ifloor(i/interval*4);
43  
    var sum = partSum.get(part);
44  
    sum.add(sample);
45  
    printVars(+i, +part, sample := formatDouble2(sample), sum := formatDouble2(sum!));
46  
  }
47  
  pnl(partSum);
48  
  
49  
  for (int i = 0; i+3 < l(partSum); i += 4) {
50  
    double[] vals = new[2];
51  
    for phase to 2: {
52  
      double a = partSum.get(i+((4-phase)&3))!;
53  
      double b = partSum.get(i+((5-phase)&3))!;
54  
      double c = partSum.get(i+((6-phase)&3))!;
55  
      double d = partSum.get(i+((7-phase)&3))!;
56  
    
57  
      printVars(+a, +b, +c, +d);
58  
      double hi = avg(a, b), lo = avg(c, d);
59  
      double val = hi-lo;
60  
      vals[phase] = val;
61  
      print("i=" + i + ", phase " + phase + ": " + formatDouble2(hi) + " - " + formatDouble2(lo) + " = " + formatDouble2(val));
62  
    }
63  
    print("c=" + renderComplexWithAngle(complex(vals)));
64  
  }
65  
  */
66  
  
67  
  // test linear interpolation
68  
  /*for (t : countIterator(0.0, 2.0, 0.1))
69  
    print(t + "=" + co.audio.sampleSum(0, 0, t));*/
70  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): bhatertpkbcr, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033276
Snippet name: audioRestorationDemo_v1
Eternal ID of this version: #1033276/2
Text MD5: 8b6b1b80b33ca8f58082d5a4855da1c9
Transpilation MD5: 34dac4f4c8a29128997aac594a187719
Author: stefan
Category: javax / audio analysis
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-18 05:11:30
Source code size: 2300 bytes / 70 lines
Pitched / IR pitched: No / No
Views / Downloads: 63 / 97
Version history: 1 change(s)
Referenced in: [show references]