Last active
November 2, 2024 01:38
-
-
Save spdskatr/939b77f0c360e5c201a93193f6b38afe to your computer and use it in GitHub Desktop.
Megalovania for the bbc micro:bit.
This file contains 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
from microbit import * | |
import music | |
import radio | |
MEGALOVANIA2 = "D3:2 D3:2 D4:4 A3:5 0:1 G#3:4 G3:4 F3:4 D3:2 F3:2 G3:2 C3:2 C3:2 D4:4 A3:5 0:1 G#3:4 G3:4 F3:4 D3:2 F3:2 G3:2 B2:2 B2:2 D4:4 A3:5 0:1 G#3:4 G3:4 F3:4 D3:2 F3:2 G3:2 A#2:2 A#2:2 D4:4 A3:5 0:1 G#3:4 G3:4 F3:4 D3:2 F3:2 G3:2 D4:2 D4:2 D5:4 A4:5 0:1 G#4:4 G4:4 F4:4 D4:2 F4:2 G4:2 C4:2 C4:2 D5:4 A4:5 0:1 G#4:4 G4:4 F4:4 D4:2 F4:2 G4:2 B3:2 B3:2 D5:4 A4:5 0:1 G#4:4 G4:4 F4:4 D4:2 F4:2 G4:2 A#3:2 A#3:2 D5:4 A4:5 0:1 G#4:4 G4:4 F4:4 D4:2 F4:2 G4:2 F4:4 F4:2 F4:4 F4:4 F4:4 D4:4 D4:8 D4:2 F4:4 F4:2 F4:4 G4:4 G#4:4 G4:2 F4:2 D4:2 F4:2 G4:2 0:4 F4:4 F4:2 F4:4 G4:4 G#4:4 A4:4 C5:4 A4:6 D5:4 D5:4 D5:2 A4:2 D5:2 C5:16 A4:4 A4:2 A4:4 A4:4 A4:4 G4:4 G4:8 G4:2 A4:4 A4:2 A4:4 A4:4 G4:4 A4:4 C5:4 A4:2 G4:4 D5:2 D4:2 A4:2 D4:2 G4:2 D4:2 F4:2 D4:2 C5:2 C4:2 G4:2 C4:2 F4:2 B3:2 E4:2 B3:2 A#3:6 C4:2 D4:2 F4:4 C5:16 0:16 F4:2 D4:2 F4:2 G4:2 G#4:2 G4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:4 C3:2 C3:2 C3:2 C3:4 D3:4 D3:4 D3:2 D3:4 D3:4 D3:4 D3:2 D3:2 D3:2 D3:4 D3:4 D3:4 D3:2 D3:4 D3:4 D3:4 D3:2 D3:2 D3:2 D3:4 A#2:4 A#2:4 A#2:2 A#2:4 A#2:4 A#2:4 A#2:2 A#2:2 A#2:2 A#2:4 C3:4 C3:4 C3:2 C3:4 C3:4 C3:4 C3:2 C3:2 C3:2 C3:4 D3:4 D3:4 D3:2 D3:4 C#3:4 C#3:4 C#3:2 C#3:2 C#3:2 C#3:4 C3:4 C3:4 C3:2 C3:4 B2:4 B2:4 B2:2 B2:2 B2:2 B2:4 A#2:4 A#2:4 A#2:2 A#2:4 A#2:4 A#2:4 A#2:2 A#2:2 A#2:2 A#2:4 C3:4 C3:4 C3:2 C3:4 C3:4 C3:4 C3:2 C3:2 C3:2 C3:4 D3:2 D3:2 D4:4 A3:5 0:1 G#3:4 G3:4 F3:4 D3:2 F3:2 G3:2 D3:2 D3:2 D4:4 A3:5 0:1 G#3:4 G3:4 F3:4 D3:2 F3:2 G3:2 A#2:2 A#2:2 D4:4 A3:5 0:1 G#3:4 G3:4 F3:4 D3:2 F3:2 G3:2 C3:2 C3:2 D4:4 A3:5 0:1 G#3:4 G3:4 F3:4 D3:2 F3:2 G3:2 D3:2 D3:2 D4:4 A3:5 0:1 G#3:4 G3:4 F3:4 D3:2 F3:2 G3:2 0:64" | |
BPM = 240 | |
next_play = 0 | |
skips = 0 | |
ANNOUNCER_CH = 4 | |
music.set_tempo(ticks=4, bpm=BPM) | |
radio.on() | |
radio.config(channel=ANNOUNCER_CH) | |
def megalovania(): | |
global next_play, skips | |
ptr = 0 | |
while ptr < len(MEGALOVANIA2): | |
lp = ptr | |
while ptr < len(MEGALOVANIA2) and MEGALOVANIA2[ptr] != " ": | |
ptr += 1 | |
s = MEGALOVANIA2[lp:ptr] | |
a, b = s.split(":") | |
diff = next_play - running_time() | |
if diff > 0: | |
sleep(diff) | |
ptr += 1 | |
if skips > 0: | |
skips -= 1 | |
continue | |
next_play = running_time() + (60000//BPM//4) * int(b) | |
music.play(s, wait=False) | |
while True: | |
msg = radio.receive() | |
if button_a.is_pressed() or msg == "!!START!!": | |
display.show(Image.SKULL) | |
next_play = running_time() | |
megalovania() | |
display.clear() |
is there a version of this that doesn't need the radio function? I've found two other micro:bit megalovania tunes, but both of them are in MakeCode. I would use this but I can't use radio. Can someone please link one that doesn't need it?
If you just remove lines 3, 11, 12, 33 and remove or msg == "!!START!!"
from line 34, the program will still work without radio when you press button A.
I think.
I made this many years ago.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is there a version of this that doesn't need the radio function? I've found two other micro:bit megalovania tunes, but both of them are in MakeCode. I would use this but I can't use radio. Can someone please link one that doesn't need it?