l1vmet3s.av

scopeGEN

El so i el tempo dibuixats com a panells d'un programa d'àudio: forma d'ona, oscil·loscopi, espectre, BPM, agulla i compassos.El sonido y el tempo dibujados como paneles de un programa de audio: forma de onda, osciloscopio, espectro, BPM, aguja y compases.Sound and tempo drawn like the panels of an audio program: waveform, oscilloscope, spectrum, BPM, needle and bars.

v1.0.0147 controlscontrolescontrols78 operadorsoperadoresoperators1313 línies de codilíneas de códigolines of code46 KB
scopeGEN
  • in1CHOPaudio
scopeGEN
  • out1TOPWaveform
  • out2TOPScope
  • out3TOPBands
  • out4TOPBPM
  • out5TOPDial
  • out6TOPBars

UsarUsarUse

Prova aixòPrueba estoTry this

Canvia la mida de la FFT de Bands: més gran distingeix millor els greus però respon més tard.Cambia el tamaño de la FFT de Bands: más grande distingue mejor los graves pero responde más tarde.Change the FFT size in Bands: larger separates the low end better but reacts later.

Aquesta part és en castellà.This part is in Spanish.

  1. Arrastrar tox/GEN/scopeGEN.tox y conectar a in1 el audio (Audio Device In o Audio File In). Channel vacío = la mezcla de todos los canales.
  2. Activar los paneles que se usen (Enable en cada página) y conectar out1…out6 a donde haga falta.
  3. Aspecto: Colors (todos iguales o por panel), Style (Panel Size, marco, cabecera, rejilla, líneas, tipografía grande), y en cada panel su título y su Header Right (Auto, texto propio u Off).
  4. Tempo: Sync = Timeline (reloj común de la librería), Manual BPM o Free; Beats per Bar.

Va bé ambVa bien conGoes well with

ParàmetresParámetrosParameters

El panell real del mòdul amb els seus valors per defecte. Prem una fila per saber què fa; les notes són en castellà.El panel real del módulo con sus valores por defecto. Pulsa una fila para saber qué hace.The module's real panel with its default values. Press a row to see what it does; notes are in Spanish.

EntendreEntenderUnderstand

L'anàlisi del so es fa un cop per frame en numpy i va directa a una textura; cada panell és un shader que la llegeix i els panells apagats no gasten.El análisis del sonido se hace una vez por frame en numpy y va directo a una textura; cada panel es un shader que la lee y los paneles apagados no gastan.The sound is analysed once per frame in numpy and goes straight into a texture; each panel is a shader reading it, and panels that are off cost nothing.

Aquesta part és en castellà.This part is in Spanish.

Con más detalle

Los cálculos del audio (la onda por bloques, la FFT, los golpes) se hacen una vez por frame y van directos a la imagen; cada panel se dibuja en un solo shader y los que están apagados no gastan. El tile del nodo enseña todos los paneles activos.

La idea

Elementos gráficos técnicos y limpios del audio que suena, para componerlos con otros módulos.

Les idees que hi ha a sotaLas ideas que hay debajoThe ideas underneath

Per dinsPor dentroInside

Aquesta part és en castellà.This part is in Spanish.

El recorrido de la señal esquema en texto
tempo:  beat_rate → beat_speed ┐
        beat_lib (libclock) ───┴→ beat_src (Sync) → null_beats          sec_rate → sec_speed → null_sec
audio:  in1 ┐
        silence ┴→ aud_src (Switch: silence sin canales) → aud_sel (Channel) → aud_mono → aud_gain → null_aud
estilo: style_table (fila = panel, 11 grupos rgba) → style_chop → style_tex (6 × 11, 32f)   [style_exec: *]
        glsl_common (Text DAT: fondo, rejilla, cabecera, marco; lo incluyen todos los paneles)

Waveform: wave_data (Script TOP numpy: anillo de bloques max / min / x² + texel con la vista del frame)
          → wave_cols (GLSL: min / max / rms por columna, zoom, Scroll / Sweep) → wave_glsl → wave_sw → out1
Scope:    scope_data (Script TOP numpy: ventana con disparo, Points puntos) → scope_glsl → scope_sw → out2
Bands:    bands_data (Script TOP numpy: FFT, bandas, dB, subida / caída, picos) → bands_glsl → bands_sw → out3
BPM:      bpm_num (Text TOP: tempo) + bpm_pos (Text TOP: compás.beat; lo escribe pos_exec al cambiar de beat,
          beat_count → null_beat_count) → bpm_glsl → bpm_sw → out4
Dial:     dial_glsl (reloj por uniform array desde null_beats) → dial_sw → out5
Bars:     bars_data (Script TOP numpy: golpes por paso) → bars_glsl → bars_sw → out6
Cabeceras: {panel}_title / {panel}_info (Text TOP, blanco sobre transparente) → entradas 2 y 3 de cada GLSL
Tile:     tile_glsl (los *_sw activos en rejilla) → null_tile = opviewer del COMP
util (Text DAT) · exec_start (onStart / onCreate → write_style) · build1 … build4

Cada {panel}_sw elige blank (16 × 16 transparente) con el panel apagado: su GLSL y sus datos no cocinan.

Operador a operador configuración clave
OperadorConfiguración clave
aud_src → null_audSwitch a silence sin canales en in1; Select por Channel (vacío = todos) → Math Avg (mono) → Gain
wave_dataScript TOP rgba32f, (NB + 1) × 1: NB ≤ 4096 bloques de B = muestras de la ventana / NB; último texel = ventana, fase del Sweep, beats, beats/s. Estado en un dict del módulo (no en storage)
wave_colsGLSL TOP rgba32f, (Resolution + 1) × 1, filtro nearest: min / max / rms por columna (≤ 97 lecturas), copia la vista a su última columna
scope_dataScript TOP: 3 ventanas en anillo; Rising = último cruce por cero ascendente con ventana completa; reducción a Points con reduceat
bands_dataScript TOP: FFT Size con Hann, bordes de bandas cacheados, np.maximum.reduceat, dB + Tilt, Rise / Fall exponenciales, pico con Hold y caída lineal
bars_dataScript TOP: pasos = Bars × Beats per Bar × Steps per Beat; borra al pasar el cabezal; golpe = pico del frame ≥ Hit Level viniendo de abajo, ≥ 0,12 s
{panel}_glslGLSL Multi rgba8, resolución util.size(); entradas: 0 datos, 1 style_tex, 2 título, 3 info (BPM: 4 = posición); Dial / Bars / BPM con uniform float uClock[1] (página Arrays, CHOP null_beats)
{panel}_title / _infoText TOP con la fuente / tamaño / negrita / tracking de Header, resolución util.head_res(); info = util.info() (Header Right: Auto / Custom / Off)
bpm_num / bpm_posText TOP con la tipografía grande (Type), resolución util.content_res(); alineación Align
style_table6 filas (panel) × 44 columnas: 8 colores (bg, motif, accent, dim, headbg, headtext, frame, grid) + marco / cabecera / rejilla / líneas; util.write_style() solo escribe las celdas que cambian
style_execParameter Execute sobre * → write_style (solo cambios de pars)
tile_glsl800 × 600, entradas = los 6 *_sw; rejilla cols = ⌈√n⌉

TallerTallerWorkshop

El codiEl códigoThe code

util python · 178 línieslíneaslines
# util de scopeGEN: tempo, ventana del Waveform, estado de la vista (congelable), estilo → textura.
# Python solo en expresiones baratas (una vez por frame, cacheadas) y al cambiar un par de aspecto.
import math

PANELS = ['wave', 'scope', 'bands', 'bpm', 'dial', 'bars']
PFX = {'wave': 'Wave', 'scope': 'Scope', 'bands': 'Bands', 'bpm': 'Bpm', 'dial': 'Dial', 'bars': 'Bars'}
COLORS = ['bg', 'motif', 'accent', 'dim', 'headbg', 'headtext', 'frame', 'grid']
PERPANEL = ('bg', 'motif', 'headbg')             # con Colors = Per Panel; los de la interfaz, siempre comunes


def rate(comp):
	"""Beats por segundo; lo integra beat_speed (sin saltos al cambiar el tempo)."""
	p = comp.par
	mode = p.Sync.eval()
	if mode == 'manual':
		return max(p.Bpm.eval(), 1.0) / 60.0
	if mode == 'free':
		return 1.0
	t = op('/local/time')
	try:
		return float(t.par.tempo.eval()) / 60.0 if t is not None else float(comp.time.tempo) / 60.0
	except Exception:
		return 2.0


def beats(comp):
	n = comp.op('null_beats')
	return float(n[0].eval()) if n is not None and n.numChans else 0.0


def seconds(comp):
	n = comp.op('null_sec')
	return float(n[0].eval()) if n is not None and n.numChans else 0.0


def wave_span(comp):
	"""Beats de la ventana en modo Bars (0 en Seconds)."""
	p = comp.par
	if p.Wavewinunit.eval() != 'bars':
		return 0.0
	return float(p.Wavebars.eval()) * max(int(p.Beatsperbar.eval()), 1)


def wave_window(comp):
	"""Segundos de la ventana del Waveform."""
	s = wave_span(comp)
	if s > 0:
		return s / max(rate(comp), 1e-3)
	return max(float(comp.par.Wavewindow.eval()), 0.05)


def info(comp, panel):
	"""Texto de la derecha de la cabecera: Header Right del panel = Auto (esta info), Custom (su texto) u Off."""
	p = comp.par
	mode = getattr(p, PFX[panel] + 'infomode', None)
	mode = mode.eval() if mode is not None else 'auto'
	if mode == 'off':
		return ''
	if mode == 'custom':
		return getattr(p, PFX[panel] + 'infotext').eval()
	if panel == 'wave':
		s = wave_span(comp)
		if s > 0:
			w = '%s BAR%s' % (p.Wavebars.eval(), '' if p.Wavebars.eval() == '1' else 'S')
		else:
			w = '%.2g s' % wave_window(comp)
		z = p.Wavezoom.eval()
		ch = p.Audiochan.eval().strip().upper() or 'MIX'
		return '  ·  '.join(x for x in (ch, w, ('x%.3g' % z) if z > 1.001 else '') if x)
	if panel == 'scope' and getattr(p, 'Scopewindow', None) is not None:
		ch = p.Audiochan.eval().strip().upper() or 'MIX'
		trig = 'TRIG' if p.Scopetrigger.eval() == 'rising' else 'FREE'
		return '  ·  '.join((ch, '%.3g ms' % p.Scopewindow.eval(), trig))
	if panel == 'bands' and getattr(p, 'Bandscount', None) is not None:
		def hz(f):
			return ('%.3g kHz' % (f / 1000.0)) if f >= 1000 else ('%d Hz' % round(f))
		return '%d  ·  %s – %s' % (p.Bandscount.eval(), hz(p.Bandsfmin.eval()), hz(p.Bandsfmax.eval()))
	sig = '%d/4' % int(p.Beatsperbar.eval())
	sync = {'timeline': 'SYNC', 'manual': 'MANUAL', 'free': 'FREE'}[p.Sync.eval()]
	if panel == 'bpm':
		return '  ·  '.join((sync, sig))
	if panel == 'dial' and getattr(p, 'Dialturn', None) is not None:
		return '  ·  '.join(('1 TURN / ' + ('BEAT' if p.Dialturn.eval() == 'beat' else 'BAR'), sig))
	if panel == 'bars' and getattr(p, 'Barscount', None) is not None:
		n = int(p.Barscount.eval())
		return '  ·  '.join(('%d BAR%s' % (n, '' if n == 1 else 'S'), sig))
	return ''


def content_res(comp, panel):
	"""Resolución del contenido de un panel (dentro del marco y del padding, bajo la cabecera)."""
	w, h = size(comp, panel)
	m = frame_w(comp) + float(comp.par.Framepad.eval())
	return max(int(round(w - 2 * m)), 1), max(int(round(h - 2 * m - head_h(comp))), 1)


def bpm_text(comp):
	d = int(comp.par.Bpmdecimals.eval()) if getattr(comp.par, 'Bpmdecimals', None) is not None else 1
	return '%.*f' % (d, rate(comp) * 60.0)


def pos_text(comp):
	"""Posición compás.beat (desde 1) dentro del ciclo de Bars (el reloj común cuenta desde que se abrió TD:
	el compás absoluto saldría en miles)."""
	b = int(beats(comp))
	bpb = max(int(comp.par.Beatsperbar.eval()), 1)
	nb = int(comp.par.Barscount.eval()) if getattr(comp.par, 'Barscount', None) is not None else 4
	return '%d.%d' % ((b // bpb) % max(nb, 1) + 1, b % bpb + 1)


def size(comp, panel):
	"""Tamaño del panel: el suyo o, con Panel Size = Same for All Panels, el común."""
	sm = getattr(comp.par, 'Sizemode', None)
	if sm is not None and sm.eval() == 'all':
		return max(int(comp.par.Allsize1.eval()), 16), max(int(comp.par.Allsize2.eval()), 16)
	pr = getattr(comp.par, PFX[panel] + 'size1', None)
	if pr is None:
		return 512, 512
	return max(int(pr.eval()), 16), max(int(getattr(comp.par, PFX[panel] + 'size2').eval()), 16)


def frame_w(comp):
	return float(comp.par.Framewidth.eval()) if comp.par.Frameon.eval() else 0.0


def head_h(comp):
	return float(comp.par.Headerh.eval()) if comp.par.Headeron.eval() else 0.0


def head_res(comp, panel):
	"""Resolución de los Text TOP de la cabecera: el ancho dentro del marco × el alto de la cabecera."""
	w, h = size(comp, panel)
	fw = frame_w(comp)
	return max(int(round(w - 2 * fw)), 1), max(int(round(head_h(comp))), 1)


def _col(comp, panel, key):
	p = comp.par
	per = key in PERPANEL and p.Colormode.eval() == 'panel' and getattr(p, PFX[panel] + key + 'r', None) is not None
	base = (PFX[panel] + key) if per else (key[0].upper() + key[1:] + 'color')
	r = getattr(p, base + 'r').eval()
	g = getattr(p, base + 'g').eval()
	b = getattr(p, base + 'b').eval()
	a = getattr(p, base + 'a', None)
	a = a.eval() if a is not None else 1.0
	if key == 'grid':
		a = p.Gridalpha.eval()
	return [r, g, b, a]


def style_row(comp, panel):
	"""11 grupos rgba: 8 colores | marco (ancho, padding, alto cabecera, separador) | rejilla (estilo, x, y,
	ancho) | líneas (ancho, opacidad del relleno, ·, ·)."""
	p = comp.par
	row = []
	for k in COLORS:
		row += _col(comp, panel, k)
	row += [frame_w(comp), p.Framepad.eval(), head_h(comp), p.Headerline.eval() if p.Headeron.eval() else 0.0]
	row += [['off', 'lines', 'dots'].index(p.Gridstyle.eval()), p.Gridx.eval(), p.Gridy.eval(), p.Gridwidth.eval()]
	row += [p.Linewidth.eval(), p.Fillopacity.eval(), 0.0, 0.0]
	return [round(float(v), 5) for v in row]


def write_style(comp):
	t = comp.op('style_table')
	if t is None:
		return
	names = ['s%d%s' % (i, c) for i in range(11) for c in 'rgba']
	if t.numRows != len(PANELS) + 1 or t.numCols != len(names):
		t.clear()
		t.appendRow(names)
		for _ in PANELS:
			t.appendRow([0] * len(names))
	for i, panel in enumerate(PANELS):
		for j, v in enumerate(style_row(comp, panel)):
			if t[i + 1, j].val != str(v):
				t[i + 1, j] = v
pos_exec python · 16 línieslíneaslines
def onValueChange(channel, sampleIndex, val, prev):
	op('bpm_pos').par.text = op('util').module.pos_text(parent())
	return

def onOffToOn(channel, sampleIndex, val, prev):
	return

def whileOn(channel, sampleIndex, val, prev):
	return

def onOnToOff(channel, sampleIndex, val, prev):
	return

def whileOff(channel, sampleIndex, val, prev):
	return
exec_start python · 29 línieslíneaslines
def onStart():
	op('util').module.write_style(parent())
	return

def onCreate():
	op('util').module.write_style(parent())
	return

def onExit():
	return

def onFrameStart(frame):
	return

def onFrameEnd(frame):
	return

def onPlayStateChange(state):
	return

def onDeviceChange():
	return

def onProjectPreSave():
	return

def onProjectPostSave():
	return
style_exec python · 22 línieslíneaslines
def onValueChange(par, prev):
	op('util').module.write_style(parent())
	return

def onValuesChanged(changes):
	return

def onPulse(par):
	return

def onExpressionChange(par, val, prev):
	return

def onExportChange(par, val, prev):
	return

def onEnableChange(par, val, prev):
	return

def onModeChange(par, val, prev):
	return
glsl_common glsl · 51 línieslíneaslines
// scopeGEN: común a todos los paneles (fondo, rejilla, cabecera, marco). Alfa premultiplicado.
// Entradas: 1 = estilo (texelFetch(panel, grupo)), 2 = título, 3 = info de la cabecera.
#define STYLE 1
#define TITLE 2
#define INFO 3
vec4 S(int g) { return texelFetch(sTD2DInputs[STYLE], ivec2(PANEL, g), 0); }
void over(inout vec4 c, vec3 rgb, float a) { c = vec4(rgb * a, a) + c * (1.0 - a); }
float inBox(vec2 p, vec4 r) { vec2 d = min(p - r.xy, r.zw - p); return clamp(min(d.x, d.y) + 0.5, 0.0, 1.0); }
float lineCov(float dist, float w) { return clamp(w * 0.5 - dist + 0.5, 0.0, 1.0); }

// rectángulo del contenido (dentro del marco, bajo la cabecera, con padding)
vec4 contentRect(vec2 res)
{
	vec4 f = S(8);                                  // marco, padding, alto cabecera, separador
	return vec4(f.x + f.y, f.x + f.y, res.x - f.x - f.y, res.y - f.x - f.z - f.y);
}

void drawGrid(inout vec4 c, vec2 p, vec4 r)
{
	vec4 g = S(9);                                  // estilo (0 off, 1 lines, 2 dots), x, y, ancho
	if (g.x < 0.5) return;
	vec4 gc = S(7);
	vec2 sz = r.zw - r.xy;
	vec2 q = (p - r.xy) / sz * g.yz;                // en divisiones
	vec2 k = floor(q + 0.5);
	vec2 d = abs(q - k) * sz / g.yz;                // px a la línea más cercana
	bool ix = k.x > 0.5 && k.x < g.y - 0.5, iy = k.y > 0.5 && k.y < g.z - 0.5;
	float a;
	if (g.x < 1.5) a = max(ix ? lineCov(d.x, g.w) : 0.0, iy ? lineCov(d.y, g.w) : 0.0);
	else a = (ix && iy) ? clamp(g.w + 0.5 - length(d), 0.0, 1.0) : 0.0;
	over(c, gc.rgb, a * gc.a * inBox(p, r));
}

void drawChrome(inout vec4 c, vec2 p, vec2 res)
{
	vec4 f = S(8);
	float fw = f.x, hh = f.z, hl = f.w;
	if (hh > 0.5) {
		vec4 hr = vec4(fw, res.y - fw - hh, res.x - fw, res.y - fw);
		float a = inBox(p, hr);
		if (a > 0.0) {
			over(c, S(4).rgb, a);
			vec2 uv = (p - hr.xy) / (hr.zw - hr.xy);
			float t = max(texture(sTD2DInputs[TITLE], uv).a, texture(sTD2DInputs[INFO], uv).a);
			over(c, S(5).rgb, t * a);
		}
		if (hl > 0.0) over(c, S(6).rgb, lineCov(abs(p.y - (hr.y - hl * 0.5)), hl) * step(fw, p.x) * step(p.x, res.x - fw));
	}
	if (fw > 0.0) over(c, S(6).rgb, 1.0 - inBox(p, vec4(fw, fw, res.x - fw, res.y - fw)));
}
bpm_glsl_shader glsl · 83 línieslíneaslines
#define PANEL 3
// scopeGEN: común a todos los paneles (fondo, rejilla, cabecera, marco). Alfa premultiplicado.
// Entradas: 1 = estilo (texelFetch(panel, grupo)), 2 = título, 3 = info de la cabecera.
#define STYLE 1
#define TITLE 2
#define INFO 3
vec4 S(int g) { return texelFetch(sTD2DInputs[STYLE], ivec2(PANEL, g), 0); }
void over(inout vec4 c, vec3 rgb, float a) { c = vec4(rgb * a, a) + c * (1.0 - a); }
float inBox(vec2 p, vec4 r) { vec2 d = min(p - r.xy, r.zw - p); return clamp(min(d.x, d.y) + 0.5, 0.0, 1.0); }
float lineCov(float dist, float w) { return clamp(w * 0.5 - dist + 0.5, 0.0, 1.0); }

// rectángulo del contenido (dentro del marco, bajo la cabecera, con padding)
vec4 contentRect(vec2 res)
{
	vec4 f = S(8);                                  // marco, padding, alto cabecera, separador
	return vec4(f.x + f.y, f.x + f.y, res.x - f.x - f.y, res.y - f.x - f.z - f.y);
}

void drawGrid(inout vec4 c, vec2 p, vec4 r)
{
	vec4 g = S(9);                                  // estilo (0 off, 1 lines, 2 dots), x, y, ancho
	if (g.x < 0.5) return;
	vec4 gc = S(7);
	vec2 sz = r.zw - r.xy;
	vec2 q = (p - r.xy) / sz * g.yz;                // en divisiones
	vec2 k = floor(q + 0.5);
	vec2 d = abs(q - k) * sz / g.yz;                // px a la línea más cercana
	bool ix = k.x > 0.5 && k.x < g.y - 0.5, iy = k.y > 0.5 && k.y < g.z - 0.5;
	float a;
	if (g.x < 1.5) a = max(ix ? lineCov(d.x, g.w) : 0.0, iy ? lineCov(d.y, g.w) : 0.0);
	else a = (ix && iy) ? clamp(g.w + 0.5 - length(d), 0.0, 1.0) : 0.0;
	over(c, gc.rgb, a * gc.a * inBox(p, r));
}

void drawChrome(inout vec4 c, vec2 p, vec2 res)
{
	vec4 f = S(8);
	float fw = f.x, hh = f.z, hl = f.w;
	if (hh > 0.5) {
		vec4 hr = vec4(fw, res.y - fw - hh, res.x - fw, res.y - fw);
		float a = inBox(p, hr);
		if (a > 0.0) {
			over(c, S(4).rgb, a);
			vec2 uv = (p - hr.xy) / (hr.zw - hr.xy);
			float t = max(texture(sTD2DInputs[TITLE], uv).a, texture(sTD2DInputs[INFO], uv).a);
			over(c, S(5).rgb, t * a);
		}
		if (hl > 0.0) over(c, S(6).rgb, lineCov(abs(p.y - (hr.y - hl * 0.5)), hl) * step(fw, p.x) * step(p.x, res.x - fw));
	}
	if (fw > 0.0) over(c, S(6).rgb, 1.0 - inBox(p, vec4(fw, fw, res.x - fw, res.y - fw)));
}
// bpm_glsl: panel BPM. Entradas: 0 = el número (Text TOP del tamaño del contenido), 4 = compás.beat.
uniform vec4 uT;      // LED, posición on, beats por compás, rejilla
uniform float uClock[1];
out vec4 fragColor;

void main()
{
	vec2 res = uTDOutputInfo.res.zw;
	vec2 p = vUV.st * res;
	vec4 bg = S(0);
	vec4 c = vec4(bg.rgb * bg.a, bg.a);
	vec4 r = contentRect(res);
	if (uT.w > 0.5) drawGrid(c, p, r);
	vec2 sz = r.zw - r.xy;
	float inside = inBox(p, r);
	vec2 uv = (p - r.xy) / sz;
	over(c, S(1).rgb, texture(sTD2DInputs[0], uv).a * inside);
	if (uT.y > 0.5) over(c, S(2).rgb, texture(sTD2DInputs[4], uv).a * inside);
	if (uT.x > 0.5) {                            // LED: arriba a la derecha del contenido
		float b = uClock[0];
		float ph = fract(b);
		bool down = mod(floor(b), max(uT.z, 1.0)) < 0.5;
		float s = clamp(min(sz.x, sz.y) * 0.09, 6.0, 40.0);
		vec4 led = vec4(r.z - s, r.w - s, r.z, r.w);
		vec3 lc = ph < 0.18 ? S(2).rgb : S(3).rgb;
		over(c, lc, inBox(p, led));
		if (down && ph < 0.18) over(c, S(1).rgb, inBox(p, led + vec4(s * 0.3, s * 0.3, -s * 0.3, -s * 0.3)));
	}
	drawChrome(c, p, res);
	fragColor = TDOutputSwizzle(c);
}
bars_glsl_shader glsl · 99 línieslíneaslines
#define PANEL 5
// scopeGEN: común a todos los paneles (fondo, rejilla, cabecera, marco). Alfa premultiplicado.
// Entradas: 1 = estilo (texelFetch(panel, grupo)), 2 = título, 3 = info de la cabecera.
#define STYLE 1
#define TITLE 2
#define INFO 3
vec4 S(int g) { return texelFetch(sTD2DInputs[STYLE], ivec2(PANEL, g), 0); }
void over(inout vec4 c, vec3 rgb, float a) { c = vec4(rgb * a, a) + c * (1.0 - a); }
float inBox(vec2 p, vec4 r) { vec2 d = min(p - r.xy, r.zw - p); return clamp(min(d.x, d.y) + 0.5, 0.0, 1.0); }
float lineCov(float dist, float w) { return clamp(w * 0.5 - dist + 0.5, 0.0, 1.0); }

// rectángulo del contenido (dentro del marco, bajo la cabecera, con padding)
vec4 contentRect(vec2 res)
{
	vec4 f = S(8);                                  // marco, padding, alto cabecera, separador
	return vec4(f.x + f.y, f.x + f.y, res.x - f.x - f.y, res.y - f.x - f.z - f.y);
}

void drawGrid(inout vec4 c, vec2 p, vec4 r)
{
	vec4 g = S(9);                                  // estilo (0 off, 1 lines, 2 dots), x, y, ancho
	if (g.x < 0.5) return;
	vec4 gc = S(7);
	vec2 sz = r.zw - r.xy;
	vec2 q = (p - r.xy) / sz * g.yz;                // en divisiones
	vec2 k = floor(q + 0.5);
	vec2 d = abs(q - k) * sz / g.yz;                // px a la línea más cercana
	bool ix = k.x > 0.5 && k.x < g.y - 0.5, iy = k.y > 0.5 && k.y < g.z - 0.5;
	float a;
	if (g.x < 1.5) a = max(ix ? lineCov(d.x, g.w) : 0.0, iy ? lineCov(d.y, g.w) : 0.0);
	else a = (ix && iy) ? clamp(g.w + 0.5 - length(d), 0.0, 1.0) : 0.0;
	over(c, gc.rgb, a * gc.a * inBox(p, r));
}

void drawChrome(inout vec4 c, vec2 p, vec2 res)
{
	vec4 f = S(8);
	float fw = f.x, hh = f.z, hl = f.w;
	if (hh > 0.5) {
		vec4 hr = vec4(fw, res.y - fw - hh, res.x - fw, res.y - fw);
		float a = inBox(p, hr);
		if (a > 0.0) {
			over(c, S(4).rgb, a);
			vec2 uv = (p - hr.xy) / (hr.zw - hr.xy);
			float t = max(texture(sTD2DInputs[TITLE], uv).a, texture(sTD2DInputs[INFO], uv).a);
			over(c, S(5).rgb, t * a);
		}
		if (hl > 0.0) over(c, S(6).rgb, lineCov(abs(p.y - (hr.y - hl * 0.5)), hl) * step(fw, p.x) * step(p.x, res.x - fw));
	}
	if (fw > 0.0) over(c, S(6).rgb, 1.0 - inBox(p, vec4(fw, fw, res.x - fw, res.y - fw)));
}
// bars_glsl: panel Bars. Entrada 0 = bars_data (pasos × 1: golpe). Paso actual en Motif, pasados con la
// opacidad del relleno, futuros en Dim; primer paso de cada compás con una raya Accent; golpes = cuadrado Accent.
uniform vec4 uC;      // compases, beats por compás, pasos por beat, disposición (0 fila, 1 rejilla)
uniform vec4 uG;      // hueco, golpes, rejilla, ·
uniform float uClock[1];
out vec4 fragColor;

void main()
{
	vec2 res = uTDOutputInfo.res.zw;
	vec2 p = vUV.st * res;
	vec4 bg = S(0);
	vec4 c = vec4(bg.rgb * bg.a, bg.a);
	vec4 r = contentRect(res);
	if (uG.z > 0.5) drawGrid(c, p, r);
	vec2 sz = r.zw - r.xy;
	float bars = uC.x, perBar = uC.y * uC.z;
	float steps = bars * perBar;
	float span = bars * uC.y;
	float now = floor(fract(uClock[0] / span) * steps);
	vec2 uv = (p - r.xy) / sz;
	float cols = uC.w > 0.5 ? perBar : steps;
	float rows = uC.w > 0.5 ? bars : 1.0;
	vec2 cell = sz / vec2(cols, rows);
	float col = floor(uv.x * cols), row = floor(uv.y * rows);
	float i = (rows - 1.0 - row) * cols + col;    // arriba = el primer compás
	if (i >= 0.0 && i < steps && uv.x >= 0.0 && uv.y >= 0.0 && uv.x < 1.0 && uv.y < 1.0) {
		float g = uG.x * min(cell.x, cell.y) * 0.5;
		bool barStart = mod(i, perBar) < 0.5;
		vec2 c0 = r.xy + vec2(col, row) * cell;
		float gl = (uC.w < 0.5 && barStart && i > 0.5) ? g * 2.0 : g;   // más hueco entre compases (en fila)
		vec4 box = vec4(c0.x + gl, c0.y + g, c0.x + cell.x - g, c0.y + cell.y - g);
		float a = inBox(p, box);
		vec3 cc = i == now ? S(1).rgb : S(3).rgb;
		float al = i < now ? S(10).y : 1.0;
		if (i < now) cc = S(1).rgb;
		over(c, cc, a * al);
		if (barStart) over(c, S(2).rgb, inBox(p, vec4(box.x, box.w - max(2.0, S(10).x), box.z, box.w)));
		if (uG.y > 0.5 && texelFetch(sTD2DInputs[0], ivec2(int(i), 0), 0).r > 0.5) {
			vec2 m = (box.xy + box.zw) * 0.5;
			float h = min(box.z - box.x, box.w - box.y) * 0.18;
			over(c, S(2).rgb, inBox(p, vec4(m - h, m + h)));
		}
	}
	drawChrome(c, p, res);
	fragColor = TDOutputSwizzle(c);
}
dial_glsl_shader glsl · 114 línieslíneaslines
#define PANEL 4
// scopeGEN: común a todos los paneles (fondo, rejilla, cabecera, marco). Alfa premultiplicado.
// Entradas: 1 = estilo (texelFetch(panel, grupo)), 2 = título, 3 = info de la cabecera.
#define STYLE 1
#define TITLE 2
#define INFO 3
vec4 S(int g) { return texelFetch(sTD2DInputs[STYLE], ivec2(PANEL, g), 0); }
void over(inout vec4 c, vec3 rgb, float a) { c = vec4(rgb * a, a) + c * (1.0 - a); }
float inBox(vec2 p, vec4 r) { vec2 d = min(p - r.xy, r.zw - p); return clamp(min(d.x, d.y) + 0.5, 0.0, 1.0); }
float lineCov(float dist, float w) { return clamp(w * 0.5 - dist + 0.5, 0.0, 1.0); }

// rectángulo del contenido (dentro del marco, bajo la cabecera, con padding)
vec4 contentRect(vec2 res)
{
	vec4 f = S(8);                                  // marco, padding, alto cabecera, separador
	return vec4(f.x + f.y, f.x + f.y, res.x - f.x - f.y, res.y - f.x - f.z - f.y);
}

void drawGrid(inout vec4 c, vec2 p, vec4 r)
{
	vec4 g = S(9);                                  // estilo (0 off, 1 lines, 2 dots), x, y, ancho
	if (g.x < 0.5) return;
	vec4 gc = S(7);
	vec2 sz = r.zw - r.xy;
	vec2 q = (p - r.xy) / sz * g.yz;                // en divisiones
	vec2 k = floor(q + 0.5);
	vec2 d = abs(q - k) * sz / g.yz;                // px a la línea más cercana
	bool ix = k.x > 0.5 && k.x < g.y - 0.5, iy = k.y > 0.5 && k.y < g.z - 0.5;
	float a;
	if (g.x < 1.5) a = max(ix ? lineCov(d.x, g.w) : 0.0, iy ? lineCov(d.y, g.w) : 0.0);
	else a = (ix && iy) ? clamp(g.w + 0.5 - length(d), 0.0, 1.0) : 0.0;
	over(c, gc.rgb, a * gc.a * inBox(p, r));
}

void drawChrome(inout vec4 c, vec2 p, vec2 res)
{
	vec4 f = S(8);
	float fw = f.x, hh = f.z, hl = f.w;
	if (hh > 0.5) {
		vec4 hr = vec4(fw, res.y - fw - hh, res.x - fw, res.y - fw);
		float a = inBox(p, hr);
		if (a > 0.0) {
			over(c, S(4).rgb, a);
			vec2 uv = (p - hr.xy) / (hr.zw - hr.xy);
			float t = max(texture(sTD2DInputs[TITLE], uv).a, texture(sTD2DInputs[INFO], uv).a);
			over(c, S(5).rgb, t * a);
		}
		if (hl > 0.0) over(c, S(6).rgb, lineCov(abs(p.y - (hr.y - hl * 0.5)), hl) * step(fw, p.x) * step(p.x, res.x - fw));
	}
	if (fw > 0.0) over(c, S(6).rgb, 1.0 - inBox(p, vec4(fw, fw, res.x - fw, res.y - fw)));
}
// dial_glsl: panel Dial. Aro y marcas en Dim (la del compás en Accent), aguja y estela en Motif, destello
// en Accent al empezar cada beat.
uniform vec4 uD;      // beats por vuelta, marcas, estela (fracción de vuelta), destello
uniform vec4 uE;      // rejilla, beats por compás, ·, ·
uniform float uClock[1];
out vec4 fragColor;

float segDist(vec2 p, vec2 a, vec2 b)
{
	vec2 ab = b - a;
	float t = clamp(dot(p - a, ab) / max(dot(ab, ab), 1e-6), 0.0, 1.0);
	return length(p - (a + ab * t));
}

void main()
{
	vec2 res = uTDOutputInfo.res.zw;
	vec2 p = vUV.st * res;
	vec4 bg = S(0);
	vec4 c = vec4(bg.rgb * bg.a, bg.a);
	vec4 r = contentRect(res);
	if (uE.x > 0.5) drawGrid(c, p, r);
	vec2 sz = r.zw - r.xy;
	vec4 L = S(10);
	float lw = L.x;
	vec2 ctr = (r.xy + r.zw) * 0.5;
	float R = min(sz.x, sz.y) * 0.5 - lw;
	vec2 q = p - ctr;
	float d = length(q);
	float TAU = 6.2831853;
	float b = uClock[0];
	float turn = fract(b / max(uD.x, 1e-3));
	float th = fract(atan(q.x, q.y) / TAU);       // 0 arriba, sentido horario
	// destello del beat
	float fb = fract(b);
	over(c, S(2).rgb, uD.w * pow(1.0 - fb, 4.0) * 0.6 * clamp(R - d + 0.5, 0.0, 1.0));
	// estela (radar)
	if (uD.z > 0.0) {
		float k = fract(turn - th);
		float a = (k < uD.z) ? (1.0 - k / uD.z) : 0.0;
		over(c, S(1).rgb, a * L.y * clamp(R - d + 0.5, 0.0, 1.0));
	}
	// aro
	over(c, S(3).rgb, lineCov(abs(d - R), lw));
	// marcas
	if (uD.y > 0.5) {
		float n = uD.x < 1.5 ? 4.0 : uD.x;        // por beat: cuartos; por compás: los beats
		float k = floor(th * n + 0.5);
		float ang = k / n * TAU;
		vec2 dir = vec2(sin(ang), cos(ang));
		float t = segDist(q, dir * R * 0.82, dir * R);
		bool first = mod(k, n) < 0.5;
		over(c, first ? S(2).rgb : S(3).rgb, lineCov(t, lw));
	}
	// aguja
	float ah = turn * TAU;
	vec2 hd = vec2(sin(ah), cos(ah));
	over(c, S(1).rgb, lineCov(segDist(q, vec2(0.0), hd * R * 0.96), lw));
	over(c, S(1).rgb, clamp(lw * 1.6 + 0.5 - d, 0.0, 1.0));
	drawChrome(c, p, res);
	fragColor = TDOutputSwizzle(c);
}
tile_glsl_shader glsl · 60 línieslíneaslines
// tile_glsl: los paneles activos en rejilla (cols = ceil(sqrt(n))), cada uno encajado en su celda.
// Entradas 0..5 = wave_sw … bars_sw (un panel apagado da un negro de 16 × 16 y no cocina).
uniform vec4 uOn0;    // wave, scope, bands, bpm activos
uniform vec4 uOn1;    // dial, bars, ·, ·
out vec4 fragColor;

vec2 InRes(int i)
{
	if (i == 0) return uTD2DInfos[0].res.zw;
	if (i == 1) return uTD2DInfos[1].res.zw;
	if (i == 2) return uTD2DInfos[2].res.zw;
	if (i == 3) return uTD2DInfos[3].res.zw;
	if (i == 4) return uTD2DInfos[4].res.zw;
	return uTD2DInfos[5].res.zw;
}
vec4 InTex(int i, vec2 uv)
{
	if (i == 0) return texture(sTD2DInputs[0], uv);
	if (i == 1) return texture(sTD2DInputs[1], uv);
	if (i == 2) return texture(sTD2DInputs[2], uv);
	if (i == 3) return texture(sTD2DInputs[3], uv);
	if (i == 4) return texture(sTD2DInputs[4], uv);
	return texture(sTD2DInputs[5], uv);
}
float isOn(int i) { return i < 4 ? uOn0[i] : uOn1[i - 4]; }

void main()
{
	vec2 res = uTDOutputInfo.res.zw;
	vec2 p = vUV.st * res;
	vec4 c = vec4(0.06, 0.06, 0.06, 1.0);
	int idx[6];
	int n = 0;
	for (int i = 0; i < 6; i++)
		if (isOn(i) > 0.5) { idx[n] = i; n++; }
	if (n > 0) {
		int cols = int(ceil(sqrt(float(n))));
		int rows = (n + cols - 1) / cols;
		vec2 cell = res / vec2(cols, rows);
		int cx = int(floor(p.x / cell.x));
		int cy = int(floor((res.y - p.y) / cell.y));          // arriba primero
		int k = cy * cols + cx;
		if (k < n) {
			int i = idx[k];
			vec2 o = vec2(float(cx) * cell.x, res.y - float(cy + 1) * cell.y);
			vec2 inner = cell - 8.0;
			vec2 I = max(InRes(i), vec2(1.0));
			float s = min(inner.x / I.x, inner.y / I.y);
			vec2 sz = I * s;
			vec2 lo = o + (cell - sz) * 0.5;
			vec2 uv = (p - lo) / sz;
			if (all(greaterThanEqual(uv, vec2(0.0))) && all(lessThanEqual(uv, vec2(1.0)))) {
				vec4 t = InTex(i, uv);
				c = vec4(t.rgb + c.rgb * (1.0 - t.a), 1.0);    // premultiplicado sobre el gris
			}
		}
	}
	fragColor = TDOutputSwizzle(c);
}
wave_cols_shader glsl · 47 línieslíneaslines
// wave_cols: min / max / rms de cada COLUMNA del Waveform ((Resolution + 1) × 1), con zoom y Scroll / Sweep.
// Entrada 0 = wave_data: bloques (r max, g min, b media de x²; el más nuevo al final) + un último texel con la
// vista del frame (ventana s, fase del Sweep, beats, beats/s), que esta pasada copia a su última columna.
uniform vec4 uW;      // ·, ·, modo (0 scroll, 1 sweep), ·
uniform vec4 uV;      // columnas, zoom, centro del zoom, ·
out vec4 fragColor;

vec4 VW;              // la vista del frame

float back(float u)   // segundos hacia atrás de la posición u (0..1 de la ventana)
{
	return (uW.z < 0.5 ? (1.0 - u) : fract(VW.y - u)) * VW.x;
}

void main()
{
	int N = textureSize(sTD2DInputs[0], 0).x - 1;
	VW = texelFetch(sTD2DInputs[0], ivec2(N, 0), 0);
	if (int(gl_FragCoord.x) >= int(uV.x)) { fragColor = VW; return; }
	float x0 = floor(gl_FragCoord.x) / uV.x, x1 = (floor(gl_FragCoord.x) + 1.0) / uV.x;
	float u0 = uV.z + (x0 - 0.5) / uV.y, u1 = uV.z + (x1 - 0.5) / uV.y;
	float mn = 1e9, mx = -1e9, rms = 0.0;
	float valid = 0.0;
	if (u1 > 0.0 && u0 < 1.0) {
		u0 = clamp(u0, 0.0, 1.0);
		u1 = clamp(u1, 0.0, 1.0);
		float rt = float(N) / VW.x;                    // bloques por segundo (la textura cubre la ventana)
		float ia = float(N - 1) - back(u0) * rt, ib = float(N - 1) - back(u1) * rt;
		if (uW.z > 0.5 && ib < ia) ib = ia;           // la columna cruza el cabezal: solo un lado
		int a = int(floor(min(ia, ib))), b = int(ceil(max(ia, ib)));
		int n = max(b - a, 1);
		int stp = max(n / 96, 1);
		for (int i = 0; i <= 96; i++) {
			int k = a + i * stp;
			if (k > b) break;
			if (k < 0 || k >= N) continue;
			vec3 s = texelFetch(sTD2DInputs[0], ivec2(k, 0), 0).rgb;
			mx = max(mx, s.r);
			mn = min(mn, s.g);
			rms = max(rms, sqrt(max(s.b, 0.0)));
			valid = 1.0;
		}
	}
	if (valid < 0.5) { mn = 0.0; mx = 0.0; }
	fragColor = vec4(mn, mx, rms, valid);
}
wave_glsl_shader glsl · 140 línieslíneaslines
#define PANEL 0
// scopeGEN: común a todos los paneles (fondo, rejilla, cabecera, marco). Alfa premultiplicado.
// Entradas: 1 = estilo (texelFetch(panel, grupo)), 2 = título, 3 = info de la cabecera.
#define STYLE 1
#define TITLE 2
#define INFO 3
vec4 S(int g) { return texelFetch(sTD2DInputs[STYLE], ivec2(PANEL, g), 0); }
void over(inout vec4 c, vec3 rgb, float a) { c = vec4(rgb * a, a) + c * (1.0 - a); }
float inBox(vec2 p, vec4 r) { vec2 d = min(p - r.xy, r.zw - p); return clamp(min(d.x, d.y) + 0.5, 0.0, 1.0); }
float lineCov(float dist, float w) { return clamp(w * 0.5 - dist + 0.5, 0.0, 1.0); }

// rectángulo del contenido (dentro del marco, bajo la cabecera, con padding)
vec4 contentRect(vec2 res)
{
	vec4 f = S(8);                                  // marco, padding, alto cabecera, separador
	return vec4(f.x + f.y, f.x + f.y, res.x - f.x - f.y, res.y - f.x - f.z - f.y);
}

void drawGrid(inout vec4 c, vec2 p, vec4 r)
{
	vec4 g = S(9);                                  // estilo (0 off, 1 lines, 2 dots), x, y, ancho
	if (g.x < 0.5) return;
	vec4 gc = S(7);
	vec2 sz = r.zw - r.xy;
	vec2 q = (p - r.xy) / sz * g.yz;                // en divisiones
	vec2 k = floor(q + 0.5);
	vec2 d = abs(q - k) * sz / g.yz;                // px a la línea más cercana
	bool ix = k.x > 0.5 && k.x < g.y - 0.5, iy = k.y > 0.5 && k.y < g.z - 0.5;
	float a;
	if (g.x < 1.5) a = max(ix ? lineCov(d.x, g.w) : 0.0, iy ? lineCov(d.y, g.w) : 0.0);
	else a = (ix && iy) ? clamp(g.w + 0.5 - length(d), 0.0, 1.0) : 0.0;
	over(c, gc.rgb, a * gc.a * inBox(p, r));
}

void drawChrome(inout vec4 c, vec2 p, vec2 res)
{
	vec4 f = S(8);
	float fw = f.x, hh = f.z, hl = f.w;
	if (hh > 0.5) {
		vec4 hr = vec4(fw, res.y - fw - hh, res.x - fw, res.y - fw);
		float a = inBox(p, hr);
		if (a > 0.0) {
			over(c, S(4).rgb, a);
			vec2 uv = (p - hr.xy) / (hr.zw - hr.xy);
			float t = max(texture(sTD2DInputs[TITLE], uv).a, texture(sTD2DInputs[INFO], uv).a);
			over(c, S(5).rgb, t * a);
		}
		if (hl > 0.0) over(c, S(6).rgb, lineCov(abs(p.y - (hr.y - hl * 0.5)), hl) * step(fw, p.x) * step(p.x, res.x - fw));
	}
	if (fw > 0.0) over(c, S(6).rgb, 1.0 - inBox(p, vec4(fw, fw, res.x - fw, res.y - fw)));
}
// wave_glsl: panel Waveform. Entrada 0 = wave_cols (min, max, rms, válido por columna; la última columna =
// la vista del frame: ventana s, fase del Sweep, beats, beats/s).
uniform vec4 uW;      // ·, ·, modo (0 scroll, 1 sweep), beats por compás
uniform vec4 uV;      // columnas, zoom, centro del zoom, ganancia vertical
uniform vec4 uS;      // estilo (0 filled, 1 outline, 2 bars), forma (0 min/max, 1 mirror), RMS, clipping
uniform vec4 uB;      // ·, ·, líneas de beat, cabezal
out vec4 fragColor;

vec4 colAt(int i) { return texelFetch(sTD2DInputs[0], ivec2(clamp(i, 0, int(uV.x) - 1), 0), 0); }
vec2 shapeOf(vec4 c) { if (uS.y > 0.5) { float m = max(abs(c.x), abs(c.y)); return vec2(-m, m); } return c.xy; }

void main()
{
	vec4 VW = texelFetch(sTD2DInputs[0], ivec2(int(uV.x), 0), 0);
	vec2 res = uTDOutputInfo.res.zw;
	vec2 p = vUV.st * res;
	vec4 bg = S(0);
	vec4 c = vec4(bg.rgb * bg.a, bg.a);
	vec4 r = contentRect(res);
	drawGrid(c, p, r);
	vec2 sz = r.zw - r.xy;
	float u = (p.x - r.x) / sz.x;                   // 0..1 en la vista
	float inside = inBox(p, r);
	vec4 L = S(10);                                 // ancho de línea, opacidad del relleno
	float lw = L.x;
	// líneas de beat / compás (detrás de la onda)
	if (uB.z > 0.5 && VW.w > 0.0) {
		float ud = uV.z + (u - 0.5) / uV.y;
		float d = (uW.z < 0.5 ? (1.0 - ud) : fract(VW.y - ud)) * VW.x;
		float t = VW.z - d * VW.w;
		float k = floor(t + 0.5);
		float pxb = sz.x * uV.y / max(VW.x * VW.w, 1e-3);
		float a = lineCov(abs(t - k) * pxb, S(9).w);
		bool bar = mod(k, max(uW.w, 1.0)) < 0.5;
		over(c, bar ? S(2).rgb : S(3).rgb, a * inside * (bar ? 0.55 : 0.8) * step(4.0, pxb));
	}
	// onda
	float fi = u * uV.x;
	int i = int(floor(fi));
	vec4 cc = colAt(i);
	vec2 v = shapeOf(cc) * uV.w;
	float half_ = sz.y * 0.5, yc = r.y + half_;
	float y0 = yc + clamp(v.x, -1.0, 1.0) * half_, y1 = yc + clamp(v.y, -1.0, 1.0) * half_;
	bool clipd = uS.w > 0.5 && max(abs(v.x), abs(v.y)) >= 0.999;
	vec3 mc = S(1).rgb;
	if (cc.w > 0.5 && u >= 0.0 && u <= 1.0) {
		if (uS.x < 0.5 || uS.x > 1.5) {             // filled / bars
			float bw = sz.x / uV.x;
			float gap = (uS.x > 1.5 && bw >= 3.0) ? step(fract(fi), 0.72) : 1.0;
			float lo = min(y0, y1 - 1.0), hi = max(y1, y0 + 1.0);
			float a = clamp(min(p.y - lo, hi - p.y) + 0.5, 0.0, 1.0) * gap;
			over(c, mc, a * (uS.z > 0.5 ? L.y : 1.0) * inside);   // sin RMS, la onda va opaca
			if (uS.z > 0.5) {
				float rr = cc.z * uV.w * half_;
				float ar = clamp(min(p.y - (yc - rr), (yc + rr) - p.y) + 0.5, 0.0, 1.0) * gap;
				over(c, mc, ar * inside);
			}
		} else {                                     // outline: contornos superior e inferior
			vec2 vp = shapeOf(colAt(i - 1)) * uV.w;
			float a = 0.0;
			for (int s = 0; s < 2; s++) {
				float ya = yc + clamp(s == 0 ? v.y : v.x, -1.0, 1.0) * half_;
				float yb = yc + clamp(s == 0 ? vp.y : vp.x, -1.0, 1.0) * half_;
				float lo = min(ya, yb), hi = max(ya, yb);
				float dist = p.y < lo ? lo - p.y : (p.y > hi ? p.y - hi : 0.0);
				a = max(a, lineCov(dist, lw));
			}
			over(c, mc, a * inside);
			if (uS.z > 0.5) {
				float rr = cc.z * uV.w * half_;
				over(c, mc, clamp(min(p.y - (yc - rr), (yc + rr) - p.y) + 0.5, 0.0, 1.0) * L.y * inside);
			}
		}
		// saturación: una franja (Accent) arriba y abajo de las columnas que llegan a ±1
		if (clipd) {
			float m = max(2.0, lw * 1.5);
			over(c, S(2).rgb, (step(r.w - m, p.y) + step(p.y, r.y + m)) * inside);
		}
	}
	// cabezal
	if (uB.w > 0.5) {
		float uh = uW.z < 0.5 ? 1.0 : (VW.y - uV.z) * uV.y + 0.5;
		float xh = r.x + uh * sz.x - (uW.z < 0.5 ? lw * 0.5 : 0.0);
		if (uh >= 0.0 && uh <= 1.0) over(c, S(2).rgb, lineCov(abs(p.x - xh), lw) * step(r.y, p.y) * step(p.y, r.w));
	}
	drawChrome(c, p, res);
	fragColor = TDOutputSwizzle(c);
}
bands_glsl_shader glsl · 111 línieslíneaslines
#define PANEL 2
// scopeGEN: común a todos los paneles (fondo, rejilla, cabecera, marco). Alfa premultiplicado.
// Entradas: 1 = estilo (texelFetch(panel, grupo)), 2 = título, 3 = info de la cabecera.
#define STYLE 1
#define TITLE 2
#define INFO 3
vec4 S(int g) { return texelFetch(sTD2DInputs[STYLE], ivec2(PANEL, g), 0); }
void over(inout vec4 c, vec3 rgb, float a) { c = vec4(rgb * a, a) + c * (1.0 - a); }
float inBox(vec2 p, vec4 r) { vec2 d = min(p - r.xy, r.zw - p); return clamp(min(d.x, d.y) + 0.5, 0.0, 1.0); }
float lineCov(float dist, float w) { return clamp(w * 0.5 - dist + 0.5, 0.0, 1.0); }

// rectángulo del contenido (dentro del marco, bajo la cabecera, con padding)
vec4 contentRect(vec2 res)
{
	vec4 f = S(8);                                  // marco, padding, alto cabecera, separador
	return vec4(f.x + f.y, f.x + f.y, res.x - f.x - f.y, res.y - f.x - f.z - f.y);
}

void drawGrid(inout vec4 c, vec2 p, vec4 r)
{
	vec4 g = S(9);                                  // estilo (0 off, 1 lines, 2 dots), x, y, ancho
	if (g.x < 0.5) return;
	vec4 gc = S(7);
	vec2 sz = r.zw - r.xy;
	vec2 q = (p - r.xy) / sz * g.yz;                // en divisiones
	vec2 k = floor(q + 0.5);
	vec2 d = abs(q - k) * sz / g.yz;                // px a la línea más cercana
	bool ix = k.x > 0.5 && k.x < g.y - 0.5, iy = k.y > 0.5 && k.y < g.z - 0.5;
	float a;
	if (g.x < 1.5) a = max(ix ? lineCov(d.x, g.w) : 0.0, iy ? lineCov(d.y, g.w) : 0.0);
	else a = (ix && iy) ? clamp(g.w + 0.5 - length(d), 0.0, 1.0) : 0.0;
	over(c, gc.rgb, a * gc.a * inBox(p, r));
}

void drawChrome(inout vec4 c, vec2 p, vec2 res)
{
	vec4 f = S(8);
	float fw = f.x, hh = f.z, hl = f.w;
	if (hh > 0.5) {
		vec4 hr = vec4(fw, res.y - fw - hh, res.x - fw, res.y - fw);
		float a = inBox(p, hr);
		if (a > 0.0) {
			over(c, S(4).rgb, a);
			vec2 uv = (p - hr.xy) / (hr.zw - hr.xy);
			float t = max(texture(sTD2DInputs[TITLE], uv).a, texture(sTD2DInputs[INFO], uv).a);
			over(c, S(5).rgb, t * a);
		}
		if (hl > 0.0) over(c, S(6).rgb, lineCov(abs(p.y - (hr.y - hl * 0.5)), hl) * step(fw, p.x) * step(p.x, res.x - fw));
	}
	if (fw > 0.0) over(c, S(6).rgb, 1.0 - inBox(p, vec4(fw, fw, res.x - fw, res.y - fw)));
}
// bands_glsl: panel Bands. Entrada 0 = bands_data (Bands × 1: nivel, pico).
uniform vec4 uB;      // bandas, estilo (0 bars, 1 segments, 2 line), segmentos, hueco
uniform vec4 uQ;      // pico on, ·, ·, ·
out vec4 fragColor;

vec4 bd(int k) { return texelFetch(sTD2DInputs[0], ivec2(clamp(k, 0, int(uB.x) - 1), 0), 0); }

void main()
{
	vec2 res = uTDOutputInfo.res.zw;
	vec2 p = vUV.st * res;
	vec4 bg = S(0);
	vec4 c = vec4(bg.rgb * bg.a, bg.a);
	vec4 r = contentRect(res);
	drawGrid(c, p, r);
	vec2 sz = r.zw - r.xy;
	float inside = inBox(p, r);
	vec4 L = S(10);
	float lw = L.x;
	float n = uB.x;
	float cw = sz.x / n;
	float fk = (p.x - r.x) / cw;
	int k = int(floor(fk));
	vec4 b = bd(k);
	float gap = uB.w * 0.5;
	float x0 = r.x + (float(k) + gap) * cw, x1 = r.x + (float(k) + 1.0 - gap) * cw;
	vec3 mc = S(1).rgb;
	if (uB.y < 0.5) {                            // bars
		over(c, mc, inBox(p, vec4(x0, r.y, x1, r.y + b.x * sz.y)) * inside);
	} else if (uB.y < 1.5) {                     // segments (LED): encendidos Motif, apagados Dim
		float S_ = uB.z;
		float sh = sz.y / S_;
		float s = floor((p.y - r.y) / sh);
		float g = max(1.0, sh * uB.w * 0.5);
		float a = inBox(p, vec4(x0, r.y + s * sh + g * 0.5, x1, r.y + (s + 1.0) * sh - g * 0.5));
		bool lit = (s + 0.5) / S_ <= b.x;
		over(c, lit ? mc : S(3).rgb, a * inside);
	} else {                                     // line: por los centros de las bandas, con relleno debajo
		float d = 1e9;
		float yv = r.y;
		for (int j = -1; j <= 1; j++) {
			int q = int(floor(fk - 0.5)) + j;
			vec2 A = vec2(r.x + (float(q) + 0.5) * cw, r.y + bd(q).x * sz.y);
			vec2 B = vec2(r.x + (float(q) + 1.5) * cw, r.y + bd(q + 1).x * sz.y);
			vec2 ab = B - A;
			float t = clamp(dot(p - A, ab) / max(dot(ab, ab), 1e-6), 0.0, 1.0);
			d = min(d, length(p - (A + ab * t)));
			if (p.x >= A.x && p.x < B.x) yv = mix(A.y, B.y, (p.x - A.x) / max(B.x - A.x, 1e-6));
		}
		over(c, mc, clamp(yv - p.y + 0.5, 0.0, 1.0) * step(r.y, p.y) * L.y * inside);
		over(c, mc, lineCov(d, lw) * inside);
	}
	if (uQ.x > 0.5 && b.y > 0.002) {             // pico: raya Accent
		float yp = r.y + b.y * sz.y;
		over(c, S(2).rgb, lineCov(abs(p.y - yp), max(lw, 1.0)) * step(x0, p.x) * step(p.x, x1) * inside);
	}
	drawChrome(c, p, res);
	fragColor = TDOutputSwizzle(c);
}
scope_glsl_shader glsl · 114 línieslíneaslines
#define PANEL 1
// scopeGEN: común a todos los paneles (fondo, rejilla, cabecera, marco). Alfa premultiplicado.
// Entradas: 1 = estilo (texelFetch(panel, grupo)), 2 = título, 3 = info de la cabecera.
#define STYLE 1
#define TITLE 2
#define INFO 3
vec4 S(int g) { return texelFetch(sTD2DInputs[STYLE], ivec2(PANEL, g), 0); }
void over(inout vec4 c, vec3 rgb, float a) { c = vec4(rgb * a, a) + c * (1.0 - a); }
float inBox(vec2 p, vec4 r) { vec2 d = min(p - r.xy, r.zw - p); return clamp(min(d.x, d.y) + 0.5, 0.0, 1.0); }
float lineCov(float dist, float w) { return clamp(w * 0.5 - dist + 0.5, 0.0, 1.0); }

// rectángulo del contenido (dentro del marco, bajo la cabecera, con padding)
vec4 contentRect(vec2 res)
{
	vec4 f = S(8);                                  // marco, padding, alto cabecera, separador
	return vec4(f.x + f.y, f.x + f.y, res.x - f.x - f.y, res.y - f.x - f.z - f.y);
}

void drawGrid(inout vec4 c, vec2 p, vec4 r)
{
	vec4 g = S(9);                                  // estilo (0 off, 1 lines, 2 dots), x, y, ancho
	if (g.x < 0.5) return;
	vec4 gc = S(7);
	vec2 sz = r.zw - r.xy;
	vec2 q = (p - r.xy) / sz * g.yz;                // en divisiones
	vec2 k = floor(q + 0.5);
	vec2 d = abs(q - k) * sz / g.yz;                // px a la línea más cercana
	bool ix = k.x > 0.5 && k.x < g.y - 0.5, iy = k.y > 0.5 && k.y < g.z - 0.5;
	float a;
	if (g.x < 1.5) a = max(ix ? lineCov(d.x, g.w) : 0.0, iy ? lineCov(d.y, g.w) : 0.0);
	else a = (ix && iy) ? clamp(g.w + 0.5 - length(d), 0.0, 1.0) : 0.0;
	over(c, gc.rgb, a * gc.a * inBox(p, r));
}

void drawChrome(inout vec4 c, vec2 p, vec2 res)
{
	vec4 f = S(8);
	float fw = f.x, hh = f.z, hl = f.w;
	if (hh > 0.5) {
		vec4 hr = vec4(fw, res.y - fw - hh, res.x - fw, res.y - fw);
		float a = inBox(p, hr);
		if (a > 0.0) {
			over(c, S(4).rgb, a);
			vec2 uv = (p - hr.xy) / (hr.zw - hr.xy);
			float t = max(texture(sTD2DInputs[TITLE], uv).a, texture(sTD2DInputs[INFO], uv).a);
			over(c, S(5).rgb, t * a);
		}
		if (hl > 0.0) over(c, S(6).rgb, lineCov(abs(p.y - (hr.y - hl * 0.5)), hl) * step(fw, p.x) * step(p.x, res.x - fw));
	}
	if (fw > 0.0) over(c, S(6).rgb, 1.0 - inBox(p, vec4(fw, fw, res.x - fw, res.y - fw)));
}
// scope_glsl: panel Scope. Entrada 0 = scope_data (Points × 1: min, max, valor).
uniform vec4 uP;      // puntos, estilo (0 line, 1 dots, 2 filled), ganancia vertical, ·
out vec4 fragColor;

vec4 pt(int i) { return texelFetch(sTD2DInputs[0], ivec2(clamp(i, 0, int(uP.x) - 1), 0), 0); }

float segDist(vec2 p, vec2 a, vec2 b)
{
	vec2 ab = b - a;
	float t = clamp(dot(p - a, ab) / max(dot(ab, ab), 1e-6), 0.0, 1.0);
	return length(p - (a + ab * t));
}

void main()
{
	vec2 res = uTDOutputInfo.res.zw;
	vec2 p = vUV.st * res;
	vec4 bg = S(0);
	vec4 c = vec4(bg.rgb * bg.a, bg.a);
	vec4 r = contentRect(res);
	drawGrid(c, p, r);
	vec2 sz = r.zw - r.xy;
	float inside = inBox(p, r);
	vec4 L = S(10);
	float lw = L.x;
	float n = uP.x;
	float dx = sz.x / max(n - 1.0, 1.0);
	float half_ = sz.y * 0.5, yc = r.y + half_;
	float fi = (p.x - r.x) / dx;
	int i = int(floor(fi + 0.5));
	vec3 mc = S(1).rgb;
	if (uP.y < 0.5 || uP.y > 1.5) {              // line / filled
		float d = 1e9;
		for (int k = -2; k <= 1; k++) {
			vec4 A = pt(i + k), B = pt(i + k + 1);
			vec2 a = vec2(r.x + float(i + k) * dx, yc + clamp(A.z * uP.z, -1.0, 1.0) * half_);
			vec2 b = vec2(r.x + float(i + k + 1) * dx, yc + clamp(B.z * uP.z, -1.0, 1.0) * half_);
			d = min(d, segDist(p, a, b));
			// densidad dentro del punto (min..max): una raya vertical fina
			float y0 = yc + clamp(A.x * uP.z, -1.0, 1.0) * half_, y1 = yc + clamp(A.y * uP.z, -1.0, 1.0) * half_;
			float dv = max(abs(p.x - a.x), max(y0 - p.y, p.y - y1));
			d = min(d, max(dv, 0.0) + lw * 0.25);
		}
		if (uP.y > 1.5) {
			vec4 A = pt(int(floor(fi))), B = pt(int(floor(fi)) + 1);
			float yv = yc + clamp(mix(A.z, B.z, fract(fi)) * uP.z, -1.0, 1.0) * half_;
			float lo = min(yc, yv), hi = max(yc, yv);
			over(c, mc, clamp(min(p.y - lo, hi - p.y) + 0.5, 0.0, 1.0) * L.y * inside);
		}
		over(c, mc, lineCov(d, lw) * inside);
	} else {                                     // dots
		float d = 1e9;
		for (int k = -1; k <= 1; k++) {
			vec4 A = pt(i + k);
			vec2 a = vec2(r.x + float(i + k) * dx, yc + clamp(A.z * uP.z, -1.0, 1.0) * half_);
			d = min(d, length(p - a));
		}
		over(c, mc, clamp(lw * 0.75 + 0.5 - d, 0.0, 1.0) * inside);
	}
	drawChrome(c, p, res);
	fragColor = TDOutputSwizzle(c);
}
bars_data_callbacks python · 55 línieslíneaslines
# bars_data (Script TOP): golpes del audio por paso del ciclo de Bars (Bars × Beats per Bar × Steps per Beat).
# Al pasar el cabezal por un paso se borra lo que tenía (del ciclo anterior); un golpe (el pico del trozo de
# audio del frame supera Hit Level viniendo de abajo, mínimo 0,12 s entre golpes) marca el paso actual.
# Textura pasos × 1: r = golpe. Con Freeze no cambia.
import numpy as np

STATE = {}


def onSetupParameters(scriptOp):
	return


def onPulse(par):
	return


def onCook(scriptOp):
	comp = scriptOp.parent()
	p = comp.par
	u = comp.op('util').module
	bpb = max(int(p.Beatsperbar.eval()), 1)
	sub = int(p.Barssub.eval())
	span = int(p.Barscount.eval()) * bpb
	steps = span * sub
	st = STATE.get(scriptOp.path)
	if st is None or st['key'] != steps:
		st = {'key': steps, 'img': np.zeros((1, steps, 4), dtype=np.float32), 'last': -1, 'pk': 0.0, 't': -1e9}
		STATE[scriptOp.path] = st
	img = st['img']
	if not p.Freeze.eval():
		b = u.beats(comp)
		s = int(((b % span) / span) * steps) % steps
		last = st['last']
		if s != last:                               # borrar los pasos que acaba de recorrer el cabezal
			k = (last + 1) % steps if last >= 0 else s
			for _ in range(steps):
				img[0, k, 0] = 0.0
				if k == s:
					break
				k = (k + 1) % steps
			st['last'] = s
		if p.Barshits.eval():
			a = comp.op('null_aud')
			pk = float(np.abs(a[0].numpyArray()).max()) if a is not None and a.numChans and a.numSamples else 0.0
			lv = float(p.Barshitlevel.eval())
			now = absTime.seconds
			if pk >= lv and st['pk'] < lv and now - st['t'] > 0.12:
				img[0, s, 0] = 1.0
				st['t'] = now
			st['pk'] = pk
	img[0, :, 3] = 1.0
	scriptOp.copyNumpyArray(img)
	return
wave_data_callbacks python · 55 línieslíneaslines
# wave_data (Script TOP): anillo de bloques del Waveform en numpy, escrito directamente en la textura.
# Cada cook lee el trozo de audio del frame (null_aud), lo parte en bloques de B muestras (lo que sobra espera
# al siguiente) y guarda max / min / media de x² de los últimos NB bloques (la ventana; NB ≤ 4096, hasta
# 1000 bloques/s). Texel NB (el último) = la vista del frame: ventana (s), fase del Sweep, beats, beats/s,
# para que los shaders no necesiten expresiones Python por frame. Con Freeze no cambia nada.
import numpy as np

NBMAX = 4096
STATE = {}                                      # por ruta del Script TOP (no en su storage: escribirlo
                                                # durante el cook es un bucle de dependencias)


def onSetupParameters(scriptOp):
	return


def onPulse(par):
	return


def onCook(scriptOp):
	comp = scriptOp.parent()
	u = comp.op('util').module
	a = comp.op('null_aud')
	sr = float(a.rate) if a is not None and a.numChans else 44100.0
	w = u.wave_window(comp)
	nb = int(max(32, min(NBMAX, w * 1000.0)))
	B = max(1, int(round(sr * w / nb)))
	key = (sr, B, nb)
	st = STATE.get(scriptOp.path)
	if st is None or st['key'] != key:
		st = {'key': key, 'img': np.zeros((1, nb + 1, 4), dtype=np.float32), 'left': np.zeros(0, dtype=np.float32)}
	img = st['img']
	if not comp.par.Freeze.eval():
		if a is not None and a.numChans:
			buf = np.concatenate((st['left'], a[0].numpyArray()))
			k = len(buf) // B
			if k:
				blk = buf[:k * B].reshape(k, B)
				new = np.stack((blk.max(axis=1), blk.min(axis=1), (blk * blk).mean(axis=1)), axis=1)
				ring = img[0, :nb, :3]
				if k >= nb:
					ring[:] = new[-nb:]
				else:
					ring[:-k] = ring[k:]
					ring[-k:] = new
			st['left'] = buf[k * B:]
		b = u.beats(comp)
		span = u.wave_span(comp)
		ph = (b % span) / span if span > 0 else (u.seconds(comp) % w) / w
		img[0, nb] = (w, ph, b, u.rate(comp))
	STATE[scriptOp.path] = st
	scriptOp.copyNumpyArray(img)
	return
bands_data_callbacks python · 78 línieslíneaslines
# bands_data (Script TOP): espectro por bandas. FFT (ventana de Hann) de las últimas FFT Size muestras; bandas
# log (por octavas) o lineales entre Min y Max Frequency (en cada banda, el máximo de sus bins; si es más
# estrecha que un bin, el bin más cercano); dB + Tilt (dB / octava respecto a 1 kHz) → 0..1 entre Floor y 0 dB;
# subida / caída exponenciales (Rise / Fall s) y pico con retención (Hold) y caída lineal.
# Textura Bands × 1: r nivel, g pico. Con Freeze no cambia.
import numpy as np

STATE = {}


def onSetupParameters(scriptOp):
	return


def onPulse(par):
	return


def onCook(scriptOp):
	comp = scriptOp.parent()
	p = comp.par
	a = comp.op('null_aud')
	sr = float(a.rate) if a is not None and a.numChans else 44100.0
	n = int(p.Bandscount.eval())
	N = int(p.Bandsfft.eval())
	st = STATE.get(scriptOp.path)
	if st is None or st['key'] != (sr, N, n):
		st = {'key': (sr, N, n), 'buf': np.zeros(N, dtype=np.float32), 'win': np.hanning(N).astype(np.float32),
			  'lvl': np.zeros(n, dtype=np.float32), 'pk': np.zeros(n, dtype=np.float32),
			  'pkt': np.zeros(n, dtype=np.float32), 't': absTime.seconds, 'img': np.zeros((1, n, 4), dtype=np.float32)}
		STATE[scriptOp.path] = st
	now = absTime.seconds
	dt = min(max(now - st['t'], 0.0), 0.25)
	st['t'] = now
	if not p.Freeze.eval():
		if a is not None and a.numChans:
			x = a[0].numpyArray()
			b = st['buf']
			if len(x) >= N:
				b[:] = x[-N:]
			elif len(x):
				b[:-len(x)] = b[len(x):]
				b[-len(x):] = x
		w = st['win']
		spec = np.abs(np.fft.rfft(st['buf'] * w)) * (2.0 / w.sum())
		bk = (float(p.Bandsfmin.eval()), float(p.Bandsfmax.eval()), p.Bandsscale.eval(), float(p.Bandstilt.eval()))
		if st.get('bk') != bk:                   # bordes de las bandas e inclinación: solo al cambiar los pars
			f0 = max(bk[0], 1.0)
			f1 = max(bk[1], f0 * 1.01)
			edges = np.geomspace(f0, f1, n + 1) if bk[2] == 'log' else np.linspace(f0, f1, n + 1)
			idx = np.minimum(np.searchsorted(np.fft.rfftfreq(N, 1.0 / sr), edges), len(spec) - 1)
			st['idx'] = idx.astype(np.int64)
			st['tilt'] = (bk[3] * np.log2(np.sqrt(edges[:-1] * edges[1:]) / 1000.0)).astype(np.float32)
			st['bk'] = bk
		# máximo de los bins de cada banda (bordes contiguos); una banda más estrecha que un bin toma su bin
		v = np.maximum.reduceat(spec, st['idx'])[:n]
		db = 20.0 * np.log10(v + 1e-9) + st['tilt']
		lo = float(p.Bandsdbmin.eval())
		tgt = np.clip((db - lo) / -lo, 0.0, 1.0).astype(np.float32)
		lvl = st['lvl']
		rise, fall = float(p.Bandsrise.eval()), float(p.Bandsfall.eval())
		ar = 1.0 if rise <= 1e-4 else 1.0 - np.exp(-dt / rise)
		af = 1.0 if fall <= 1e-4 else 1.0 - np.exp(-dt / fall)
		lvl += (tgt - lvl) * np.where(tgt > lvl, ar, af)
		pk, pkt = st['pk'], st['pkt']
		up = lvl >= pk
		pk[up] = lvl[up]
		pkt[up] = now
		old = (~up) & (now - pkt > float(p.Bandspeakhold.eval()))
		pk[old] -= float(p.Bandspeakfall.eval()) * dt
		np.maximum(pk, lvl, out=pk)
		img = st['img']
		img[0, :, 0] = lvl
		img[0, :, 1] = pk
		img[0, :, 3] = 1.0
	scriptOp.copyNumpyArray(st['img'])
	return
scope_data_callbacks python · 61 línieslíneaslines
# scope_data (Script TOP): los últimos Window ms del audio para el Scope, reducidos a Points puntos.
# Guarda las últimas 3 ventanas; con Trigger = Rising, la ventana empieza en el último cruce por cero ascendente
# que deja una ventana completa (la onda se queda quieta); si no hay, la más reciente.
# Textura Points × 1: r min, g max, b valor del punto. Con Freeze no cambia.
import numpy as np

STATE = {}


def onSetupParameters(scriptOp):
	return


def onPulse(par):
	return


def onCook(scriptOp):
	comp = scriptOp.parent()
	p = comp.par
	a = comp.op('null_aud')
	sr = float(a.rate) if a is not None and a.numChans else 44100.0
	W = max(2, int(sr * p.Scopewindow.eval() / 1000.0))
	pts = int(p.Scopepoints.eval())
	R = W * 3
	st = STATE.get(scriptOp.path)
	if st is None or st['key'] != (sr, R, pts):
		st = {'key': (sr, R, pts), 'buf': np.zeros(R, dtype=np.float32), 'img': np.zeros((1, pts, 4), dtype=np.float32)}
		STATE[scriptOp.path] = st
	if not p.Freeze.eval():
		if a is not None and a.numChans:
			x = a[0].numpyArray()
			b = st['buf']
			if len(x) >= R:
				b[:] = x[-R:]
			elif len(x):
				b[:-len(x)] = b[len(x):]
				b[-len(x):] = x
		b = st['buf']
		start = R - W
		if p.Scopetrigger.eval() == 'rising':
			z = np.nonzero((b[:-1] < 0.0) & (b[1:] >= 0.0))[0] + 1
			z = z[z <= R - W]
			if len(z):
				start = int(z[-1])
		seg = b[start:start + W]
		img = st['img']
		if W >= pts:
			e = np.linspace(0, W, pts + 1).astype(np.int64)
			img[0, :, 0] = np.minimum.reduceat(seg, e[:-1])
			img[0, :, 1] = np.maximum.reduceat(seg, e[:-1])
			img[0, :, 2] = seg[np.minimum((e[:-1] + e[1:]) // 2, W - 1)]
		else:
			v = np.interp(np.linspace(0.0, W - 1.0, pts), np.arange(W), seg)
			img[0, :, 0] = v
			img[0, :, 1] = v
			img[0, :, 2] = v
		img[0, :, 3] = 1.0
	scriptOp.copyNumpyArray(st['img'])
	return

Aquesta part és en castellà.This part is in Spanish.

Decisiones de diseño
  • Un módulo, un panel por salida (el autor: "cada visualización en una salida por separado" para componerlas luego): mismo audio, mismo reloj y mismo estilo; cada panel con Enable para no gastar.
  • Estilo común, colores por panel limitados a Background, Motif y Header Background (el autor: los de la "interfaz" — Accent, Dim, Header Text, Frame, Grid — comunes); tamaño por panel o común.
  • Datos en texturas, Python solo donde hay cálculo: los Script TOP (numpy) hacen el trabajo por frame (bloques, FFT, golpes) y escriben la textura directamente; lo que cambia cada frame (fase, beats) viaja en la textura o por uniform array desde un CHOP. Los uniforms por expresión solo leen parámetros.
  • Waveform en dos pasadas: columnas (1 × Resolution) y dibujo; el cálculo de mín. / máx. se hace una vez por columna, no por píxel.
  • Scope quieto con disparo en el cruce por cero (como un osciloscopio), reducido a puntos con min / max para no perder detalle.
  • Bands en dB con inclinación (+3 dB / octava por defecto: la música cae hacia los agudos).
  • BPM, Dial y Bars del reloj común (Sync Timeline / Manual / Free), como el resto de la librería.
  • Tile = vista previa de los paneles activos: se ve el conjunto sin abrir cada salida.
  • Export desde un COMP montado de cero (build1 → 2 → 3) con los valores del autor copiados por nombre: las páginas salen con los parámetros en su orden.
Lo que falló y cómo se arregló
SíntomaCausaSolución
Envolvente del Waveform con max < min y nº de muestras raroEl Envelope CHOP con remuestreo no es un min / max por bloquesScript TOP con numpy (bloques exactos)
Trail del audio en bruto inviable para 30 s30 s × 44,1 kHz = 1,3 M muestras por frameAnillo de bloques (≤ 4096)
La salida del Script CHOP no se actualizaba, sin errornumChans no se puede leer durante su cook (excepción silenciosa)Estado propio; luego Script TOP
"Cook dependency loop" en wave_datastore en el storage del propio Script TOP durante su cookDict del módulo de callbacks por ruta
~1,1 ms de CPU por el WaveformScript CHOP + CHOP to TOP + expresiones Python por frame en los uniformsScript TOP directo a textura + la vista en un texel: 0,33 ms
Bands 0,49 msBucle Python por bandanp.maximum.reduceat sobre bordes contiguos y cacheados: 0,27 ms
Run Script de build1 avisaba de una excepción tras "hecho"Destruir y recrear páginas rompía un instante las expresiones de los otros panelesCrear o actualizar parámetros, sin destruir páginas
build1 en un COMP vacío: RecursionErrorUna sustitución automática cambió comp.appendCustomPage por page dentro de page()Corregido; probar los builds también en un COMP vacío
"Show Grid" de BPM / Dial / Bars no aparecíaBpmgrid chocaba con la tupla de color Bpmgrid (r, g, b) y TD lo descartaba (#295)…showgrid
"Invalid Par object" al quitar colores por panelDestruir el primer par de una tupla se lleva la tupla enteraDestruirla una sola vez
Steps per Beat = 2 se comportaba como 1En una expresión numérica, un menú devuelve su índicefloat(par.eval())
bpm_pos cocinaba cada frame (0,29 ms)Su texto por expresión dependía del relojLo escribe un CHOP Execute al cambiar el beat
Posición 9888.3El reloj común cuenta desde que se abrió TDcompás.beat dentro del ciclo de Bars
Waveform: columnas saturadas tapaban la ondaToda la columna en AccentFranja Accent arriba y abajo
Cuánto cuesta

Máquina del autor, música de los Samples de TD (44,1 kHz), mediana de 240 frames con el cook forzado:

PanelCPUGPU
Waveform 1280 × 320 (wave_data + wave_cols + wave_glsl)0,33 + 0,08 + 0,07 ms0,07 + 0,17 ms
Scope 1280 × 3200,21 + 0,06 ms0,16 ms
Bands 1280 × 320, FFT 40960,27 + 0,06 ms0,10 ms
BPM 640 × 2400,06 ms (+ los Text TOP solo al cambiar)0,02 ms
Dial 480 × 4800,05 ms0,03 ms
Bars 1280 × 2000,12 + 0,07 ms0,02 ms

Un panel apagado: 0. El tile solo cocina si se ve el nodo.