Skip to content

Instantly share code, notes, and snippets.

@TobiObeck
Forked from ianoxley/smokeonthewater.py
Last active December 8, 2021 23:14
Show Gist options
  • Save TobiObeck/5bb4922b8c4b3cfcb48fcb80a394d633 to your computer and use it in GitHub Desktop.
Save TobiObeck/5bb4922b8c4b3cfcb48fcb80a394d633 to your computer and use it in GitHub Desktop.
Plays "Smoke on the Water" with Python
# plays smoke on the water with windows sounds
# for linux or mac:
# import os
# duration, freq = 1, 440 # 1 second, 440Hz
# os.system('play -nq -t alsa synth {} sine {}'.format(duration, freq))
# how to play a sound in python: https://stackoverflow.com/a/16573339/6710876
# original by https://gist.github.com/ianoxley/3417873
# minor changes by me: 1.) 200 durations to 300. 2.) shortened sleep(0.5) to sleep(0.1)
import winsound
FREQ_A = 440
FREQ_G = 392
FREQ_B_FLAT = 466
FREQ_C = 523
FREQ_C_SHARP = 554
winsound.Beep(FREQ_G, 300)
sleep(0.25)
winsound.Beep(FREQ_B_FLAT, 300)
sleep(0.25)
winsound.Beep(FREQ_C, 700)
sleep(0.12)
winsound.Beep(FREQ_G, 300)
sleep(0.25)
winsound.Beep(FREQ_B_FLAT, 300)
sleep(0.25)
winsound.Beep(FREQ_C_SHARP, 150)
sleep(0.1)
winsound.Beep(FREQ_C, 650)
sleep(0.25)
winsound.Beep(FREQ_G, 300)
sleep(0.25)
winsound.Beep(FREQ_B_FLAT, 300)
sleep(0.25)
winsound.Beep(FREQ_C, 500)
sleep(0.25)
winsound.Beep(FREQ_B_FLAT, 300)
sleep(0.25)
winsound.Beep(FREQ_G, 1000)
sleep(0.4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment