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

45
LINES

< > BotCompany Repo | #1032988 // AudioHaarFeature

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

Libraryless. Click here for Pure Java version (6347L/37K).

1  
srecord noeq AudioHaarFeature(IAudioSample sample, double start, double end) {
2  
  double factor = 1;
3  
  bool alternatePhase; // sample 90° phase shift?
4  
  
5  
  *(IAudioSample *sample, DoubleRange r) {
6  
    start = r.start;
7  
    end = r.end;
8  
  }
9  
10  
  double mid() { ret (start+end)/2; }
11  
  
12  
  double get(int channel) {
13  
    double value;
14  
    if (alternatePhase) {
15  
      double
16  
        quarter = start+(end-start)*.25,
17  
        threeQuarters = start+(end-start)*.75;
18  
        
19  
      value =
20  
           sample.sampleSum(channel, start, end)
21  
         - sample.sampleSum(channel, quarter, threeQuarters)*2;
22  
    } else {
23  
      double mid = mid();
24  
      value = sample.sampleSum(channel, start, mid)
25  
            - sample.sampleSum(channel, mid, end);
26  
    }
27  
    ret mul_optFor1(factor, value);
28  
  }
29  
  
30  
  Channels<Double> get() {
31  
    ret mapChannels get(sample.channels());
32  
  }
33  
34  
  Complex getComplex(int channel) {  
35  
    alternatePhase = true;
36  
    double re = get(channel);
37  
    alternatePhase = false;
38  
    double im = get(channel);
39  
    ret complex(re, im);
40  
  }
41  
42  
  Channels<Complex> getComplex() {
43  
    ret mapChannels getComplex(sample.channels());
44  
  }
45  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032988
Snippet name: AudioHaarFeature
Eternal ID of this version: #1032988/11
Text MD5: dbf63746263405820a510e33ded6de1d
Transpilation MD5: f1fbcbba9284551f34bdf318f1cde01a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-18 03:13:20
Source code size: 1175 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 203 / 362
Version history: 10 change(s)
Referenced in: [show references]