Transpiled version (4507L) is out of date.
1 | sclass RenderFrequencySample_SquareWave extends Meta is RenderFrequencySample { |
2 | public double get(Complex c, double frac) { |
3 | double abs = c.abs(); |
4 | if (abs == 0) ret 0; |
5 | frac = frac_nonNeg(frac + c.fracAngle()); |
6 | ret abs * (frac < .5 ? 1 : -1); |
7 | } |
8 | |
9 | //@Override |
10 | public void __subtractPeriodFrom(IAddPlateau audio, DoubleRange period, Complex intensity) { |
11 | double goHigh = fracNonNeg(-intensity.fracAngle()); |
12 | double abs = intensity.abs(); |
13 | double goLow = fracNonNeg(goHigh+.5); |
14 | double t1 = period.start, t2 = period.end, n = l(period); |
15 | bool highFirst = goHigh < goLow; |
16 | double min = min(goHigh, goLow), minPos = t1+min*n; |
17 | double max = max(goHigh, goLow), maxPos = t1+max*n; |
18 | double val = highFirst ? -abs : abs; |
19 | if (metaGet("scaffolding") != null) |
20 | printVars(+t1, +t2, +goHigh, +goLow, +abs, +minPos, +maxPos, +n); |
21 | |
22 | audio.subtractPlateau(t1, minPos, val); |
23 | audio.subtractPlateau( minPos, maxPos, -val); |
24 | audio.subtractPlateau( maxPos, t2, val); |
25 | } |
26 | } |
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: | 215 / 374 |
Version history: | 19 change(s) |
Referenced in: | [show references] |