Created
June 6, 2025 21:03
-
-
Save mbutler/2758deaa8c7cfe2b9224eb8383d06ac8 to your computer and use it in GitHub Desktop.
UAP Dog Whistle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://x.com/jasonwilde108/status/1910816547070685522 | |
import numpy as np | |
from scipy.signal import chirp | |
from pydub import AudioSegment | |
from pydub.generators import Sine, WhiteNoise | |
SAMPLE_RATE = 44100 # CD quality | |
DURATION = 60 # seconds of output | |
VOLUME = -20 # dBFS | |
def make_sine(frequency, duration, volume_db): | |
tone = Sine(frequency).to_audio_segment(duration=duration * 1000).apply_gain(volume_db) | |
return tone | |
def make_white_breath(duration, volume_db): | |
white = WhiteNoise().to_audio_segment(duration=duration * 1000).apply_gain(volume_db) | |
# Shape the white noise to feel "alive" | |
# Use a very slow amplitude LFO mod | |
samples = np.array(white.get_array_of_samples()).astype(np.float32) | |
mod = (np.sin(2 * np.pi * np.linspace(0, duration, len(samples)) * 0.2) + 1) / 2 | |
mod = 0.6 + 0.4 * mod # soft envelope between 0.6–1 | |
modulated = (samples * mod).astype(np.int16) | |
mod_segment = white._spawn(modulated.tobytes()) | |
return mod_segment.set_frame_rate(SAMPLE_RATE).apply_gain(volume_db) | |
def make_17khz_pings(duration, interval, pulse_duration_ms, volume_db): | |
# Ultrasonic ping every `interval` seconds | |
result = AudioSegment.silent(duration=duration * 1000) | |
ping = Sine(17000).to_audio_segment(duration=pulse_duration_ms).apply_gain(volume_db) | |
for i in range(0, duration, interval): | |
result = result.overlay(ping, position=i * 1000) | |
return result | |
def make_2_5k_chirps(duration, interval, chirp_duration_ms, volume_db): | |
# Organic chirp, e.g. a rising tone | |
result = AudioSegment.silent(duration=duration * 1000) | |
for i in range(0, duration, interval): | |
t = np.linspace(0, chirp_duration_ms / 1000, int(SAMPLE_RATE * chirp_duration_ms / 1000)) | |
sweep = chirp(t, f0=2000, f1=3000, t1=t[-1], method='linear') | |
sweep_int16 = np.int16(sweep * 32767) | |
sweep_segment = AudioSegment( | |
sweep_int16.tobytes(), | |
frame_rate=SAMPLE_RATE, | |
sample_width=2, | |
channels=1 | |
).apply_gain(volume_db) | |
result = result.overlay(sweep_segment, position=i * 1000) | |
return result | |
# Layers | |
carrier_7_83 = make_sine(7.83, DURATION, VOLUME) | |
harmonic_528 = make_sine(528, DURATION, VOLUME + 2) | |
ambient_432 = make_sine(432, DURATION, VOLUME + 1) | |
ultrasonic_17k = make_17khz_pings(DURATION, interval=5, pulse_duration_ms=150, volume_db=VOLUME - 5) | |
chirps_2_5k = make_2_5k_chirps(DURATION, interval=10, chirp_duration_ms=400, volume_db=VOLUME - 3) | |
breath_layer = make_white_breath(DURATION, VOLUME - 8) | |
# Mix all together | |
combined = carrier_7_83.overlay(harmonic_528) | |
combined = combined.overlay(ambient_432) | |
combined = combined.overlay(ultrasonic_17k) | |
combined = combined.overlay(chirps_2_5k) | |
combined = combined.overlay(breath_layer) | |
# Export | |
combined.export("layered_output.wav", format="wav") | |
print("Exported 'layered_output.wav'") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment