Format Theme Songs

This commit is contained in:
Craig Richardson 2018-05-14 18:14:25 +01:00
parent 319c507a38
commit aee8ab67d5
2 changed files with 207 additions and 199 deletions

View file

@ -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 board
import pulseio
piezo = pulseio.PWMOut(board.D0, duty_cycle=0, frequency=440,
variable_frequency=True)
@ -87,7 +90,7 @@ B5 = 987
C6 = C5 * 2
Cs6 = Cs5 * 2
Db6 = Db5 * 2
D6 = D5 * 2
D6 = D5 * 2
Ds6 = Ds5 * 2
Eb6 = Eb5 * 2
E6 = E5 * 2
@ -104,89 +107,88 @@ B6 = B5 * 2
rst = 24000 # rest is just a tone out of normal hearing range
Bond01=[[B3, half_note],
[C4, half_note],
[Cs4, half_note],
[C4, half_note]]
Bond01 = [[B3, half_note],
[C4, half_note],
[Cs4, half_note],
[C4, half_note]]
Bond02=[[E3, eighth_note],
[Fs3, sixteenth_note],
[Fs3, sixteenth_note],
[Fs3, eighth_note],
[Fs3, eighth_note],
[Fs3, eighth_note],
[E3, eighth_note],
[E3, eighth_note],
[E3, eighth_note]]
Bond02 = [[E3, eighth_note],
[Fs3, sixteenth_note],
[Fs3, sixteenth_note],
[Fs3, eighth_note],
[Fs3, eighth_note],
[Fs3, eighth_note],
[E3, eighth_note],
[E3, eighth_note],
[E3, eighth_note]]
Bond03=[[E3, eighth_note],
[G3, sixteenth_note],
[G3, sixteenth_note],
[G3, eighth_note],
[G3, eighth_note],
[G3, eighth_note],
[Fs3, eighth_note],
[Fs3, eighth_note],
[Fs3, eighth_note]]
Bond03 = [[E3, eighth_note],
[G3, sixteenth_note],
[G3, sixteenth_note],
[G3, eighth_note],
[G3, eighth_note],
[G3, eighth_note],
[Fs3, eighth_note],
[Fs3, eighth_note],
[Fs3, eighth_note]]
Bond04 = [[E3, eighth_note],
[G3, sixteenth_note],
[G3, sixteenth_note],
[G3, eighth_note],
[G3, eighth_note],
[G3, eighth_note],
[Fs3, eighth_note],
[Fs3, eighth_note],
[E3, eighth_note]]
Bond04=[[E3, eighth_note],
[G3, sixteenth_note],
[G3, sixteenth_note],
[G3, eighth_note],
[G3, eighth_note],
[G3, eighth_note],
[Fs3, eighth_note],
[Fs3, eighth_note],
[E3, eighth_note]]
Bond05 = [[Ds4, eighth_note],
[D4, eighth_note],
[D4, half_note],
[B3, eighth_note],
[A3, eighth_note],
[B3, whole_note]]
Bond05=[[Ds4, eighth_note],
[D4, eighth_note],
[D4, half_note],
[B3, eighth_note],
[A3, eighth_note],
[B3, whole_note]]
Bond06 = [[E4, eighth_note],
[G4, quarter_note],
[Ds5, eighth_note],
[D5, quarter_note],
[D5, eighth_note],
[G4, eighth_note],
[As4, eighth_note],
[B4, eighth_note],
[B4, half_note],
[B4, quarter_note]]
Bond06=[[E4, eighth_note],
[G4, quarter_note],
[Ds5, eighth_note],
[D5, quarter_note],
[D5, eighth_note],
[G4, eighth_note],
[As4, eighth_note],
[B4, eighth_note],
[B4, half_note],
[B4, quarter_note]]
Bond07 = [[G4, quarter_note],
[A4, sixteenth_note],
[G4, sixteenth_note],
[Fs4, quarter_note],
[Fs4, eighth_note],
[B3, eighth_note],
[E4, eighth_note],
[Cs4, eighth_note],
[Cs4, whole_note]]
Bond07=[[G4, quarter_note],
[A4, sixteenth_note],
[G4, sixteenth_note],
[Fs4, quarter_note],
[Fs4, eighth_note],
[B3, eighth_note],
[E4, eighth_note],
[Cs4, eighth_note],
[Cs4, whole_note]]
Bond08 = [[G4, quarter_note],
[A4, sixteenth_note],
[G4, sixteenth_note],
[Fs4, quarter_note],
[Fs4, eighth_note],
[B3, eighth_note],
[Ds4, eighth_note],
[E4, eighth_note],
[E4, whole_note]]
Bond08=[[G4, quarter_note],
[A4, sixteenth_note],
[G4, sixteenth_note],
[Fs4, quarter_note],
[Fs4, eighth_note],
[B3, eighth_note],
[Ds4, eighth_note],
[E4, eighth_note],
[E4, whole_note]]
Bond09 = [[E4, eighth_note],
[E4, quarter_note],
[E4, eighth_note],
[Fs4, eighth_note],
[Fs4, sixteenth_note],
[E4, eighth_note],
[Fs4, quarter_note]]
Bond09=[[E4, eighth_note],
[E4, quarter_note],
[E4, eighth_note],
[Fs4, eighth_note],
[Fs4, sixteenth_note],
[E4, eighth_note],
[Fs4, quarter_note]]
Bond10=[
Bond10 = [
[G4, eighth_note],
[G4, quarter_note],
[G4, eighth_note],
@ -195,50 +197,52 @@ Bond10=[
[G4, eighth_note],
[Fs4, quarter_note]]
Bond11=[[B4, eighth_note],
[B4, eighth_note],
[rst, eighth_note],
[B3, eighth_note],
[B3, quarter_note],
[B4, eighth_note],
[B4, eighth_note],
[rst, eighth_note],
[B3, eighth_note],
[B3, quarter_note],
[B4, sixteenth_note],
[B4, eighth_note],
[B4, sixteenth_note],
[B4, eighth_note],
[B4, eighth_note]]
Bond11 = [[B4, eighth_note],
[B4, eighth_note],
[rst, eighth_note],
[B3, eighth_note],
[B3, quarter_note],
[B4, eighth_note],
[B4, eighth_note],
[rst, eighth_note],
[B3, eighth_note],
[B3, quarter_note],
[B4, sixteenth_note],
[B4, eighth_note],
[B4, sixteenth_note],
[B4, eighth_note],
[B4, eighth_note]]
Bond12 = [[E3, eighth_note],
[G3, quarter_note],
[Ds4, eighth_note],
[D4, quarter_note],
[G3, eighth_note],
[B3, quarter_note],
[Fs4, eighth_note],
[F4, quarter_note],
[B3, eighth_note],
[D4, quarter_note],
[As4, eighth_note],
[A4, quarter_note],
[F4, eighth_note],
[A4, quarter_note],
[Ds5, eighth_note],
[D5, quarter_note],
[rst, eighth_note],
[rst, quarter_note],
[Fs4, whole_note]]
Bond12=[[E3, eighth_note],
[G3, quarter_note],
[Ds4, eighth_note],
[D4, quarter_note],
[G3, eighth_note],
[B3, quarter_note],
[Fs4, eighth_note],
[F4, quarter_note],
[B3, eighth_note],
[D4, quarter_note],
[As4, eighth_note],
[A4, quarter_note],
[F4, eighth_note],
[A4, quarter_note],
[Ds5, eighth_note],
[D5, quarter_note],
[rst, eighth_note],
[rst, quarter_note],
[Fs4, whole_note]]
def song_playback(song):
for n in range(len(song)):
piezo.frequency = (song[n][0])
piezo.duty_cycle = 65536//2 # on 50%
time.sleep(song[n][1]) # note duration
for note in song:
piezo.frequency = (note[0])
piezo.duty_cycle = 65536 // 2 # on 50%
time.sleep(note[1]) # note duration
piezo.duty_cycle = 0 # off
time.sleep(0.01)
# this plays the full song roadmap
song_playback(Bond01)
song_playback(Bond01)

View file

@ -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 board
import pulseio
piezo = pulseio.PWMOut(board.D0, duty_cycle=0, frequency=440,
variable_frequency=True)
@ -86,7 +89,7 @@ B5 = 987
C6 = C5 * 2
Cs6 = Cs5 * 2
Db6 = Db5 * 2
D6 = D5 * 2
D6 = D5 * 2
Ds6 = Ds5 * 2
Eb6 = Eb5 * 2
E6 = E5 * 2
@ -103,93 +106,94 @@ B6 = B5 * 2
rst = 24000 # rest is just a tone out of normal hearing range
carmen01 =[[As4, quarter_note],
[As4, eighth_note],
[rst, eighth_note],
[rst, sixteenth_note],
[B4, eighth_note],
[rst, sixteenth_note],
[B4, eighth_note],
[B4, eighth_note]]
carmen01 = [[As4, quarter_note],
[As4, eighth_note],
[rst, eighth_note],
[rst, sixteenth_note],
[B4, eighth_note],
[rst, sixteenth_note],
[B4, eighth_note],
[B4, eighth_note]]
carmen02 =[[Gs4, quarter_note],
[Gs4, eighth_note],
[rst, eighth_note],
[rst, sixteenth_note],
[Gs4, eighth_note],
[rst, sixteenth_note],
[Gs4, eighth_note],
[B4, eighth_note]]
carmen02 = [[Gs4, quarter_note],
[Gs4, eighth_note],
[rst, eighth_note],
[rst, sixteenth_note],
[Gs4, eighth_note],
[rst, sixteenth_note],
[Gs4, eighth_note],
[B4, eighth_note]]
carmen03 =[[Gs4, quarter_note],
[Gs4, eighth_note],
[rst, eighth_note],
[rst, quarter_note],
[Cs4, eighth_note],
[Cs4, eighth_note]]
carmen03 = [[Gs4, quarter_note],
[Gs4, eighth_note],
[rst, eighth_note],
[rst, quarter_note],
[Cs4, eighth_note],
[Cs4, eighth_note]]
carmen04 =[[As4, eighth_note],
[As4, sixteenth_note],
[As4, eighth_note],
[As4, eighth_note],
[B4, sixteenth_note],
[B4, quarter_note],
[B4, eighth_note],
[B4, eighth_note]]
carmen04 = [[As4, eighth_note],
[As4, sixteenth_note],
[As4, eighth_note],
[As4, eighth_note],
[B4, sixteenth_note],
[B4, quarter_note],
[B4, eighth_note],
[B4, eighth_note]]
carmen05 =[[Gs4, eighth_note],
[Fs4, eighth_note],
[Gs4, eighth_note],
[Fs4, sixteenth_note],
[Cs5, sixteenth_note],
[Cs5, sixteenth_note],
[As4, eighth_note],
[As4, sixteenth_note],
[Fs4, eighth_note],
[Fs4, eighth_note]]
carmen05 = [[Gs4, eighth_note],
[Fs4, eighth_note],
[Gs4, eighth_note],
[Fs4, sixteenth_note],
[Cs5, sixteenth_note],
[Cs5, sixteenth_note],
[As4, eighth_note],
[As4, sixteenth_note],
[Fs4, eighth_note],
[Fs4, eighth_note]]
carmen06 =[[Gs4, eighth_note],
[Fs4, eighth_note],
[Gs4, eighth_note],
[Fs4, sixteenth_note],
[Gs4, sixteenth_note],
[Gs4, sixteenth_note],
[Gs4, eighth_note],
[rst, eighth_note],
[rst, eighth_note],
[Fs4, eighth_note]]
carmen06 = [[Gs4, eighth_note],
[Fs4, eighth_note],
[Gs4, eighth_note],
[Fs4, sixteenth_note],
[Gs4, sixteenth_note],
[Gs4, sixteenth_note],
[Gs4, eighth_note],
[rst, eighth_note],
[rst, eighth_note],
[Fs4, eighth_note]]
carmen07 =[[Gs4, eighth_note],
[Fs4, eighth_note],
[Gs4, eighth_note],
[Fs4, sixteenth_note],
[Cs5, sixteenth_note],
[Cs5, sixteenth_note],
[As4, eighth_note],
[As4, sixteenth_note],
[Gs4, eighth_note],
[Fs4, eighth_note]]
carmen07 = [[Gs4, eighth_note],
[Fs4, eighth_note],
[Gs4, eighth_note],
[Fs4, sixteenth_note],
[Cs5, sixteenth_note],
[Cs5, sixteenth_note],
[As4, eighth_note],
[As4, sixteenth_note],
[Gs4, eighth_note],
[Fs4, eighth_note]]
carmen08 = [[Fs4, eighth_note],
[rst, eighth_note],
[Fs4, eighth_note],
[Fs4, eighth_note],
[Gs4, eighth_note],
[rst, eighth_note],
[Gs4, eighth_note],
[rst, eighth_note],
[E3, eighth_note],
[E3, eighth_note],
[E3, eighth_note],
[E3, sixteenth_note],
[Fs3, eighth_note],
[Fs3, eighth_note],
[rst, quarter_note]]
carmen08 =[[Fs4, eighth_note],
[rst, eighth_note],
[Fs4, eighth_note],
[Fs4, eighth_note],
[Gs4, eighth_note],
[rst, eighth_note],
[Gs4, eighth_note],
[rst, eighth_note],
[E3, eighth_note],
[E3, eighth_note],
[E3, eighth_note],
[E3, sixteenth_note],
[Fs3, eighth_note],
[Fs3, eighth_note],
[rst, quarter_note]]
def song_playback(song):
for n in range(len(song)):
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
piezo.duty_cycle = 0 # off
time.sleep(0.01)