Libraryless. Click here for Pure Java version (4749L/27K).
interface RenderFrequencySample { public default double get aka renderFrequencySample(Complex c, double frac); default void subtractPeriodFrom(IAddPlateau audio, DoubleRange period, Frequency f, Complex intensity) { int i1 = ifloor(period.start), i2 = ifloor(period.end); new LPair<DoubleRange, Double> pairs; for (int i = i1; i < i2; i++) addPair(pairs, doubleRangeWithLength(i, 1), renderPeriodSample(period, f, intensity, i, false)); for (DoubleRange r, double amplitude : unpair concatenateAdjacentDoubleRanges(pairs)) audio.addPlateau(r.start, r.end, amplitude); } default double renderPeriodSample(DoubleRange period, Frequency f, Complex intensity, double t, bool shouldPrint) { double n = l(period); Complex c = div(intensity, n); double t2 = t-period.start; double frac = t2/n; if (shouldPrint) printVars(+f, +t, interval := n, +t, +t2, frac := formatDouble2(frac), c := renderComplexWithAngle(div(c, 32768))); /*if (realOnly) c = complex(c.re()); else if (imagOnly) c = complex(0, c.im());*/ ret renderFrequencySample(c, frac); } public default void addPeriodTo(double[] samples, DoubleRange period, Frequency f, Complex intensity) { if (samples == null) ret; subtractPeriodFrom(new IAddPlateau { public void addPlateau(double start, double end, double intensity) { int i1 = ifloor(start), i2 = ifloor(end); for (int i = i1; i < i2; i++) samples[i] += intensity; } }, period, f, minus(intensity)); } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033263 |
Snippet name: | RenderFrequencySample |
Eternal ID of this version: | #1033263/28 |
Text MD5: | be250beec34999ca0f4804fd7133650d |
Transpilation MD5: | 9d606b8abc3dd93cb9c68642a22107e7 |
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 12:02:03 |
Source code size: | 1604 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 212 / 389 |
Version history: | 27 change(s) |
Referenced in: | [show references] |