Files
backspace/tools/sfx/notif.py
T
devsyncwrldandClaude Opus 5 1fb61377b9
OpenSSF Scorecard / Scorecard analysis (push) Waiting to run
CI / Build & test (Node 20) (push) Canceled after 0s
CI / Build & test (Node 24) (push) Canceled after 0s
CI / Build & test (push) Canceled after 0s
CodeQL / Analyze (javascript-typescript) (push) Canceled after 0s
Security / Secret scan (gitleaks) (push) Canceled after 0s
Security / Dependency scan (OSV-Scanner) (push) Canceled after 0s
Security / IaC/config scan (Trivy) (push) Canceled after 0s
Security / License compliance scan (Trivy) (push) Canceled after 0s
feat(notify): in-app notifications with the app's own sound
The system balloon carries the OS notification sound, which does not belong to
this app, and it only fired while the window was out of focus — with the app
focused nothing appeared at all.

Notifications now surface inside the window, carry the same synthesised timbre
as the rest of the app's sounds, and clicking one opens the channel. The native
balloon is kept for when the window is not visible, since an in-app card
nobody can see is no notification, but it is now silent: the app plays its own
effect instead.

A focused window is notified only about other channels — announcing the
conversation someone is already reading is noise.

Also fixes the Gitea publish cleanup, which silently deleted nothing: it
interpolated an Actions expression inside a bash , and when the pattern
did not match, the loop passed over every asset. The release ended with two
latest.yml files and the updater served the older one, reporting 1.1.0 as
current — an update that exists but is never offered, with no error anywhere.
The filter is plain bash now, logs what it found, and the job fails if more
than one latest.yml survives.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-01 18:57:02 -03:00

36 lines
1.3 KiB
Python

import math, wave, struct
SR=48000
HARM=(1.00, 0.85, 0.10, 0.02) # timbre medido nas referencias aprovadas
def note(f, dur, tau, amp=1.0):
n=int(SR*dur); o=[]
for i in range(n):
t=i/SR
s=sum(a*math.sin(2*math.pi*f*(k+1)*t) for k,a in enumerate(HARM))
o.append(s*amp*min(1.0,t/0.004)*math.exp(-t/tau))
return o
def mix(layers,total):
b=[0.0]*total
for off,s in layers:
for i,v in enumerate(s):
if off+i<total: b[off+i]+=v
return b
def peak_rms(x, win=int(SR*0.01)):
return max(math.sqrt(sum(v*v for v in x[i:i+win])/win) for i in range(0,len(x)-win,win))
def write(name, buf, target):
g=target/max(1e-9,peak_rms(buf))
pk=max(abs(s*g) for s in buf)
if pk>0.97: g*=0.97/pk
with wave.open(name,'w') as w:
w.setnchannels(1); w.setsampwidth(2); w.setframerate(SR)
w.writeframes(b''.join(struct.pack('<h',int(max(-1,min(1,s*g))*32767)) for s in buf))
print(f"{name}: pico RMS {peak_rms([s*g for s in buf]):.3f}, {len(buf)/SR:.2f}s")
G4, C5 = 392.00, 523.25
# Duas notas subindo, curtas e discretas: mensagem chega o tempo todo, entao
# tem de ser mais leve que entrar numa call.
write('notification.wav', mix([(0, note(G4,0.34,0.13)), (int(SR*0.065), note(C5,0.36,0.12))], int(SR*0.46)), 0.22)