Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 148 lines (118 sloc) 4.973 kb
d705b7af »
2011-08-15 get a first experimental version out
1 # Niki
2
3 Niki is a Ruby DSL to describe and play musical pieces.
4
961b4ae7 »
2011-08-15 release the ccrreeedit
5 Its name comes from the [world-famous band Niki](http://niki.fm) which I happen
5d434730 »
2011-08-16 niki 0.1.0 is crossplatformmm
6 to be part of :D
961b4ae7 »
2011-08-15 release the ccrreeedit
7
5d434730 »
2011-08-16 niki 0.1.0 is crossplatformmm
8 It leverages Ari Russo's [Unimidi](
9 https://github.com/arirusso/unimidi) to send MIDI output to other
d705b7af »
2011-08-15 get a first experimental version out
10 programs accepting MIDI inputs (Ableton Live, Reason, Garage Band...), which
11 will actually play the song.
12
961b4ae7 »
2011-08-15 release the ccrreeedit
13 To see what the DSL looks like, take a look at the [example song](https://github.com/txus/niki/blob/master/examples/my_song.rb).
d705b7af »
2011-08-15 get a first experimental version out
14
5d434730 »
2011-08-16 niki 0.1.0 is crossplatformmm
15 Thanks to Unimidi, it works on all major platforms (Linux, OSX and Windows). To
16 ensure Niki will run on your platform (I've personally tested it with OSX only),
17 please look at the [Unimidi repo at Github](https://github.com/arirusso/unimidi)
18 for instructions about your specific platform.
d705b7af »
2011-08-15 get a first experimental version out
19
5d434730 »
2011-08-16 niki 0.1.0 is crossplatformmm
20 Currently niki runs (at least) on Ruby MRI versions 1.8.7 and 1.9.2.
d705b7af »
2011-08-15 get a first experimental version out
21
22 ## Run the example song
23
24 First of all, get the example song files (both the Reason file and the Ruby file)
25
26 $ curl -o my_song.rns https://raw.github.com/txus/niki/master/examples/my_song.rns
27 $ curl -o my_song.rb https://raw.github.com/txus/niki/master/examples/my_song.rb
28
29 Now [download a demo version](
30 http://www.propellerheads.se/download/index.cfm?fuseaction=get_article&article=reason) of Propellerhead's
31 Reason 5 and open up `my_song.rns`.
32
33 ### Configuring the midi interface
34
35 This is how you configure the midi interface in Mac OSX (it should not be
36 difficult in other operating systems):
37
38 * Make sure the IAC driver is activated in Mac OSX's Audio/MIDI Setup (inside the
39 MIDI section) (activate the "Device is online" checkbox if it is not)
40 * Go to the Reason options panel, go to Advanced, and set your first
5d434730 »
2011-08-16 niki 0.1.0 is crossplatformmm
41 MIDI bus (Bus A) to "IAC Driver IAC Bus 1" or something similar.
d705b7af »
2011-08-15 get a first experimental version out
42
43 ### Install the gem and run!
44
45 Now you should install the gem and run the example!
46
47 $ gem install niki
48 $ ruby my_song.rb
49
271e0d9f »
2011-08-19 new sharp/flat syntax and nice syntax reference
50 ## Syntax reference
51
52 A Niki Song is represented this way:
53
54 song = Niki::Song.new do
55
56 # +instrument+ lets you configure different instruments in different
57 # MIDI channels.
58 instrument :piano do
59 channel 3
60 end
61
62 instrument :drums do
63 channel 10
64
65 # You can define macros for notes:
66 note[:kick] = c1 # Define a macro for the c1 note, name it :kick
67 note[:snare] = d1 # And the snare will be d1
68 note[:hh] = e1 # And the hh will be e1
69 end
70
77173840 »
2011-08-19 support for reusable riffs
71 # You can define reusable riffs that you will be able to play with
72 # different instruments:
73 riff :simple_break do
74 note g3, 8
75 note f3, 8
76 note e3, 8
77 note d3, 8
78 end
79
271e0d9f »
2011-08-19 new sharp/flat syntax and nice syntax reference
80 # Define your song parts like this:
81 part :intro do
82 # Notes are defined like this:
83 # +instrument+ +note or [array of notes]+, +duration+, +options+
84 #
85 # +instrument+
86 # Instrument must be one of those you defined above.
87 #
88 # +note or [array of notes]+
89 # Has to be a musical note like c3 or f2 or a chord like a3MAJ. It
90 # can also be an array of notes. Examples of valid musical notes:
91 #
92 # c2 - a C in the 2nd octave
93 # f4 - an F in the 4th octave
94 # +f4 - an F sharp in the 4th octave
95 # -d3 - a D flat in the 3rd octave
96 # f3MAJ - a F major chord in the 3rd octave
97 # -d3MIN - a D flat minor chord in the 3rd octave
98 # [c3, -e3, g3, -b3] - a C min 7th chord in the 3rd octave
99 # :kick - whatever note you defined in your instrument
100 #
101 # +duration+
102 # Duration can be expressed as a number representing a fraction.
103 # For example, a quarter note (4 of them fit in a single
104 # measure) is expressed with the number 4. An eighth note (8 of them
105 # fit in a single measure) is expressed with 8, and so on.
106 #
107 # +options+
108 # Options is an optional hash where you can specify the following
109 # per-note settings:
110 #
111 # :velocity => (a number between 0 and 127)
112 # :base => (a base note to add to some chord for example)
113 #
114 drums [:kick, :hh], 8
115 drums :hh, 8
116 drums :hh, 8
117
118 piano f2MAJ, 4
119 piano f2MAJ, 4
120 piano f2MAJ, 4
121 piano f2MAJ, 4
122 piano a2MIN, 4, :base => f2
123 piano silence, 4
77173840 »
2011-08-19 support for reusable riffs
124
125 # Play the previously defined riff with the piano.
126 riff :simple_break, :piano
271e0d9f »
2011-08-19 new sharp/flat syntax and nice syntax reference
127 end
128
129 # You can repeat any part!
130 repeat :intro
131
132 part :chorus do
133 drums :from => :intro # Use the drums from the intro
134
135 piano c2MAJ, 4
136 piano c2MAJ, 4
137 piano c2MAJ, 4
138 piano c2MAJ, 4
139 piano g2MAJ, 4
140 piano silence, 4
141 piano g2MAJ, 4
142 piano g2MAJ, 8
143 piano g2MAJ, 8
144 end
145 end
146
147 # Play the song!!!
148 song.play
77173840 »
2011-08-19 support for reusable riffs
149
Something went wrong with that request. Please try again.