|
| 1 | +try: |
| 2 | + from lineusmusic import Keyboard |
| 3 | + from lineus import LineUs |
| 4 | +except ImportError: |
| 5 | + print('\n*** You need to install the lineusmusic module: \'pip install lineusmusic\' ***') |
| 6 | + exit(1) |
| 7 | + |
| 8 | +# Don't forget to 'pip install lineusmusic' before you run the code. |
| 9 | + |
| 10 | +# Music notation is lower case for natural notes and upper case for sharp, so 'a' is natural a |
| 11 | +# and A is a#. Next, we have the octave, '-' is one octave down and '+' one up. The key is fixed |
| 12 | +# as c major at the moment so this means that the note below c on the keyboard is b-. Lastly we have the duration. |
| 13 | +# The default length is one beat, the length of which is set using set_bpm(), and you can set the length to |
| 14 | +# multiples of this. So, for example a2 is an 'a' note played for two beats. An 'r' indicates a rest of one beat. |
| 15 | +# |
| 16 | +# When you create the Keyboard object it moves Line-us to a 'home' position. This is keyboard |
| 17 | +# specific but for the Volca and Stylophone it's 'c' so the input() is included in the code to allow you to |
| 18 | +# make sure your Line-us is in the right position before playing the song. |
| 19 | +# |
| 20 | +# It's easy to add a new keyboard type (see the LineUsMusic module docs for details) but for now we have |
| 21 | +# support for Stylophone and the Korg VolcaFM (actually it will work for some of the other Volcas too). |
| 22 | +# Line-us can't reach to full range of the Volca keyboard so there are two options keyboard='VolcaFM' |
| 23 | +# and keyboard='VolcaFMLow'. I've included scales for the keyboards we support so you can see what notes |
| 24 | +# you have available. |
| 25 | + |
| 26 | +areFriendsElectric = ('c', 'c', 'g', 'r', 'A-', 'A-', 'f', 'r', 'c', 'c', 'g', 'r', 'A-', 'A-', 'A', 'e') |
| 27 | +closeEncounters = ('g', 'a', 'f', 'f-', 'c') # only for VolcaFMLow |
| 28 | + |
| 29 | +volca_low_scale = ('f-', 'g-', 'a-', 'b-', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c+', 'd+', 'e+') |
| 30 | +volca_scale = ('g-', 'a-', 'b-', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c+', 'd+', 'e+', 'f+') |
| 31 | +stylophone_scale = ('a-', 'A-', 'b-', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c+', 'd+', 'e+') |
| 32 | + |
| 33 | +song = areFriendsElectric |
| 34 | + |
| 35 | +my_lineus = LineUs() |
| 36 | +my_lineus.connect('line-us.local') |
| 37 | +k = Keyboard(my_lineus, keyboard='Stylophone') |
| 38 | +k.set_bpm(110) |
| 39 | + |
| 40 | +input('Set Line-us to \'c\':') |
| 41 | + |
| 42 | +for song_note in song: |
| 43 | + k.play_note(song_note) |
0 commit comments