Format Theme Songs
This commit is contained in:
parent
319c507a38
commit
aee8ab67d5
2 changed files with 207 additions and 199 deletions
|
|
@ -1,10 +1,13 @@
|
||||||
# Plays the 007 theme song
|
"""
|
||||||
# Gemma M0 with Piezo on D0 and GND
|
Plays the 007 theme song
|
||||||
|
Gemma M0 with Piezo on D0 and GND
|
||||||
|
"""
|
||||||
|
|
||||||
import pulseio
|
|
||||||
import board
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import board
|
||||||
|
import pulseio
|
||||||
|
|
||||||
piezo = pulseio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
piezo = pulseio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
||||||
variable_frequency=True)
|
variable_frequency=True)
|
||||||
|
|
||||||
|
|
@ -104,12 +107,12 @@ B6 = B5 * 2
|
||||||
|
|
||||||
rst = 24000 # rest is just a tone out of normal hearing range
|
rst = 24000 # rest is just a tone out of normal hearing range
|
||||||
|
|
||||||
Bond01=[[B3, half_note],
|
Bond01 = [[B3, half_note],
|
||||||
[C4, half_note],
|
[C4, half_note],
|
||||||
[Cs4, half_note],
|
[Cs4, half_note],
|
||||||
[C4, half_note]]
|
[C4, half_note]]
|
||||||
|
|
||||||
Bond02=[[E3, eighth_note],
|
Bond02 = [[E3, eighth_note],
|
||||||
[Fs3, sixteenth_note],
|
[Fs3, sixteenth_note],
|
||||||
[Fs3, sixteenth_note],
|
[Fs3, sixteenth_note],
|
||||||
[Fs3, eighth_note],
|
[Fs3, eighth_note],
|
||||||
|
|
@ -119,7 +122,7 @@ Bond02=[[E3, eighth_note],
|
||||||
[E3, eighth_note],
|
[E3, eighth_note],
|
||||||
[E3, eighth_note]]
|
[E3, eighth_note]]
|
||||||
|
|
||||||
Bond03=[[E3, eighth_note],
|
Bond03 = [[E3, eighth_note],
|
||||||
[G3, sixteenth_note],
|
[G3, sixteenth_note],
|
||||||
[G3, sixteenth_note],
|
[G3, sixteenth_note],
|
||||||
[G3, eighth_note],
|
[G3, eighth_note],
|
||||||
|
|
@ -129,8 +132,7 @@ Bond03=[[E3, eighth_note],
|
||||||
[Fs3, eighth_note],
|
[Fs3, eighth_note],
|
||||||
[Fs3, eighth_note]]
|
[Fs3, eighth_note]]
|
||||||
|
|
||||||
|
Bond04 = [[E3, eighth_note],
|
||||||
Bond04=[[E3, eighth_note],
|
|
||||||
[G3, sixteenth_note],
|
[G3, sixteenth_note],
|
||||||
[G3, sixteenth_note],
|
[G3, sixteenth_note],
|
||||||
[G3, eighth_note],
|
[G3, eighth_note],
|
||||||
|
|
@ -140,14 +142,14 @@ Bond04=[[E3, eighth_note],
|
||||||
[Fs3, eighth_note],
|
[Fs3, eighth_note],
|
||||||
[E3, eighth_note]]
|
[E3, eighth_note]]
|
||||||
|
|
||||||
Bond05=[[Ds4, eighth_note],
|
Bond05 = [[Ds4, eighth_note],
|
||||||
[D4, eighth_note],
|
[D4, eighth_note],
|
||||||
[D4, half_note],
|
[D4, half_note],
|
||||||
[B3, eighth_note],
|
[B3, eighth_note],
|
||||||
[A3, eighth_note],
|
[A3, eighth_note],
|
||||||
[B3, whole_note]]
|
[B3, whole_note]]
|
||||||
|
|
||||||
Bond06=[[E4, eighth_note],
|
Bond06 = [[E4, eighth_note],
|
||||||
[G4, quarter_note],
|
[G4, quarter_note],
|
||||||
[Ds5, eighth_note],
|
[Ds5, eighth_note],
|
||||||
[D5, quarter_note],
|
[D5, quarter_note],
|
||||||
|
|
@ -158,7 +160,7 @@ Bond06=[[E4, eighth_note],
|
||||||
[B4, half_note],
|
[B4, half_note],
|
||||||
[B4, quarter_note]]
|
[B4, quarter_note]]
|
||||||
|
|
||||||
Bond07=[[G4, quarter_note],
|
Bond07 = [[G4, quarter_note],
|
||||||
[A4, sixteenth_note],
|
[A4, sixteenth_note],
|
||||||
[G4, sixteenth_note],
|
[G4, sixteenth_note],
|
||||||
[Fs4, quarter_note],
|
[Fs4, quarter_note],
|
||||||
|
|
@ -168,7 +170,7 @@ Bond07=[[G4, quarter_note],
|
||||||
[Cs4, eighth_note],
|
[Cs4, eighth_note],
|
||||||
[Cs4, whole_note]]
|
[Cs4, whole_note]]
|
||||||
|
|
||||||
Bond08=[[G4, quarter_note],
|
Bond08 = [[G4, quarter_note],
|
||||||
[A4, sixteenth_note],
|
[A4, sixteenth_note],
|
||||||
[G4, sixteenth_note],
|
[G4, sixteenth_note],
|
||||||
[Fs4, quarter_note],
|
[Fs4, quarter_note],
|
||||||
|
|
@ -178,7 +180,7 @@ Bond08=[[G4, quarter_note],
|
||||||
[E4, eighth_note],
|
[E4, eighth_note],
|
||||||
[E4, whole_note]]
|
[E4, whole_note]]
|
||||||
|
|
||||||
Bond09=[[E4, eighth_note],
|
Bond09 = [[E4, eighth_note],
|
||||||
[E4, quarter_note],
|
[E4, quarter_note],
|
||||||
[E4, eighth_note],
|
[E4, eighth_note],
|
||||||
[Fs4, eighth_note],
|
[Fs4, eighth_note],
|
||||||
|
|
@ -186,7 +188,7 @@ Bond09=[[E4, eighth_note],
|
||||||
[E4, eighth_note],
|
[E4, eighth_note],
|
||||||
[Fs4, quarter_note]]
|
[Fs4, quarter_note]]
|
||||||
|
|
||||||
Bond10=[
|
Bond10 = [
|
||||||
[G4, eighth_note],
|
[G4, eighth_note],
|
||||||
[G4, quarter_note],
|
[G4, quarter_note],
|
||||||
[G4, eighth_note],
|
[G4, eighth_note],
|
||||||
|
|
@ -195,7 +197,7 @@ Bond10=[
|
||||||
[G4, eighth_note],
|
[G4, eighth_note],
|
||||||
[Fs4, quarter_note]]
|
[Fs4, quarter_note]]
|
||||||
|
|
||||||
Bond11=[[B4, eighth_note],
|
Bond11 = [[B4, eighth_note],
|
||||||
[B4, eighth_note],
|
[B4, eighth_note],
|
||||||
[rst, eighth_note],
|
[rst, eighth_note],
|
||||||
[B3, eighth_note],
|
[B3, eighth_note],
|
||||||
|
|
@ -211,7 +213,7 @@ Bond11=[[B4, eighth_note],
|
||||||
[B4, eighth_note],
|
[B4, eighth_note],
|
||||||
[B4, eighth_note]]
|
[B4, eighth_note]]
|
||||||
|
|
||||||
Bond12=[[E3, eighth_note],
|
Bond12 = [[E3, eighth_note],
|
||||||
[G3, quarter_note],
|
[G3, quarter_note],
|
||||||
[Ds4, eighth_note],
|
[Ds4, eighth_note],
|
||||||
[D4, quarter_note],
|
[D4, quarter_note],
|
||||||
|
|
@ -231,14 +233,16 @@ Bond12=[[E3, eighth_note],
|
||||||
[rst, quarter_note],
|
[rst, quarter_note],
|
||||||
[Fs4, whole_note]]
|
[Fs4, whole_note]]
|
||||||
|
|
||||||
|
|
||||||
def song_playback(song):
|
def song_playback(song):
|
||||||
for n in range(len(song)):
|
for note in song:
|
||||||
piezo.frequency = (song[n][0])
|
piezo.frequency = (note[0])
|
||||||
piezo.duty_cycle = 65536//2 # on 50%
|
piezo.duty_cycle = 65536 // 2 # on 50%
|
||||||
time.sleep(song[n][1]) # note duration
|
time.sleep(note[1]) # note duration
|
||||||
piezo.duty_cycle = 0 # off
|
piezo.duty_cycle = 0 # off
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
|
||||||
# this plays the full song roadmap
|
# this plays the full song roadmap
|
||||||
song_playback(Bond01)
|
song_playback(Bond01)
|
||||||
song_playback(Bond01)
|
song_playback(Bond01)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
# Plays the Carmen Sandiego theme song
|
"""
|
||||||
# Gemma M0 with Piezo on D0 and GND
|
Plays the Carmen Sandiego theme song
|
||||||
|
Gemma M0 with Piezo on D0 and GND
|
||||||
|
"""
|
||||||
|
|
||||||
import pulseio
|
|
||||||
import board
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import board
|
||||||
|
import pulseio
|
||||||
|
|
||||||
piezo = pulseio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
piezo = pulseio.PWMOut(board.D0, duty_cycle=0, frequency=440,
|
||||||
variable_frequency=True)
|
variable_frequency=True)
|
||||||
|
|
||||||
|
|
@ -103,7 +106,7 @@ B6 = B5 * 2
|
||||||
|
|
||||||
rst = 24000 # rest is just a tone out of normal hearing range
|
rst = 24000 # rest is just a tone out of normal hearing range
|
||||||
|
|
||||||
carmen01 =[[As4, quarter_note],
|
carmen01 = [[As4, quarter_note],
|
||||||
[As4, eighth_note],
|
[As4, eighth_note],
|
||||||
[rst, eighth_note],
|
[rst, eighth_note],
|
||||||
[rst, sixteenth_note],
|
[rst, sixteenth_note],
|
||||||
|
|
@ -112,7 +115,7 @@ carmen01 =[[As4, quarter_note],
|
||||||
[B4, eighth_note],
|
[B4, eighth_note],
|
||||||
[B4, eighth_note]]
|
[B4, eighth_note]]
|
||||||
|
|
||||||
carmen02 =[[Gs4, quarter_note],
|
carmen02 = [[Gs4, quarter_note],
|
||||||
[Gs4, eighth_note],
|
[Gs4, eighth_note],
|
||||||
[rst, eighth_note],
|
[rst, eighth_note],
|
||||||
[rst, sixteenth_note],
|
[rst, sixteenth_note],
|
||||||
|
|
@ -121,14 +124,14 @@ carmen02 =[[Gs4, quarter_note],
|
||||||
[Gs4, eighth_note],
|
[Gs4, eighth_note],
|
||||||
[B4, eighth_note]]
|
[B4, eighth_note]]
|
||||||
|
|
||||||
carmen03 =[[Gs4, quarter_note],
|
carmen03 = [[Gs4, quarter_note],
|
||||||
[Gs4, eighth_note],
|
[Gs4, eighth_note],
|
||||||
[rst, eighth_note],
|
[rst, eighth_note],
|
||||||
[rst, quarter_note],
|
[rst, quarter_note],
|
||||||
[Cs4, eighth_note],
|
[Cs4, eighth_note],
|
||||||
[Cs4, eighth_note]]
|
[Cs4, eighth_note]]
|
||||||
|
|
||||||
carmen04 =[[As4, eighth_note],
|
carmen04 = [[As4, eighth_note],
|
||||||
[As4, sixteenth_note],
|
[As4, sixteenth_note],
|
||||||
[As4, eighth_note],
|
[As4, eighth_note],
|
||||||
[As4, eighth_note],
|
[As4, eighth_note],
|
||||||
|
|
@ -137,7 +140,7 @@ carmen04 =[[As4, eighth_note],
|
||||||
[B4, eighth_note],
|
[B4, eighth_note],
|
||||||
[B4, eighth_note]]
|
[B4, eighth_note]]
|
||||||
|
|
||||||
carmen05 =[[Gs4, eighth_note],
|
carmen05 = [[Gs4, eighth_note],
|
||||||
[Fs4, eighth_note],
|
[Fs4, eighth_note],
|
||||||
[Gs4, eighth_note],
|
[Gs4, eighth_note],
|
||||||
[Fs4, sixteenth_note],
|
[Fs4, sixteenth_note],
|
||||||
|
|
@ -148,7 +151,7 @@ carmen05 =[[Gs4, eighth_note],
|
||||||
[Fs4, eighth_note],
|
[Fs4, eighth_note],
|
||||||
[Fs4, eighth_note]]
|
[Fs4, eighth_note]]
|
||||||
|
|
||||||
carmen06 =[[Gs4, eighth_note],
|
carmen06 = [[Gs4, eighth_note],
|
||||||
[Fs4, eighth_note],
|
[Fs4, eighth_note],
|
||||||
[Gs4, eighth_note],
|
[Gs4, eighth_note],
|
||||||
[Fs4, sixteenth_note],
|
[Fs4, sixteenth_note],
|
||||||
|
|
@ -159,7 +162,7 @@ carmen06 =[[Gs4, eighth_note],
|
||||||
[rst, eighth_note],
|
[rst, eighth_note],
|
||||||
[Fs4, eighth_note]]
|
[Fs4, eighth_note]]
|
||||||
|
|
||||||
carmen07 =[[Gs4, eighth_note],
|
carmen07 = [[Gs4, eighth_note],
|
||||||
[Fs4, eighth_note],
|
[Fs4, eighth_note],
|
||||||
[Gs4, eighth_note],
|
[Gs4, eighth_note],
|
||||||
[Fs4, sixteenth_note],
|
[Fs4, sixteenth_note],
|
||||||
|
|
@ -170,7 +173,7 @@ carmen07 =[[Gs4, eighth_note],
|
||||||
[Gs4, eighth_note],
|
[Gs4, eighth_note],
|
||||||
[Fs4, eighth_note]]
|
[Fs4, eighth_note]]
|
||||||
|
|
||||||
carmen08 =[[Fs4, eighth_note],
|
carmen08 = [[Fs4, eighth_note],
|
||||||
[rst, eighth_note],
|
[rst, eighth_note],
|
||||||
[Fs4, eighth_note],
|
[Fs4, eighth_note],
|
||||||
[Fs4, eighth_note],
|
[Fs4, eighth_note],
|
||||||
|
|
@ -186,10 +189,11 @@ carmen08 =[[Fs4, eighth_note],
|
||||||
[Fs3, eighth_note],
|
[Fs3, eighth_note],
|
||||||
[rst, quarter_note]]
|
[rst, quarter_note]]
|
||||||
|
|
||||||
|
|
||||||
def song_playback(song):
|
def song_playback(song):
|
||||||
for n in range(len(song)):
|
for n in range(len(song)):
|
||||||
piezo.frequency = (song[n][0])
|
piezo.frequency = (song[n][0])
|
||||||
piezo.duty_cycle = 65536//2 # on 50%
|
piezo.duty_cycle = 65536 // 2 # on 50%
|
||||||
time.sleep(song[n][1]) # note duration
|
time.sleep(song[n][1]) # note duration
|
||||||
piezo.duty_cycle = 0 # off
|
piezo.duty_cycle = 0 # off
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue