27.06.2018

Playing Super Mario theme music with Python

Playing Super Mario theme music with Python - Are you a music composer that likes the sound from your system speaker? Are you just a Super Mario nerd that loves the theme songs from Mario? Read on, as we are going to discover how you can play or make these songs with Python!

The winsound module allows you to play sounds from within Windows. You can, for example, beep the system speaker with the Beep method. The Beep method accepts two parameters. The first is the tone you want to play in Hertz (frequency must be in 37 thru 32767), the second is how long you want to play it in milliseconds. For example, to play the low tone of 400 Hz for 1 second, you write winsound.Beep(400,1000).

You can also use winsound.Beep to see what low frequency and high-frequency tones you can hear. To make it more interesting, I added some melodies from Super-Mario here as well. The first one I found from the net was J0kerR's Mario Bros Theme. Akash Agrawal made the second Mario theme I found. I modified the scripts a bit so that I could play them with the winsound module. Enjoy the Mario music and let me know if you have some more music to add!

from winsound import Beep
import time

#Beep(frequency, duration) Frequency in Hertz, duration in ms

###################################################
# Mario Bros Theme ( Beep Music )##################
# Address: https://www.autoitscript.com/forum/topic/40848-beep-music-mario-bros-theme/
###################################################
###################### by J0keR  ##################
###################################################

Beep(480,200)

Beep(1568,200)

Beep(1568,200)

Beep(1568,200)



Beep(740,200)

Beep(784,200)

Beep(784,200)

Beep(784,200)


Beep(370,200)

Beep(392,200)

Beep(370,200)

Beep(392,200)

Beep(392,400)

Beep(196,400)



Beep(740,200)

Beep(784,200)

Beep(784,200)

Beep(740,200)

Beep(784,200)

Beep(784,200)

Beep(740,200)

Beep(84,200)

Beep(880,200)

Beep(831,200)

Beep(880,200)

Beep(988,400)


Beep(880,200)

Beep(784,200)

Beep(699,200)

Beep(740,200)

Beep(784,200)

Beep(784,200)

Beep(740,200)

Beep(784,200)

Beep(784,200)

Beep(740,200)

Beep(784,200)

Beep(880,200)

Beep(830,200)

Beep(880,200)

Beep(988,400)

time.sleep(200/1000)

Beep(1108,10)
Beep(1174,200)
Beep(1480,10)
Beep(1568,200)


time.sleep(200/1000)
Beep(740,200)

Beep(784,200)

Beep(784,200)

Beep(740,200)

Beep(784,200)

Beep(784,200)

Beep(740,200)

Beep(784,200)

Beep(880,200)

Beep(830,200)

Beep(880,200)

Beep(988,400)


Beep(880,200)

Beep(784,200)

Beep(699,200)


Beep(659,200)

Beep(699,200)

Beep(784,200)

Beep(880,400)

Beep(784,200)

Beep(699,200)

Beep(659,200)



Beep(587,200)

Beep(659,200)

Beep(699,200)

Beep(784,400)

Beep(699,200)

Beep(659,200)

Beep(587,200)



Beep(523,200)

Beep(587,200)

Beep(659,200)

Beep(699,400)

Beep(659,200)

Beep(587,200)

Beep(494,200)

Beep(523,200)


time.sleep(400/1000)

Beep(349,400)

Beep(392,200)

Beep(330,200)

Beep(523,200)

Beep(494,200)

Beep(466,200)



Beep(440,200)

Beep(494,200)

Beep(523,200)

Beep(880,200)

Beep(494,200)

Beep(880,200)

Beep(1760,200)

Beep(440,200)



Beep(392,200)

Beep(440,200)

Beep(494,200)

Beep(784,200)

Beep(440, 200)

Beep(784,200)

Beep(1568,200)

Beep(392,200)



Beep(349,200)

Beep(392,200)

Beep(440,200)

Beep(699,200)

Beep(415,200)

Beep(699,200)

Beep(1397,200)

Beep(349,200)



Beep(330,200)

Beep(311,200)

Beep(330,200)

Beep(659,200)

Beep(699,400)

Beep(784,400)



Beep(440,200)

Beep(494,200)

Beep(523,200)

Beep(880,200)

Beep(494,200)

Beep(880,200)

Beep(1760,200)

Beep(440,200)



Beep(392,200)

Beep(440,200)

Beep(494,200)

Beep(784,200)

Beep(440,200)

Beep(784,200)

Beep(1568,200)

Beep(392,200)



Beep(349,200)

Beep(392,200)

Beep(440,200)

Beep(699,200)

Beep(659,200)

Beep(699,200)

Beep(740,200)

Beep(784,200)

Beep(392,200)

Beep(392,200)

Beep(392,200)

Beep(392,200)

Beep(196,200)

Beep(196,200)

Beep(196,200)



Beep(185,200)

Beep(196,200)

Beep(185,200)

Beep(196,200)

Beep(208,200)

Beep(220,200)

Beep(233,200)

Beep(247,200)

print("song finished")

Second Mario Bros theme

from winsound import Beep
import time

#Beep(frequency, duration) Frequency in Hertz, duration in ms
# Composer: Akash Agrawal
# Address: https://hashtagakash.wordpress.com/2014/01/22/182/


Beep(659, 125)
Beep(659, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.167)
Beep(523, 125)
Beep(659, 125)
time.sleep(0.125)
Beep(784, 125)
time.sleep(0.375)
Beep(392, 125)
time.sleep(0.375)
Beep(523, 125)
time.sleep(0.250)
Beep(392, 125)
time.sleep(0.250)
Beep(330, 125)
time.sleep(0.250)
Beep(440, 125)
time.sleep(0.125)
Beep(494, 125)
time.sleep(0.125)
Beep(466, 125)
time.sleep(0.42)
Beep(440, 125)
time.sleep(0.125)
Beep(392, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.125)
Beep(784, 125)
time.sleep(0.125)
Beep(880, 125)
time.sleep(0.125)
Beep(698, 125)
Beep(784, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.125)
Beep(523, 125)
time.sleep(0.125)
Beep(587, 125)
Beep(494, 125)
time.sleep(0.125)
Beep(523, 125)
time.sleep(0.250)
Beep(392, 125)
time.sleep(0.250)
Beep(330, 125)
time.sleep(0.250)
Beep(440, 125)
time.sleep(0.125)
Beep(494, 125)
time.sleep(0.125)
Beep(466, 125)
time.sleep(0.42)
Beep(440, 125)
time.sleep(0.125)
Beep(392, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.125)
Beep(784, 125)
time.sleep(0.125)
Beep(880, 125)
time.sleep(0.125)
Beep(698, 125)
Beep(784, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.125)
Beep(523, 125)
time.sleep(0.125)
Beep(587, 125)
Beep(494, 125)
time.sleep(0.375)
Beep(784, 125)
Beep(740, 125)
Beep(698, 125)
time.sleep(0.42)
Beep(622, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.167)
Beep(415, 125)
Beep(440, 125)
Beep(523, 125)
time.sleep(0.125)
Beep(440, 125)
Beep(523, 125)
Beep(587, 125)
time.sleep(0.250)
Beep(784, 125)
Beep(740, 125)
Beep(698, 125)
time.sleep(0.42)
Beep(622, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.167)
Beep(698, 125)
time.sleep(0.125)
Beep(698, 125)
Beep(698, 125)
time.sleep(0.625)
Beep(784, 125)
Beep(740, 125)
Beep(698, 125)
time.sleep(0.42)
Beep(622, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.167)
Beep(415, 125)
Beep(440, 125)
Beep(523, 125)
time.sleep(0.125)
Beep(440, 125)
Beep(523, 125)
Beep(587, 125)
time.sleep(0.250)
Beep(622, 125)
time.sleep(0.250)
Beep(587, 125)
time.sleep(0.250)
Beep(523, 125)
time.sleep(0.1125)
Beep(784, 125)
Beep(740, 125)
Beep(698, 125)
time.sleep(0.42)
Beep(622, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.167)
Beep(415, 125)
Beep(440, 125)
Beep(523, 125)
time.sleep(0.125)
Beep(440, 125)
Beep(523, 125)
Beep(587, 125)
time.sleep(0.250)
Beep(784, 125)
Beep(740, 125)
Beep(698, 125)
time.sleep(0.42)
Beep(622, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.167)
Beep(698, 125)
time.sleep(0.125)
Beep(698, 125)
Beep(698, 125)
time.sleep(0.625)
Beep(784, 125)
Beep(740, 125)
Beep(698, 125)
time.sleep(0.42)
Beep(622, 125)
time.sleep(0.125)
Beep(659, 125)
time.sleep(0.167)
Beep(415, 125)
Beep(440, 125)
Beep(523, 125)
time.sleep(0.125)
Beep(440, 125)
Beep(523, 125)
Beep(587, 125)
time.sleep(0.250)
Beep(622, 125)
time.sleep(0.250)
Beep(587, 125)
time.sleep(0.250)
Beep(523, 125)
print("Song finished")

 

Leave a Reply

Your email address will not be published.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram