[Microbit-Python] Built in tunes.... enjoy..!

Nicholas H.Tollervey ntoll at ntoll.org
Tue Oct 13 17:55:33 CEST 2015


Hi Folks,

I've just spent half an hour collating these tunes for inclusion in the
music module (yet to be implemented). Please try them out like this:

>>> from microbit import music
>>> from microbit import pin0
>>> DADADADUM = ['r3:2', 'g', 'g', 'g', 'eb:8', 'r:2', 'f', 'f', 'f', 'd:8']
>>> music.tune(pin0, DADADADUM)

Make sure you have a speaker connected to GND and pin0 via crocodile
clips for the full force of the pathos of such fragments... ;-)

All of them are either out of copyright, composed by me and released to
the public domain or, in the case of nyan-cat, composer untraceable.

As you can see, I've tried to include different genres, music for
different occasions and some familiar tunes that could be re-used in
games. ;-)

Ultimately (once I've figured things out) you'll be able to do this:

>>> import microbit
>>> microbit.music.tune(microbit.pin0, microbit.music.NYAN)

The __repr__ for each melodic fragment will be the list of notes as
defined below (so people can see how they could re-create or adapt them).

Given a non-blocking music API (that Matthew is currently working on),
Mark's new image implementation and Larry's game related classes I think
we could implement a micro:nyan quite easily as a cool example.

;-)

Here they are in full:

DADADADUM = ['r3:2', 'g', 'g', 'g', 'eb:8', 'r:2', 'f', 'f', 'f', 'd:8']

ENTERTAINER = ['d3:1', 'd#', 'e', 'c4:2', 'e3:1', 'c4:2', 'e3:1',
'c4:3', 'c:1', 'd', 'd#', 'e', 'c', 'd', 'e:2', 'b3:1', 'd4:2', 'c:4']

PRELUDE = [
  'c3:1', 'e', 'g', 'c4', 'e', 'g3', 'c4', 'e', 'c3', 'e', 'g', 'c4',
'e', 'g3', 'c4', 'e',
  'c3', 'd', 'g', 'd4', 'f', 'g3', 'd4', 'f', 'c3', 'd', 'g', 'd4', 'f',
'g3', 'd4', 'f',
  'b2', 'd3', 'g', 'd4', 'f', 'g3', 'd4', 'f', 'b2', 'd3', 'g', 'd4',
'f', 'g3', 'd4', 'f',
  'c3', 'e', 'g', 'c4', 'e', 'g3', 'c4', 'e', 'c3', 'e', 'g', 'c4', 'e',
'g3', 'c4', 'e',
]

ODE = ['e4', 'e', 'f', 'g', 'g', 'f', 'e', 'd', 'c', 'c', 'd', 'e',
'e:6', 'd:2', 'd:8', 'e:4', 'e', 'f', 'g', 'g', 'f', 'e', 'd', 'c', 'c',
'd', 'e', 'd:6', 'c:2', 'c:8']

NYAN = ['f#4:2', 'g#', 'c#:1', 'd#:2', 'b3:1', 'd4:1', 'c#', 'b3:2',
'b', 'c#4', 'd', 'd:1', 'c#', 'b3:1', 'c#4:1', 'd#', 'f#', 'g#', 'd#',
'f#', 'c#', 'd', 'b3', 'c#4', 'b3', 'd#4:2', 'f#', 'g#:1', 'd#', 'f#',
'c#', 'd#', 'b3', 'd4', 'd#', 'd', 'c#', 'b3', 'c#4', 'd:2', 'b3:1',
'c#4', 'd#', 'f#', 'c#', 'd', 'c#', 'b3', 'c#4:2', 'b3', 'c#4', 'b3',
'f#:1', 'g#', 'b:2', 'f#:1', 'g#', 'b', 'c#4', 'd#', 'b3', 'e4', 'd#',
'e', 'f#', 'b3:2', 'b', 'f#:1', 'g#', 'b', 'f#', 'e4', 'd#', 'c#', 'b3',
'f#', 'd#', 'e', 'f#', 'b3:2', 'f#:1', 'g#', 'b:2', 'f#:1', 'g#', 'b',
'b', 'c#4', 'd#', 'b3', 'f#', 'g#', 'f#', 'b:2', 'b:1', 'a#', 'b', 'f#',
'g#', 'b', 'e4', 'd#', 'e', 'f#', 'b3:2', 'c#4']

RINGTONE = ['c3:1', 'd', 'e:2', 'g', 'd:1', 'e', 'f:2', 'a', 'e:1', 'f',
'g:2', 'b', 'c4:4']

FUNK = ['c2:2', 'c', 'd#', 'c:1', 'f:2', 'c:1', 'f:2', 'f#', 'g', 'c',
'c', 'g', 'c:1', 'f#:2', 'c:1', 'f#:2', 'f', 'd#']

BLUES = ['c2:2', 'e', 'g', 'a', 'a#', 'a', 'g', 'e', 'c2:2', 'e', 'g',
'a', 'a#', 'a', 'g', 'e', 'f', 'a', 'c3', 'd', 'd#', 'd', 'c', 'a2',
'c2:2', 'e', 'g', 'a', 'a#', 'a', 'g', 'e', 'g', 'b', 'd3', 'f', 'f2',
'a', 'c3', 'd#', 'c2:2', 'e', 'g', 'e', 'g', 'f', 'e', 'd']

BIRTHDAY = ['c3:3', 'c:1', 'd:4', 'c:4', 'f', 'e:8', 'c:3', 'c:1',
'd:4', 'c:4', 'g', 'f:8', 'c3:3', 'c:1', 'c4:4', 'a3', 'f', 'e', 'd',
'a#:3', 'a#:1', 'a:4', 'f', 'g', 'f:8']

WEDDING = ['c4:4', 'f:3', 'f:1', 'f:8', 'c:4', 'g:3', 'e:1', 'f:8',
'c:4', 'f:3', 'a:1', 'c5:4', 'a4:3', 'f:1', 'f:4', 'e:3', 'f:1', 'g:8']

FUNERAL = ['c3:4', 'c:3', 'c:1', 'c:4', 'd#:3', 'd:1', 'd:3', 'c:1',
'c:3', 'b2:1', 'c3:4']

PUNCHLINE = ['c4:3', 'g3:1', 'f#', 'g', 'g#:3', 'g', 'r', 'b', 'c4']

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://mail.python.org/mailman/private/microbit/attachments/20151013/5e38cee7/attachment.sig>


More information about the Microbit mailing list