Toggle Navigation
Hatchery
Eggs
Comic bakery
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import sndmixer, time try: import buttons except: pass maxNotes = 8 channels = [] sndmixer.begin(maxNotes) waveform = 1 for i in range(maxNotes): n = sndmixer.synth() channels.append(n) sndmixer.freq(n, 0) sndmixer.waveform(n, waveform) sndmixer.play(n) def setWaveform(w): for i in range(maxNotes): sndmixer.waveform(channels[i], w) def onRight(pressed): if pressed: global waveform waveform += 1 setWaveform(waveform) def onLeft(pressed): if pressed: global waveform waveform -= 1 setWaveform(waveform) try: buttons.attach(buttons.BTN_LEFT, onLeft) buttons.attach(buttons.BTN_RIGHT, onRight) except: pass song = [ [0,415,207,0,0,0,0,0,0],[109,0,207,0,0,0,0,0,0],[112,415,0,0,0,0,0,0,0],[1,415,0,0,0,0,0,0,0], [109,0,0,0,0,0,0,0,0],[116,369,207,0,0,0,0,0,0],[110,0,207,0,0,0,0,0,0],[111,415,0,0,0,0,0,0,0], [226,207,0,0,0,0,0,0,0],[219,415,311,0,0,0,0,0,0],[228,415,207,0,0,0,0,0,0],[109,0,207,0,0,0,0,0,0], [110,466,0,415,0,0,0,0,0],[118,0,0,415,0,0,0,0,0],[110,493,246,0,0,0,0,0,0],[110,0,246,0,0,0,0,0,0], [117,554,493,0,0,0,0,0,0],[110,0,493,0,0,0,0,0,0],[109,246,0,0,0,0,0,0,0],[109,246,0,0,0,0,0,0,0], [119,493,466,0,0,0,0,0,0],[110,493,0,0,0,0,0,0,0],[108,277,0,0,0,0,0,0,0],[117,277,0,0,0,0,0,0,0], [112,554,466,0,0,0,0,0,0],[108,554,0,0,0,0,0,0,0],[110,277,415,0,0,0,0,0,0],[118,277,0,0,0,0,0,0,0], [109,0,369,554,0,0,0,0,0],[112,0,0,554,0,0,0,0,0],[115,415,207,0,0,0,0,0,0],[110,0,207,0,0,0,0,0,0], [111,415,207,0,0,0,0,0,0],[1,415,0,0,0,0,0,0,0],[108,0,0,0,0,0,0,0,0],[117,369,0,0,0,0,0,0,0], [1,369,207,0,0,0,0,0,0],[109,0,207,0,0,0,0,0,0],[111,415,207,0,0,0,0,0,0],[1,415,0,0,0,0,0,0,0], [226,207,0,0,0,0,0,0,0],[221,415,311,0,0,0,0,0,0],[225,207,369,0,0,0,0,0,0],[110,207,0,0,0,0,0,0,0], [116,0,415,0,0,0,0,0,0],[1,0,415,0,0,0,0,0,0],[109,0,0,0,0,0,0,0,0],[111,369,184,0,0,0,0,0,0], [110,0,184,0,0,0,0,0,0],[117,369,0,0,0,0,0,0,0],[110,0,0,0,0,0,0,0,0],[110,415,184,0,0,0,0,0,0], [116,0,184,0,0,0,0,0,0],[110,369,0,0,0,0,0,0,0],[109,0,0,0,0,0,0,0,0],[113,349,138,0,0,0,0,0,0], [115,0,138,0,0,0,0,0,0],[109,277,0,0,0,0,0,0,0],[110,311,0,0,0,0,0,0,0],[117,138,349,0,0,0,0,0,0], [110,138,369,0,0,0,0,0,0],[111,0,369,0,0,0,0,0,0],[1,277,349,0,0,0,0,0,0],[109,277,0,0,0,0,0,0,0], [115,207,415,0,0,0,0,0,0],[109,207,0,0,0,0,0,0,0],[111,0,415,0,0,0,0,0,0],[110,0,0,0,0,0,0,0,0], [117,369,207,0,0,0,0,0,0],[1,369,207,0,0,0,0,0,0],[107,0,207,0,0,0,0,0,0],[110,415,207,0,0,0,0,0,0], [1,415,0,0,0,0,0,0,0],[227,0,0,0,0,0,0,0,0],[1,207,0,0,0,0,0,0,0],[218,415,311,0,0,0,0,0,0], [228,415,207,0,0,0,0,0,0],[110,0,207,0,0,0,0,0,0],[114,466,0,415,0,0,0,0,0],[110,0,0,415,0,0,0,0,0], [111,493,246,0,0,0,0,0,0],[111,0,246,0,0,0,0,0,0],[116,554,493,0,0,0,0,0,0],[109,0,493,0,0,0,0,0,0], [112,246,0,0,0,0,0,0,0],[115,246,0,0,0,0,0,0,0],[109,0,466,493,0,0,0,0,0],[111,0,0,493,0,0,0,0,0], [110,0,0,493,0,0,0,0,0],[1,277,0,0,0,0,0,0,0],[115,277,0,0,0,0,0,0,0],[111,277,466,554,0,0,0,0,0], [1,0,466,554,0,0,0,0,0],[110,0,0,554,0,0,0,0,0],[115,415,277,0,0,0,0,0,0],[110,0,277,0,0,0,0,0,0], [111,369,554,0,0,0,0,0,0],[111,0,554,0,0,0,0,0,0],[116,415,207,0,0,0,0,0,0],[110,0,207,0,0,0,0,0,0], [110,415,0,0,0,0,0,0,0],[115,0,0,0,0,0,0,0,0],[110,369,207,0,0,0,0,0,0],[111,0,207,0,0,0,0,0,0], [109,415,0,0,0,0,0,0,0],[228,207,0,0,0,0,0,0,0],[227,415,311,0,0,0,0,0,0],[220,0,207,0,0,0,0,0,0], [109,0,207,0,0,0,0,0,0],[117,466,415,0,0,0,0,0,0],[110,0,415,0,0,0,0,0,0],[110,622,0,184,0,0,0,0,0], [116,0,0,184,0,0,0,0,0],[109,554,369,0,0,0,0,0,0],[110,0,369,0,0,0,0,0,0],[112,493,184,0,0,0,0,0,0], [116,0,184,0,0,0,0,0,0],[109,466,184,0,0,0,0,0,0],[1,466,0,369,0,0,0,0,0],[110,0,0,369,0,0,0,0,0], [115,493,138,0,0,0,0,0,0],[110,0,138,0,0,0,0,0,0],[111,466,0,277,0,0,0,0,0],[110,0,0,277,0,0,0,0,0], [116,415,0,0,0,0,0,0,0],[1,415,138,0,0,0,0,0,0],[109,0,138,0,0,0,0,0,0],[110,369,138,277,0,0,0,0,0], [1,369,0,277,0,0,0,0,0],[117,0,0,277,0,0,0,0,0],[111,415,207,0,0,0,0,0,0],[218,415,0,0,0,0,0,0,0], [228,207,0,0,0,0,0,0,0],[222,0,415,0,0,0,0,0,0],[224,207,0,0,0,0,0,0,0],[228,415,0,0,0,0,0,0,0], [219,0,207,0,0,0,0,0,0],[227,415,0,0,0,0,0,0,0],[221,415,369,0,0,0,0,0,0],[1,246,369,0,0,0,0,0,0], [226,493,0,0,0,0,0,0,0],[220,246,369,0,0,0,0,0,0],[224,0,493,0,0,0,0,0,0],[227,349,277,0,0,0,0,0,0], [222,554,277,0,0,0,0,0,0],[1,554,0,0,0,0,0,0,0],[224,0,277,0,0,0,0,0,0],[222,554,0,0,0,0,0,0,0], [225,0,415,207,0,0,0,0,0],[222,415,0,0,0,0,0,0,0],[225,0,207,0,0,0,0,0,0],[228,415,0,0,0,0,0,0,0], [219,207,0,0,0,0,0,0,0],[228,0,0,0,0,0,0,0,0],[1,415,0,0,0,0,0,0,0],[220,207,0,0,0,0,0,0,0], [225,415,0,0,0,0,0,0,0],[222,369,0,0,0,0,0,0,0],[1,369,184,0,0,0,0,0,0],[223,369,0,0,0,0,0,0,0], [226,0,184,0,0,0,0,0,0],[221,369,0,0,0,0,0,0,0],[227,0,349,138,0,0,0,0,0],[220,277,0,0,0,0,0,0,0], [227,138,0,0,0,0,0,0,0],[222,0,277,0,0,0,0,0,0],[226,415,207,0,0,0,0,0,0],[219,415,0,0,0,0,0,0,0], [225,0,0,0,0,0,0,0,0],[1,207,0,0,0,0,0,0,0],[229,415,0,0,0,0,0,0,0],[219,415,207,0,0,0,0,0,0], [1,0,207,0,0,0,0,0,0],[225,415,0,0,0,0,0,0,0],[220,207,0,0,0,0,0,0,0],[227,415,0,0,0,0,0,0,0], [221,0,369,246,0,0,0,0,0],[224,493,0,0,0,0,0,0,0],[228,246,369,0,0,0,0,0,0],[218,493,0,0,0,0,0,0,0], [227,0,349,277,0,0,0,0,0],[221,0,0,277,0,0,0,0,0],[1,554,0,0,0,0,0,0,0],[225,0,277,0,0,0,0,0,0], [220,554,0,0,0,0,0,0,0],[228,207,415,0,0,0,0,0,0],[226,415,0,0,0,0,0,0,0],[221,415,0,0,0,0,0,0,0], [1,207,0,0,0,0,0,0,0],[225,0,0,0,0,0,0,0,0],[1,415,0,0,0,0,0,0,0],[220,207,0,0,0,0,0,0,0], [227,0,415,0,0,0,0,0,0],[219,207,0,0,0,0,0,0,0],[226,0,415,0,0,0,0,0,0],[226,622,184,0,0,0,0,0,0], [110,0,184,0,0,0,0,0,0],[110,554,369,0,0,0,0,0,0],[110,0,369,0,0,0,0,0,0],[116,493,0,184,0,0,0,0,0], [110,0,0,184,0,0,0,0,0],[112,466,369,0,0,0,0,0,0],[115,0,369,0,0,0,0,0,0],[108,493,369,0,0,0,0,0,0], [1,493,138,0,0,0,0,0,0],[109,0,138,0,0,0,0,0,0],[112,466,0,277,0,0,0,0,0],[115,0,0,277,0,0,0,0,0], [111,415,138,0,0,0,0,0,0],[109,0,138,0,0,0,0,0,0],[116,369,0,277,0,0,0,0,0],[111,0,0,277,0,0,0,0,0], [86,0,0,0,0,0,0,0,0]] while 1: for step in song: time.sleep_ms(step[0]) for i in range(maxNotes): sndmixer.freq(channels[i], step[1+i])