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).

srecord noeq AudioHaarFeature(IAudioSample sample, double start, double end) {
  double factor = 1;
  bool alternatePhase; // sample 90° phase shift?
  
  *(IAudioSample *sample, DoubleRange r) {
    start = r.start;
    end = r.end;
  }

  double mid() { ret (start+end)/2; }
  
  double get(int channel) {
    double value;
    if (alternatePhase) {
      double
        quarter = start+(end-start)*.25,
        threeQuarters = start+(end-start)*.75;
        
      value =
           sample.sampleSum(channel, start, end)
         - sample.sampleSum(channel, quarter, threeQuarters)*2;
    } else {
      double mid = mid();
      value = sample.sampleSum(channel, start, mid)
            - sample.sampleSum(channel, mid, end);
    }
    ret mul_optFor1(factor, value);
  }
  
  Channels<Double> get() {
    ret mapChannels get(sample.channels());
  }

  Complex getComplex(int channel) {  
    alternatePhase = true;
    double re = get(channel);
    alternatePhase = false;
    double im = get(channel);
    ret complex(re, im);
  }

  Channels<Complex> getComplex() {
    ret mapChannels getComplex(sample.channels());
  }
}

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: 139 / 269
Version history: 10 change(s)
Referenced in: [show references]