zgomot 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/README.rdoc +191 -98
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/bin/zgomot +1 -1
- data/examples/arp_chords.rb +1 -4
- data/examples/delay.rb +16 -0
- data/examples/full_scale_notes.rb +2 -5
- data/examples/inv_chords.rb +1 -4
- data/examples/modes_notes.rb +2 -5
- data/examples/notes.rb +1 -5
- data/examples/percs.rb +4 -8
- data/examples/percs_multi.rb +1 -5
- data/examples/phase_notes.rb +4 -8
- data/examples/prog_chords.rb +2 -5
- data/examples/prog_chords_multi_vel_length.rb +1 -4
- data/examples/prog_chords_rest.rb +1 -4
- data/examples/prog_notes.rb +1 -4
- data/examples/prog_notes_multi_vel_length.rb +1 -4
- data/examples/prog_notes_rest.rb +1 -4
- data/examples/progressive_modes.rb +10 -18
- data/examples/reverse_chords.rb +1 -4
- data/examples/route_chords.rb +22 -0
- data/examples/scale_chords.rb +1 -4
- data/examples/scale_notes.rb +1 -4
- data/examples/scales_notes.rb +1 -5
- data/examples/simple_chords.rb +1 -4
- data/examples/simple_input.rb +21 -0
- data/examples/simple_markov.rb +1 -5
- data/examples/simple_notes.rb +2 -5
- data/examples/zgomot_streams.rb +19 -0
- data/lib/zgomot/boot.rb +5 -31
- data/lib/zgomot/comp/chord.rb +16 -70
- data/lib/zgomot/comp/markov.rb +8 -26
- data/lib/zgomot/comp/mode.rb +9 -32
- data/lib/zgomot/comp/note.rb +1 -16
- data/lib/zgomot/comp/pattern.rb +1 -24
- data/lib/zgomot/comp/permutation.rb +0 -11
- data/lib/zgomot/comp/pitch_class.rb +3 -28
- data/lib/zgomot/comp/progression.rb +15 -49
- data/lib/zgomot/comp/scale.rb +5 -14
- data/lib/zgomot/config.rb +3 -18
- data/lib/zgomot/drivers/core_midi.rb +129 -92
- data/lib/zgomot/drivers/driver.rb +2 -15
- data/lib/zgomot/drivers/mgr.rb +5 -21
- data/lib/zgomot/main.rb +13 -24
- data/lib/zgomot/midi/cc.rb +67 -0
- data/lib/zgomot/midi/channel.rb +20 -50
- data/lib/zgomot/midi/clock.rb +21 -48
- data/lib/zgomot/midi/dispatcher.rb +13 -26
- data/lib/zgomot/midi/note.rb +11 -34
- data/lib/zgomot/midi/stream.rb +82 -43
- data/lib/zgomot/midi.rb +1 -0
- data/lib/zgomot/ui/output.rb +67 -0
- data/lib/zgomot/ui/windows.rb +359 -0
- data/lib/zgomot/ui.rb +3 -0
- data/lib/zgomot.rb +6 -1
- data/lib/{zlive.rb → zgomot_sh.rb} +1 -0
- data/zgomot.gems +14 -0
- data/zgomot.gemspec +26 -14
- metadata +52 -9
- data/default.gems +0 -7
- data/examples/simple_notes_length.rb +0 -17
- data/examples/simple_notes_velocity.rb +0 -17
data/examples/percs_multi.rb
CHANGED
@@ -1,18 +1,14 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
score = [pr([:acoustic_bass_drum, :cowbell]), pr(:R), pr([:acoustic_snare, :hand_clap]), pr(:R)]
|
11
9
|
|
12
|
-
#.........................................................................................................
|
13
10
|
str 'percussion', score, :lim=>:inf do |pattern|
|
14
|
-
|
11
|
+
pattern
|
15
12
|
end
|
16
13
|
|
17
|
-
#.........................................................................................................
|
18
14
|
play
|
data/examples/phase_notes.rb
CHANGED
@@ -1,20 +1,16 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
ch(0) << pattern.mode!((count/4) % 7 + 1)
|
8
|
+
str 'melody-1', np([:B,3],nil,:l=>4)[1,4,5,5], :lim=>:inf, :ch => 0 do |pattern|
|
9
|
+
pattern.mode!((count/4) % 7 + 1)
|
12
10
|
end
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
ch(1) << pattern
|
12
|
+
str 'melody-2', np([:B,3],:ionian,:l=>4)[1,4,5,5].bpm!(16.0/15.0), :lim=>:inf, :ch => 1 do |pattern|
|
13
|
+
pattern
|
17
14
|
end
|
18
15
|
|
19
|
-
#.........................................................................................................
|
20
16
|
play
|
data/examples/prog_chords.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
ch << pattern
|
8
|
+
str 'prog', cp([:B,3],:ionian,:l=>4)[1,4,5,5], :lim=>6 do |pattern|
|
9
|
+
pattern
|
12
10
|
end
|
13
11
|
|
14
|
-
#.........................................................................................................
|
15
12
|
play
|
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
str 'prog', cp([:A,4],nil,:l=>[4,4,8,8,4], :v=>[0.6, 0.4, 0.7, 0.6, 0.4])[7,5,3,3,1], :lim=>6 do |pattern|
|
11
|
-
|
9
|
+
pattern.mode!(count)
|
12
10
|
end
|
13
11
|
|
14
|
-
#.........................................................................................................
|
15
12
|
play
|
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
str 'prog', cp([:B,3],:ionian,:l=>4)[1,4,:R,5], :lim=>1 do |pattern|
|
11
|
-
|
9
|
+
pattern
|
12
10
|
end
|
13
11
|
|
14
|
-
#.........................................................................................................
|
15
12
|
play
|
data/examples/prog_notes.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
str 'prog', np([:A,4],nil,:l=>4)[7,5,3,1], :lim=>6 do |pattern|
|
11
|
-
|
9
|
+
pattern.mode!(count)
|
12
10
|
end
|
13
11
|
|
14
|
-
#.........................................................................................................
|
15
12
|
play
|
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
str 'prog', np([:A,4],nil,:l=>[4,4,8,8,4], :v=>[0.6, 0.4, 0.7, 0.6, 0.4])[7,5,3,3,1], :lim=>6 do |pattern|
|
11
|
-
|
9
|
+
pattern.mode!(count)
|
12
10
|
end
|
13
11
|
|
14
|
-
#.........................................................................................................
|
15
12
|
play
|
data/examples/prog_notes_rest.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
str 'prog', np([:A,4],nil,:l=>4)[7,:R,3,1], :lim=>6 do |pattern|
|
11
|
-
|
9
|
+
pattern.mode!(count)
|
12
10
|
end
|
13
11
|
|
14
|
-
#.........................................................................................................
|
15
12
|
play
|
@@ -1,16 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
|
10
|
-
major_modes = [:ionian, :lydian, :mixolydian]
|
8
|
+
major_modes = [:ionian, :lydian, :mixolydian]
|
11
9
|
minor_modes = [:dorian, :phrygian, :aeolian]
|
12
10
|
|
13
|
-
#.........................................................................................................
|
14
11
|
m_slow = mark
|
15
12
|
m_slow.add([0.6, 0.4]) do |count|
|
16
13
|
np([:A,4],major_modes[count % 3],:l=>4)[7,5,3,1]
|
@@ -19,12 +16,10 @@ m_slow.add([0.4, 0.6]) do |count|
|
|
19
16
|
np([:A,4],minor_modes[count % 3],:l=>4)[7,5,3,1]
|
20
17
|
end
|
21
18
|
|
22
|
-
#.........................................................................................................
|
23
19
|
str :slow do
|
24
|
-
|
20
|
+
m_slow.next(count)
|
25
21
|
end
|
26
22
|
|
27
|
-
#.........................................................................................................
|
28
23
|
m_fast = mark
|
29
24
|
m_fast.add([0.6, 0.4]) do |count|
|
30
25
|
np([:G,4],major_modes[count % 3],:l=>4)[7,5,3,1].bpm!(16.0/15.0)
|
@@ -33,19 +28,16 @@ m_fast.add([0.4, 0.6]) do |count|
|
|
33
28
|
np([:G,4],minor_modes[count % 3],:l=>4)[7,5,3,1].bpm!(16.0/15.0)
|
34
29
|
end
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
ch(1) << m_fast.next(count)
|
31
|
+
str :fast, nil, :ch => 1 do
|
32
|
+
m_fast.next(count)
|
39
33
|
end
|
40
34
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
35
|
+
str :perc, nil, :ch => 2 do
|
36
|
+
if (count % 2).eql?(0)
|
37
|
+
[pr(:R, :l=>2), pr(:hand_clap), pr(:hand_clap)]
|
38
|
+
else
|
39
|
+
pr(:R,:l=>1)
|
40
|
+
end
|
48
41
|
end
|
49
42
|
|
50
|
-
#.........................................................................................................
|
51
43
|
play
|
data/examples/reverse_chords.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
str 'chords', [c(:C,:min).arp!(4), c(:C,:min).arp!(4).rev!, c(:E,:min).arp!(4), c(:E,:min).arp!(4).rev!], :lim=>3 do |pattern|
|
11
|
-
|
9
|
+
pattern
|
12
10
|
end
|
13
11
|
|
14
|
-
#.........................................................................................................
|
15
12
|
play
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
|
+
|
4
|
+
before_start do
|
5
|
+
Zgomot.logger.level = Logger::DEBUG
|
6
|
+
end
|
7
|
+
|
8
|
+
chords = cp([:B,3],:ionian,:l=>4)[1,4,5,5]
|
9
|
+
|
10
|
+
str 'note-0', chords.note(0), :ch=>0 do |pattern|
|
11
|
+
pattern
|
12
|
+
end
|
13
|
+
|
14
|
+
str 'note-1', chords.note(1), :ch=>1 do |pattern|
|
15
|
+
pattern
|
16
|
+
end
|
17
|
+
|
18
|
+
str 'note-2', chords.note(2), :ch=>2 do |pattern|
|
19
|
+
pattern
|
20
|
+
end
|
21
|
+
|
22
|
+
run
|
data/examples/scale_chords.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
str 'scale', cp([:C,4],:ionian,:l=>4), :lim=>1 do |pattern|
|
11
|
-
|
9
|
+
pattern
|
12
10
|
end
|
13
11
|
|
14
|
-
#.........................................................................................................
|
15
12
|
play
|
data/examples/scale_notes.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
str 'scale', [np([:C,4],:dorian,:l=>4), np([:C,4],:dorian,:l=>4).reverse!.shift, n(:R)], :lim=>3 do |pattern|
|
11
|
-
|
9
|
+
pattern
|
12
10
|
end
|
13
11
|
|
14
|
-
#.........................................................................................................
|
15
12
|
play
|
data/examples/scales_notes.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
pclass = [:C, :Cs, :D, :Ds, :E, :F, :Fs, :G, :Gs, :A, :As, :B]
|
11
9
|
|
12
|
-
#.........................................................................................................
|
13
10
|
str 'scale', [np(nil,:dorian,:l=>4), np(nil,:dorian,:l=>4).reverse!.shift, n(:R)], :lim=>pclass.length do |pattern|
|
14
11
|
Zgomot.logger.info "TONIC: [#{pclass[count-1]},4], MODE: dorian"
|
15
|
-
|
12
|
+
pattern.tonic!([pclass[count-1], 4])
|
16
13
|
end
|
17
14
|
|
18
|
-
#.........................................................................................................
|
19
15
|
play
|
data/examples/simple_chords.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
str 'chords', [ c(:C), c(:E,:min), c(:D,:min), c(:B,:dim), c(:G,:maj)], :lim=>3 do |pattern|
|
11
|
-
|
9
|
+
pattern
|
12
10
|
end
|
13
11
|
|
14
|
-
#.........................................................................................................
|
15
12
|
play
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
|
+
|
4
|
+
before_start do
|
5
|
+
Zgomot.logger.level = Logger::DEBUG
|
6
|
+
end
|
7
|
+
|
8
|
+
if sources.include?("nanoKONTROL")
|
9
|
+
add_input("nanoKONTROL")
|
10
|
+
add_cc(:mode, 17, :type => :cont, :min => 0, :max => 6, :init => 0)
|
11
|
+
add_cc(:reverse, 13, :type => :switch)
|
12
|
+
str 'simple_input', np([:A,4],2,:l=>4)[7,5,3,1] do |pattern|
|
13
|
+
if cc(:reverse)
|
14
|
+
pattern.mode!(cc(:mode).to_i).reverse!
|
15
|
+
else
|
16
|
+
pattern.mode!(cc(:mode).to_i)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
play
|
20
|
+
end
|
21
|
+
|
data/examples/simple_markov.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
m = mark
|
11
9
|
m.add([0.6, 0.4]) do
|
12
10
|
np([:A,4],:dorian,:l=>4)[7,5,3,1,]
|
@@ -15,10 +13,8 @@ m.add([0.4, 0.6]) do
|
|
15
13
|
np([:A,4],:ionian,:l=>4)[7,5,3,1]
|
16
14
|
end
|
17
15
|
|
18
|
-
#.........................................................................................................
|
19
16
|
str 'markov' do
|
20
|
-
|
17
|
+
m.next
|
21
18
|
end
|
22
19
|
|
23
|
-
#.........................................................................................................
|
24
20
|
play
|
data/examples/simple_notes.rb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require "#{File.dirname(__FILE__)}/../lib/zgomot"
|
3
3
|
|
4
|
-
#.........................................................................................................
|
5
4
|
before_start do
|
6
5
|
Zgomot.logger.level = Logger::DEBUG
|
7
6
|
end
|
8
7
|
|
9
|
-
#.........................................................................................................
|
10
8
|
str 'notes' do
|
11
|
-
|
9
|
+
[n([:C,5]), n(:B), n(:R), n(:G), n(:C,:l=>2), n([:E,5],:l=>2)]
|
12
10
|
end
|
13
11
|
|
14
|
-
|
15
|
-
play
|
12
|
+
play
|
@@ -0,0 +1,19 @@
|
|
1
|
+
set_config(:beats_per_minute=>120, :time_signature=>"4/4", :resolution=>"1/64")
|
2
|
+
|
3
|
+
add_input("nanoKONTROL") if sources.include?("nanoKONTROL")
|
4
|
+
add_cc(:mode, 17, :type => :cont, :min => 0, :max => 6, :init => 0)
|
5
|
+
add_cc(:reverse, 13, :type => :switch)
|
6
|
+
|
7
|
+
|
8
|
+
str 'input', np([:A,4],2,:l=>4)[7,5,3,1], :ch=>0 do |pattern|
|
9
|
+
if cc(:reverse)
|
10
|
+
pattern.mode!(cc(:mode).to_i).reverse!
|
11
|
+
else
|
12
|
+
pattern.mode!(cc(:mode).to_i)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
str 'chords', cp([:B,3],:ionian,:l=>4)[1,4,5,5], :lim=>6, :ch=>1 do |pattern|
|
17
|
+
pattern
|
18
|
+
end
|
19
|
+
|
data/lib/zgomot/boot.rb
CHANGED
@@ -1,56 +1,30 @@
|
|
1
|
-
##############################################################################################################
|
2
1
|
module Zgomot
|
3
2
|
|
4
|
-
#####-------------------------------------------------------------------------------------------------------
|
5
3
|
class Boot
|
6
|
-
|
7
|
-
####......................................................................................................
|
8
4
|
class << self
|
9
|
-
|
10
|
-
#.......................................................................................................
|
11
5
|
def boot
|
12
|
-
|
13
|
-
####..............
|
14
6
|
Zgomot.logger = Logger.new(STDOUT)
|
15
|
-
Zgomot.logger.level = Logger::WARN
|
16
|
-
|
17
|
-
####..............
|
7
|
+
Zgomot.logger.level = Logger::WARN
|
18
8
|
call_if_implemented(:call_before_start)
|
19
|
-
|
20
|
-
####..............
|
21
9
|
Zgomot.logger.info "ZGOMOT BEGINNING"
|
22
10
|
Zgomot.logger.info "APPLICATION PATH: #{Zgomot.app_path}"
|
23
11
|
Zgomot.logger.info "CONFIGURATION FILE: #{Zgomot.config_file}"
|
24
|
-
Zgomot.logger.info "CONFIGURATION: #{Zgomot.config.inspect}"
|
25
|
-
|
12
|
+
Zgomot.logger.info "CONFIGURATION: #{Zgomot.config.inspect}"
|
26
13
|
end
|
27
|
-
|
28
|
-
####....................................................................................................
|
29
|
-
# application deligate methods
|
30
|
-
#.......................................................................................................
|
31
14
|
def call_if_implemented(method, *args)
|
32
15
|
send(method, *args) if respond_to?(method)
|
33
16
|
end
|
34
|
-
|
35
|
-
#.........................................................................................................
|
36
17
|
def callbacks(*args)
|
37
|
-
args.each do |meth|
|
18
|
+
args.each do |meth|
|
38
19
|
instance_eval <<-do_eval
|
39
20
|
def #{meth}(&blk)
|
40
21
|
define_meta_class_method(:call_#{meth}, &blk)
|
41
22
|
end
|
42
23
|
do_eval
|
43
24
|
end
|
44
|
-
end
|
45
|
-
|
46
|
-
#### self
|
25
|
+
end
|
47
26
|
end
|
48
|
-
|
49
|
-
#.........................................................................................................
|
50
27
|
callbacks(:before_start)
|
51
|
-
|
52
|
-
#### Boot
|
53
28
|
end
|
54
|
-
|
55
|
-
#### Zgomot
|
29
|
+
|
56
30
|
end
|
data/lib/zgomot/comp/chord.rb
CHANGED
@@ -1,41 +1,28 @@
|
|
1
|
-
##############################################################################################################
|
2
1
|
module Zgomot::Comp
|
3
2
|
|
4
|
-
#####-------------------------------------------------------------------------------------------------------
|
5
3
|
class Chord
|
6
4
|
|
7
|
-
#####-------------------------------------------------------------------------------------------------------
|
8
|
-
# progession interface
|
9
|
-
#####-------------------------------------------------------------------------------------------------------
|
10
5
|
class Progression
|
11
|
-
|
12
|
-
#.........................................................................................................
|
13
|
-
attr_reader :chord
|
14
6
|
|
15
|
-
|
7
|
+
attr_reader :chord
|
16
8
|
def initialize(chord)
|
17
9
|
@chord = chord || :scale
|
18
10
|
end
|
19
|
-
|
20
|
-
#.........................................................................................................
|
21
11
|
def notes(prog)
|
22
12
|
chords = prog.mode.chords(chord); count = -1
|
23
|
-
prog.items.select do |d|
|
13
|
+
prog.items.select do |d|
|
24
14
|
d.eql?(:R) || chords[d-1]
|
25
15
|
end.map do |d|
|
26
16
|
count += 1; idx_length, idx_velocity = count % prog.length.length, count % prog.velocity.length
|
27
17
|
unless d.eql?(:R)
|
28
18
|
Chord.new(:tonic => prog.pitches[d-1], :chord => chords[d-1], :length => prog.length[idx_length], :velocity => prog.velocity[idx_velocity])
|
29
19
|
else
|
30
|
-
Zgomot::Midi::Note.new(:pitch => :R, :length => prog.length[idx_length], :velocity => prog.velocity[idx_velocity])
|
20
|
+
Zgomot::Midi::Note.new(:pitch => :R, :length => prog.length[idx_length], :velocity => prog.velocity[idx_velocity])
|
31
21
|
end
|
32
22
|
end
|
33
23
|
end
|
34
|
-
|
35
|
-
#### Progression
|
36
24
|
end
|
37
25
|
|
38
|
-
#.........................................................................................................
|
39
26
|
@chord_intervals = {
|
40
27
|
:maj => [4,7],
|
41
28
|
:min => [3,7],
|
@@ -44,24 +31,17 @@ module Zgomot::Comp
|
|
44
31
|
:sus2 => [2,7],
|
45
32
|
:sus4 => [5,7]
|
46
33
|
}
|
47
|
-
|
48
|
-
#####-------------------------------------------------------------------------------------------------------
|
34
|
+
|
49
35
|
class << self
|
50
|
-
|
51
|
-
#.........................................................................................................
|
52
36
|
attr_reader :chord_intervals
|
53
|
-
|
54
|
-
#### self
|
55
37
|
end
|
56
|
-
|
57
|
-
#.........................................................................................................
|
38
|
+
|
58
39
|
attr_reader :tonic, :chord, :clock, :intervals, :arp, :time_scale, :items, :inversion, :reverse
|
59
40
|
attr_accessor :length, :velocity
|
60
|
-
|
61
|
-
#.........................................................................................................
|
41
|
+
|
62
42
|
def initialize(args)
|
63
43
|
@length, @velocity, @chord = args[:length], args[:velocity], args[:chord]
|
64
|
-
(@intervals = Chord.chord_intervals[chord]) || raise(Zgomot::Error, "#{chord.inspect} is invalid")
|
44
|
+
(@intervals = Chord.chord_intervals[chord]) || raise(Zgomot::Error, "#{chord.inspect} is invalid")
|
65
45
|
@time_scale, @inversion, @reverse = 1.0, 0, false
|
66
46
|
@tonic = case args[:tonic]
|
67
47
|
when Array then args[:tonic]
|
@@ -71,101 +51,67 @@ module Zgomot::Comp
|
|
71
51
|
end
|
72
52
|
end
|
73
53
|
|
74
|
-
#.........................................................................................................
|
75
54
|
def pitches
|
76
55
|
last_pitch, octave = tonic; pitches = [tonic]
|
77
56
|
intervals.each_index{|i| pitches << PitchClass.next(tonic.first, intervals[i])}
|
78
57
|
nts = pitches[1..-1].map do |p|
|
79
58
|
octave += 1 if p < last_pitch; last_pitch = p.value; [last_pitch, octave]
|
80
59
|
end.unshift(tonic)
|
81
|
-
@reverse ? invert(nts).reverse : invert(nts)
|
60
|
+
@reverse ? invert(nts).reverse : invert(nts)
|
61
|
+
end
|
62
|
+
def note(number)
|
63
|
+
Zgomot::Midi::Note.new(:pitch => pitches[number], :length => length, :velocity => velocity)
|
82
64
|
end
|
83
|
-
|
84
|
-
#.........................................................................................................
|
85
65
|
def notes
|
86
|
-
@notes ||= pitches.map do |p|
|
66
|
+
@notes ||= pitches.map do |p|
|
87
67
|
Zgomot::Midi::Note.new(:pitch => p, :length => length, :velocity => velocity)
|
88
|
-
end
|
68
|
+
end
|
89
69
|
end
|
90
|
-
|
91
|
-
#.........................................................................................................
|
92
|
-
# transforms
|
93
|
-
#.........................................................................................................
|
94
70
|
def arp!(v)
|
95
71
|
@notes = nil; @arp = v; self
|
96
72
|
end
|
97
|
-
|
98
|
-
#.........................................................................................................
|
99
73
|
def inv!(v)
|
100
74
|
@notes = nil; @inversion = v; self
|
101
75
|
end
|
102
|
-
|
103
|
-
#.........................................................................................................
|
104
76
|
def rev!
|
105
77
|
@reverse = true; self
|
106
78
|
end
|
107
|
-
|
108
|
-
#.........................................................................................................
|
109
79
|
def bpm!(v)
|
110
80
|
@time_scale = 1.0/v.to_f; self
|
111
81
|
end
|
112
|
-
|
113
|
-
#.........................................................................................................
|
114
82
|
def octave!(v)
|
115
83
|
@notes = nil; @octave = v; self
|
116
84
|
end
|
117
|
-
|
118
|
-
#.........................................................................................................
|
119
|
-
# channel and dispatch interface
|
120
|
-
#.........................................................................................................
|
121
85
|
def length_to_sec
|
122
86
|
time_scale*Zgomot::Midi::Clock.whole_note_sec*(1.0/length + (arp.to_f.eql?(0.0) ? 0.0 : intervals.length.to_f/arp.to_f))
|
123
87
|
end
|
124
|
-
|
125
|
-
#.........................................................................................................
|
126
88
|
def to_midi
|
127
89
|
notes.map{|n| n.to_midi}
|
128
90
|
end
|
129
|
-
|
130
|
-
#.........................................................................................................
|
131
91
|
def channel=(chan)
|
132
92
|
notes.each{|n| n.channel = chan}
|
133
93
|
end
|
134
|
-
|
135
|
-
#.........................................................................................................
|
136
94
|
def offset_time=(time)
|
137
95
|
notes.each{|n| n.offset_time = time}
|
138
96
|
end
|
139
|
-
|
140
|
-
#.........................................................................................................
|
141
97
|
def time=(time)
|
142
98
|
@clock = Zgomot::Midi::Clock.new
|
143
99
|
clock.update(time)
|
144
100
|
notes.each do |n|
|
145
101
|
n.time = clock.current_time
|
146
|
-
clock.update(Zgomot::Midi::Clock.whole_note_sec/arp.to_f) if arp.to_f > 0.0
|
102
|
+
clock.update(Zgomot::Midi::Clock.whole_note_sec/arp.to_f) if arp.to_f > 0.0
|
147
103
|
end
|
148
104
|
end
|
149
|
-
|
150
|
-
#.........................................................................................................
|
151
|
-
# private
|
152
|
-
#.........................................................................................................
|
153
105
|
def sum(a)
|
154
106
|
a.inject(0) {|s,n| s+n}
|
155
107
|
end
|
156
|
-
|
157
|
-
#.........................................................................................................
|
158
108
|
def invert(p)
|
159
109
|
inversion.times do |i|
|
160
|
-
n = p.shift; p.push([n.first, (n.last.eql?(9) ? n.last : n.last+1)])
|
110
|
+
n = p.shift; p.push([n.first, (n.last.eql?(9) ? n.last : n.last+1)])
|
161
111
|
end; p
|
162
112
|
end
|
163
|
-
|
164
|
-
#.........................................................................................................
|
165
113
|
private :sum, :invert
|
166
|
-
|
167
|
-
#### Chord
|
114
|
+
|
168
115
|
end
|
169
116
|
|
170
|
-
#### Zgomot::Comp
|
171
117
|
end
|