rhythmruby 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -0
- data/examples/Meshuggah_example.rb +2 -1
- data/examples/drum_kit_example.rb +3 -0
- data/lib/rhythmruby/LogicalRhythms.rb +1 -1
- data/lib/rhythmruby/MidiWriter.rb +18 -3
- data/lib/rhythmruby/RhythmParser.rb +1 -1
- data/lib/rhythmruby/version.rb +1 -1
- metadata +3 -4
data/README.md
CHANGED
@@ -84,8 +84,9 @@ rhythms.each_key do
|
|
84
84
|
|
85
85
|
# write the midi info/sequence to the midiTrack
|
86
86
|
midiWriter.writeSeqToTrack(midiSequence, midiTrack)
|
87
|
-
|
88
87
|
end
|
89
88
|
|
89
|
+
# merge the midi tracks to a single track (for single file import into DAW)
|
90
|
+
midiWriter.mergeTracks
|
90
91
|
# write the midiSong to a file
|
91
92
|
midiWriter.writeToFile(fileName)
|
@@ -18,7 +18,7 @@ class LogicalRhythms
|
|
18
18
|
return slaveRhythm
|
19
19
|
end
|
20
20
|
|
21
|
-
# logical XOR of two rhythms, true except both true
|
21
|
+
# logical XOR of two rhythms, true except both true or both false
|
22
22
|
# @param [String] masterRhythm rhythm to intersect with
|
23
23
|
# @param [String] slaveRhythm rhythm to intersect
|
24
24
|
# @return [String] intersected slaveRhythm
|
@@ -47,8 +47,11 @@ class MidiWriter
|
|
47
47
|
# @param [Float] noteLength length of the midiEvent, in multiples of the quarternote
|
48
48
|
# @param [MIDI::Track] midiTrack where the event is written to
|
49
49
|
def writeNote(midiNote, noteLength, midiTrack)
|
50
|
-
|
51
|
-
|
50
|
+
# if the velocity is 0, the note is not played.
|
51
|
+
# use this for an initial silent note.
|
52
|
+
velocity = (midiNote == 0) ? 0 : 127
|
53
|
+
midiTrack.events << MIDI::NoteOnEvent.new(0, midiNote, velocity, 0)
|
54
|
+
midiTrack.events << MIDI::NoteOffEvent.new(0, midiNote, velocity, \
|
52
55
|
@song.length_to_delta(noteLength))
|
53
56
|
end
|
54
57
|
|
@@ -57,4 +60,16 @@ class MidiWriter
|
|
57
60
|
def writeToFile(fileName)
|
58
61
|
open(fileName, 'w') {|f| @song.write(f) }
|
59
62
|
end
|
60
|
-
|
63
|
+
|
64
|
+
|
65
|
+
# merge all tracks in the midi song, this will create a one polyphonic track
|
66
|
+
# some editors see different tracks as different instruments (logic)
|
67
|
+
# if so, after merging: all notes/tracks will belong to one instrument
|
68
|
+
def mergeTracks
|
69
|
+
masterTrack = MIDI::Track.new(@song) # create master final track
|
70
|
+
@song.tracks.each do |track| # for each track in the current song
|
71
|
+
masterTrack.merge(track.events) # merge it with the master track
|
72
|
+
end
|
73
|
+
@song.tracks = [masterTrack] # replace all tracks with the one master
|
74
|
+
end
|
75
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
# Parser (use as class) of the rhythm strings, consisting event and silence symbols
|
3
3
|
class RhythmParser
|
4
|
-
@@silenceNote =
|
4
|
+
@@silenceNote = 0 # pitch of a note played during initial silence in a sequence
|
5
5
|
@@silenceMark = '-' # symbol identified as a silence
|
6
6
|
@@eventMark = '#' # symbol identified as an event
|
7
7
|
@@eventNote = 50 # (unused default) midi note of an event
|
data/lib/rhythmruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhythmruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: midilib
|
@@ -70,9 +70,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
|
-
rubygems_version: 1.8.
|
73
|
+
rubygems_version: 1.8.23
|
74
74
|
signing_key:
|
75
75
|
specification_version: 3
|
76
76
|
summary: represent rhythms as symbolic Strings and write them to MIDI
|
77
77
|
test_files: []
|
78
|
-
has_rdoc:
|