mirror of
https://github.com/juanjiant-bit/JIANT.git
synced 2026-12-06 21:04:32 +01:00
Parameter locks: hold a step on SEQ > STEP and turn a knob; SEQ > AUTO LIST lists and edits the locks and automation; lock edits undo. SEQ TOOLS (SEQ held on the SEQ pages): CLEAR, REVERSE, SHIFT, RANDOM, COOK, BEAT and the DRUM lane tools. REC layer (REC held): CLEAR, CLICK, COUNT-IN, CLICK LEVEL. Metronome and count-in (MENU > AUDIO), never in USB audio. MIDI CC map (5, 7, 10, 71..75, 91, 93, 94); DRUM lane levels (EDIT > LANES, LANES 2; projects FUN9). USB audio input at 44.1 or 48 kHz. Step recording at the cursor (SEQ > STEP, REC while stopped); restore the last session at power-on (MENU > SYSTEM > RESTORE LAST). Eight more ARP modes; MENU > CONTROL > SCALE LEDS; MENU > DISPLAY > SCREEN OFF. The header in three parts with a metronome; the new splash; the power-on LED sweep; DRUM grid beats on the key LEDs. Fast knob turns keep every click; KNOB ACCEL up to x8, on the FX and GLO layers too (#126). MASTER read from the pot before the audio starts, keys silent under the splash (#137). The update loader checks the whole package before erasing anything; robustness against damaged packages and stored data; sanitizer and fuzz runs in tests/run_tests.sh. Smaller icons in flash.
73 lines
3.3 KiB
Python
73 lines
3.3 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
|
# Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
|
|
"""The polyphase FIR of the USB audio input's 44.1 -> 48 kHz resampler (src/usb.c, FELUCCA_UAC_48K).
|
|
|
|
48000 / 44100 = 160 / 147: up by L = 160, low-pass, down by M = 147. Output frame k sits at input time
|
|
k * 147 / 160: phase p = (k * 147) % 160, newest input frame floor(k * 147 / 160). Each phase is N taps of
|
|
the prototype (a Kaiser-windowed sinc of 160 * N taps at 7.056 MHz, cut-off FC):
|
|
y[k] = sum_j PROTO[p + 160 j] * x[base - j], j = 0 .. N-1
|
|
The table holds the taps oldest input first (UAC_FIR[p][i] = L * PROTO[p + 160 (N-1-i)]), Q30, and only the
|
|
phases 0 .. 79: the prototype is symmetric, so phase 159 - p is phase p read backwards. Each phase's taps sum
|
|
to exactly 1 << 30 (unity gain at DC, the rounding left on its largest tap).
|
|
Why these numbers (tests/uac_test.c measures them on the C code):
|
|
N = 24, FC = 22 kHz, beta 9: images that would fold below 20 kHz (input above 28.1 kHz at 7.056 MHz) are
|
|
down 90 dB, the passband is flat within 0.06 dB to 18 kHz (-1.2 dB at 20 kHz); with Q30 taps the 1 kHz SNR
|
|
sits at the 16-bit floor (~94 dB at -1 dBFS); Q15 taps would cap it near 87 dB.
|
|
tools/gen_uac_fir.py [OUT] (default firmware/src/uac_fir.h); numpy only."""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import numpy as np
|
|
|
|
L, M, N = 160, 147, 24
|
|
FC, BETA, QB = 22000.0, 9.0, 30
|
|
FS = 44100.0
|
|
|
|
|
|
def prototype():
|
|
n = L * N
|
|
t = np.arange(n) - (n - 1) / 2.0
|
|
fc = FC / (FS * L) # cycles per sample at the up-sampled rate
|
|
h = 2 * fc * np.sinc(2 * fc * t) * np.kaiser(n, BETA)
|
|
return h / h.sum() * L # DC gain L: unity after the zero stuffing
|
|
|
|
|
|
def table():
|
|
h = prototype()
|
|
tab = np.zeros((L, N), dtype=np.int64)
|
|
for p in range(L):
|
|
c = h[p::L][::-1] # oldest input first
|
|
q = np.round(c * (1 << QB)).astype(np.int64)
|
|
q[np.argmax(np.abs(c))] += (1 << QB) - q.sum()
|
|
tab[p] = q
|
|
for p in range(L // 2): # the symmetry the C code relies on
|
|
assert (tab[L - 1 - p] == tab[p][::-1]).all() or np.abs(tab[L - 1 - p] - tab[p][::-1]).max() <= 1
|
|
return tab
|
|
|
|
|
|
def main():
|
|
out = Path(sys.argv[1] if len(sys.argv) > 1 else Path(__file__).resolve().parents[1] / "src" / "uac_fir.h")
|
|
tab = table()
|
|
lines = [
|
|
"/* SPDX-License-Identifier: GPL-3.0-only",
|
|
" * Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments */",
|
|
"/* generated by tools/gen_uac_fir.py: do not edit. The 44.1 -> 48 kHz polyphase FIR of the USB",
|
|
f" * audio input (usb.c): L {L}, M {M}, {N} taps per phase, Kaiser beta {BETA:g}, cut-off {FC:g} Hz, Q{QB};",
|
|
f" * phases 0..{L // 2 - 1} (phase {L - 1} - p = phase p backwards), taps oldest input first. */",
|
|
f"#define UAC_FIR_L {L}u",
|
|
f"#define UAC_FIR_M {M}u",
|
|
f"#define UAC_FIR_N {N}u",
|
|
f"#define UAC_FIR_Q {QB}",
|
|
f"static const int32_t UAC_FIR[{L // 2}][{N}] = {{",
|
|
]
|
|
for p in range(L // 2):
|
|
lines.append(" {" + ", ".join(str(int(v)) for v in tab[p]) + "},")
|
|
lines.append("};")
|
|
out.write_text("\n".join(lines) + "\n")
|
|
print(f"wrote {out}: {L // 2} x {N} taps, {L // 2 * N * 4} B")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|