Skip to content

Commit d03e46b

Browse files
committed
LineUsPlaysKeyboards updates
1 parent a1df40d commit d03e46b

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

Python/LineUsPlaysKeyboards.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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)

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ Pandrr has ported our Python example to Node! - check out his GitHub [here](http
4545
### Simple Dart Example
4646
[Source code](Dart/line_us.dart) for a very simple example can be downloaded from [here](../../raw/master/Dart/line_us.dart). You'll need [Dart](https://www.dartlang.org/) installed.
4747

48-
49-
### Simple C Sharp Unity Example PopLineus
50-
C (wrapped in unity for now) implementation of the protocol for Line-us created by solentygraham, check out his GitHub [here](https://github.com/NewChromantics/PopLineus)
51-
5248
### Simple C Example
5349
[Source code](C/lineustest.c) for a simple example in C created by Paul Haberli can be downloaded from [here](../../raw/master/C/lineustest.c). The code complies on MACOS using gcc but should be fairly portable. A [Makefile](C/Makefile) is also included so if you have gcc in your path, just type 'make'
5450

51+
### Simple C Sharp Unity Example PopLineus
52+
C# (wrapped in unity for now) implementation of the protocol for Line-us created by solentygraham, check out his GitHub [here](https://github.com/NewChromantics/PopLineus)
53+
5554
## Applications and other fun things to do with your Line-us
55+
### Line-us Music
56+
We've taught Line-us to play keyboards with some [simple Python3 code](Python/LineUsPlaysKeyboards.py#L1) that can be downloaded from [here](../../raw/master/Python/LineUsPlaysKeyboards.py). It's Python3 only so if you're on a Mac you'll need to install Python3 for it to work. We've put all of the keyboard code into a module, so you will need to istall that using `pip install lineusmusic`. When you install `lineusmusic` you'll also get the `lineus` module, but if you want to install that separately you can `pip install lineus`. As usual, we'd recommend using a virtual environment - my prefenece is [pipenv](https://thoughtbot.com/blog/how-to-manage-your-python-projects-with-pipenv) but there are a few options.
57+
5658
### Line-us JS Kit
5759
Write commands in JavaScript and preview the drawing in your browser before sending to Line-us! Created by Alex Kempton, check out his Github [here](https://github.com/funwithtriangles/line-us-js-kit)
5860

0 commit comments

Comments
 (0)