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

26
LINES

< > BotCompany Repo | #1033265 // RenderFrequencySample_SquareWave

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

Transpiled version (4507L) is out of date.

sclass RenderFrequencySample_SquareWave extends Meta is RenderFrequencySample {
  public double get(Complex c, double frac) {
    double abs = c.abs();
    if (abs == 0) ret 0;
    frac = frac_nonNeg(frac + c.fracAngle());
    ret abs * (frac < .5 ? 1 : -1);
  }
  
  //@Override
  public void __subtractPeriodFrom(IAddPlateau audio, DoubleRange period, Complex intensity) {
    double goHigh = fracNonNeg(-intensity.fracAngle());
    double abs = intensity.abs();
    double goLow = fracNonNeg(goHigh+.5);
    double t1 = period.start, t2 = period.end, n = l(period);
    bool highFirst = goHigh < goLow;
    double min = min(goHigh, goLow), minPos = t1+min*n;
    double max = max(goHigh, goLow), maxPos = t1+max*n;
    double val = highFirst ? -abs : abs;
    if (metaGet("scaffolding") != null)
      printVars(+t1, +t2, +goHigh, +goLow, +abs, +minPos, +maxPos, +n);
    
    audio.subtractPlateau(t1, minPos,        val);
    audio.subtractPlateau(    minPos, maxPos, -val);
    audio.subtractPlateau(    maxPos, t2,    val);
  }
}

Author comment

Began life as a copy of #1033264

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033265
Snippet name: RenderFrequencySample_SquareWave
Eternal ID of this version: #1033265/20
Text MD5: cc7e52aaee9ab1a45ba0f7df28e6c669
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 10:45:40
Source code size: 1061 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 110 / 224
Version history: 19 change(s)
Referenced in: [show references]