Skip to content

Instantly share code, notes, and snippets.

@19wintersp
Created May 3, 2024 23:35
Show Gist options
  • Save 19wintersp/f775b2352c91033abc623643a1d4e1f9 to your computer and use it in GitHub Desktop.
Save 19wintersp/f775b2352c91033abc623643a1d4e1f9 to your computer and use it in GitHub Desktop.
ATC VHF radio simulation for Audacity
;nyquist plug-in
;version 4
;type process
;name "VHF RTF"
;release "0.2.0"
;control text "Process audio to imitate VHF radio reception"
;control text "Filters derived from pierr3/afv-native"
;control preset "Filter preset" choice "Schmid ED137B,Garex 220,Rockwell Collins 2100" 0
;control pregain "Pre-scale" float nil 1.0 0.0 1.0
;; I have not used Nyquist before, so this is pretty awful
(defun peaking (track centre q gain)
(let*
(
(w0 (/ (* 2 pi centre) *sound-srate*))
(cosw0 (cos w0))
(sinw0 (sin w0))
(alpha (/ sinw0 2 q))
(a (expt 10 (/ gain 40)))
)
(let
(
(b0 (+ 1 (* alpha a)))
(b1 (* -2 cosw0))
(b2 (- 1 (* alpha a)))
(a0 (+ 1 (/ alpha a)))
(a1 (* -2 cosw0))
(a2 (- 1 (/ alpha a)))
)
(biquad-m track b0 b1 b2 a0 a1 a2))))
(defun apply-filters (track filters)
(if (null filters)
track
(apply-filters (eval (car filters)) (cdr filters))))
(apply-filters
(scale pregain
(if (arrayp *track*)
(scale 0.5 (to-mono *track*))
*track*))
(nth preset
(list
;; Schmid ED137B
(list
'(highpass2 track 310 0.25)
'(peaking track 450 0.75 12.0)
'(peaking track 1450 1.0 20.0)
'(peaking track 2000 1.0 20.0)
'(lowpass2 track 2500 0.25))
;; Garex 220
(list
'(highpass2 track 300 0.25)
'(eq-highshelf track 400 8)
'(eq-highshelf track 600 4)
'(eq-lowshelf track 2000 1)
'(eq-lowshelf track 2400 3)
'(eq-lowshelf track 3000 10)
'(lowpass2 track 3400 0.25))
;; Rockwell Collins 2100
(list
'(biquad-m track -0.01 0.0 0.0 1.0 0.0 0.0)
'(biquad-m track 0.0 1.0 0.75316 1.0 -1.7153 0.76139)
'(biquad-m track 1.0 -2.2928 1.0003 1.0 -1.7163 0.76243)
'(biquad-m track 1.0 -2.0504 1.0505 1.0 -1.7938 0.90968)
'(biquad-m track 1.0 -1.9519 0.95194 1.0 -1.7941 0.90982)
'(biquad-m track 1.0 -1.8255 1.0916 1.0 -1.9390 0.94118)
'(biquad-m track 1.0 -1.6724 0.91618 1.0 -1.9402 0.94263)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment