midilib 2.0.5 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/ChangeLog +2 -1
- data/Credits +39 -2
- data/README.rdoc +5 -6
- data/Rakefile +36 -49
- data/TODO.rdoc +13 -2
- data/examples/from_scratch.rb +1 -1
- data/examples/measures_mbt.rb +11 -11
- data/examples/print_program_changes.rb +2 -2
- data/examples/reader2text.rb +47 -47
- data/examples/seq2text.rb +1 -1
- data/examples/split.rb +4 -3
- data/examples/strings.rb +4 -4
- data/examples/transpose.rb +19 -20
- data/install.rb +21 -13
- data/lib/midilib/consts.rb +237 -239
- data/lib/midilib/event.rb +128 -100
- data/lib/midilib/info.rb +3 -5
- data/lib/midilib/io/midifile.rb +155 -182
- data/lib/midilib/io/seqreader.rb +80 -85
- data/lib/midilib/io/seqwriter.rb +93 -88
- data/lib/midilib/measure.rb +78 -80
- data/lib/midilib/mergesort.rb +39 -0
- data/lib/midilib/sequence.rb +40 -32
- data/lib/midilib/track.rb +16 -57
- data/lib/midilib/utils.rb +4 -7
- data/lib/midilib.rb +5 -5
- data/test/event_equality.rb +28 -30
- data/test/test_event.rb +9 -11
- data/test/test_io.rb +83 -3
- data/test/test_mergesort.rb +37 -0
- data/test/test_midifile.rb +6 -19
- data/test/test_sequence.rb +5 -4
- data/test/test_track.rb +9 -38
- data/test/test_varlen.rb +1 -3
- metadata +8 -95
- data/html/IO.html +0 -155
- data/html/MIDI/ActiveSense.html +0 -206
- data/html/MIDI/ChannelEvent.html +0 -231
- data/html/MIDI/ChannelPressure.html +0 -265
- data/html/MIDI/Clock.html +0 -206
- data/html/MIDI/Continue.html +0 -206
- data/html/MIDI/Controller.html +0 -280
- data/html/MIDI/Event.html +0 -489
- data/html/MIDI/IO/MIDIFile.html +0 -2024
- data/html/MIDI/IO/SeqReader.html +0 -904
- data/html/MIDI/IO/SeqWriter.html +0 -572
- data/html/MIDI/IO.html +0 -95
- data/html/MIDI/KeySig.html +0 -353
- data/html/MIDI/MIDI/MIDI/Array.html +0 -255
- data/html/MIDI/MIDI/MIDI.html +0 -95
- data/html/MIDI/MIDI.html +0 -95
- data/html/MIDI/Marker.html +0 -158
- data/html/MIDI/Measure.html +0 -328
- data/html/MIDI/Measures.html +0 -285
- data/html/MIDI/MetaEvent.html +0 -461
- data/html/MIDI/NoteEvent.html +0 -331
- data/html/MIDI/NoteOff.html +0 -228
- data/html/MIDI/NoteOn.html +0 -228
- data/html/MIDI/PitchBend.html +0 -266
- data/html/MIDI/PolyPressure.html +0 -277
- data/html/MIDI/ProgramChange.html +0 -265
- data/html/MIDI/Realtime.html +0 -242
- data/html/MIDI/Sequence.html +0 -896
- data/html/MIDI/SongPointer.html +0 -266
- data/html/MIDI/SongSelect.html +0 -265
- data/html/MIDI/Start.html +0 -206
- data/html/MIDI/Stop.html +0 -206
- data/html/MIDI/SystemCommon.html +0 -158
- data/html/MIDI/SystemExclusive.html +0 -268
- data/html/MIDI/SystemReset.html +0 -206
- data/html/MIDI/Tempo.html +0 -396
- data/html/MIDI/TimeSig.html +0 -388
- data/html/MIDI/Track.html +0 -695
- data/html/MIDI/TuneRequest.html +0 -242
- data/html/MIDI/Utils.html +0 -220
- data/html/MIDI.html +0 -547
- data/html/README_rdoc.html +0 -731
- data/html/TODO_rdoc.html +0 -125
- data/html/created.rid +0 -14
- data/html/css/fonts.css +0 -167
- data/html/css/rdoc.css +0 -590
- data/html/fonts/Lato-Light.ttf +0 -0
- data/html/fonts/Lato-LightItalic.ttf +0 -0
- data/html/fonts/Lato-Regular.ttf +0 -0
- data/html/fonts/Lato-RegularItalic.ttf +0 -0
- data/html/fonts/SourceCodePro-Bold.ttf +0 -0
- data/html/fonts/SourceCodePro-Regular.ttf +0 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +0 -768
- data/html/js/darkfish.js +0 -161
- data/html/js/jquery.js +0 -4
- data/html/js/navigation.js +0 -142
- data/html/js/navigation.js.gz +0 -0
- data/html/js/search.js +0 -109
- data/html/js/search_index.js +0 -1
- data/html/js/search_index.js.gz +0 -0
- data/html/js/searcher.js +0 -228
- data/html/js/searcher.js.gz +0 -0
- data/html/table_of_contents.html +0 -1265
data/examples/transpose.rb
CHANGED
@@ -17,15 +17,14 @@ require 'midilib/sequence'
|
|
17
17
|
require 'midilib/io/seqreader'
|
18
18
|
require 'midilib/io/seqwriter'
|
19
19
|
|
20
|
-
|
21
20
|
def usage
|
22
|
-
$stderr.print
|
23
|
-
usage: #{$0} [--channel|-c channel] [--transpose|-t half_steps]
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
EOF
|
21
|
+
$stderr.print <<~EOF
|
22
|
+
usage: #{$0} [--channel|-c channel] [--transpose|-t half_steps]
|
23
|
+
input_midi_file output_midi_file
|
24
|
+
#{' '}
|
25
|
+
--channel|-c channel 1-16; default is 1
|
26
|
+
--transpose|-t half_steps default = 12 (one octave up)
|
27
|
+
EOF
|
29
28
|
exit(1)
|
30
29
|
end
|
31
30
|
|
@@ -33,7 +32,7 @@ transpose = 12
|
|
33
32
|
channel = 0
|
34
33
|
|
35
34
|
g = GetoptLong.new(['--transpose', '-t', GetoptLong::REQUIRED_ARGUMENT],
|
36
|
-
|
35
|
+
['--channel', '-c', GetoptLong::REQUIRED_ARGUMENT])
|
37
36
|
g.each do |name, arg|
|
38
37
|
case name
|
39
38
|
when '--transpose'
|
@@ -41,13 +40,13 @@ g.each do |name, arg|
|
|
41
40
|
when '--channel'
|
42
41
|
channel = arg.to_i - 1
|
43
42
|
else
|
44
|
-
usage
|
43
|
+
usage
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
|
-
usage
|
47
|
+
usage unless ARGV.length >= 2
|
49
48
|
|
50
|
-
seq = MIDI::Sequence.new
|
49
|
+
seq = MIDI::Sequence.new
|
51
50
|
File.open(ARGV[0], 'rb') do |file|
|
52
51
|
# The block we pass in to Sequence.read is called at the end of every
|
53
52
|
# track read. It is optional, but is useful for progress reports.
|
@@ -58,13 +57,13 @@ end
|
|
58
57
|
|
59
58
|
seq.each do |track|
|
60
59
|
track.each do |event|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
next unless event.is_a?(MIDI::NoteEvent) && event.channel == channel
|
61
|
+
|
62
|
+
val = event.note + transpose
|
63
|
+
if val < 0 || val > 127
|
64
|
+
warn 'transposition out of range; ignored'
|
65
|
+
else
|
66
|
+
event.note = val
|
68
67
|
end
|
69
68
|
end
|
70
69
|
end
|
@@ -72,4 +71,4 @@ end
|
|
72
71
|
# Output to named file or stdout.
|
73
72
|
file = ARGV[1] ? File.open(ARGV[1], 'wb') : $stdout
|
74
73
|
seq.write(file)
|
75
|
-
file.close
|
74
|
+
file.close if ARGV[1]
|
data/install.rb
CHANGED
@@ -13,13 +13,21 @@ require 'getoptlong'
|
|
13
13
|
require 'find'
|
14
14
|
begin
|
15
15
|
require 'ftools'
|
16
|
-
def mkdirs(dir)
|
17
|
-
|
16
|
+
def mkdirs(dir)
|
17
|
+
File.makedirs(dir)
|
18
|
+
end
|
19
|
+
|
20
|
+
def install(*args)
|
21
|
+
File.install(*args)
|
22
|
+
end
|
18
23
|
rescue LoadError
|
19
24
|
require 'fileutils'
|
20
|
-
def mkdirs(dir)
|
25
|
+
def mkdirs(dir)
|
26
|
+
FileUtils.mkdir_p(dir)
|
27
|
+
end
|
28
|
+
|
21
29
|
def install(*args)
|
22
|
-
args[2] = {mode: args[2], verbose: args[3]}
|
30
|
+
args[2] = { mode: args[2], verbose: args[3] }
|
23
31
|
args.pop
|
24
32
|
FileUtils.install(*args)
|
25
33
|
end
|
@@ -35,15 +43,15 @@ def instdir
|
|
35
43
|
if name == '--install-dir'
|
36
44
|
return arg
|
37
45
|
else
|
38
|
-
|
46
|
+
warn 'usage: $0 [--install-dir dir]'
|
39
47
|
end
|
40
48
|
end
|
41
49
|
|
42
50
|
begin
|
43
51
|
require 'rbconfig'
|
44
|
-
libdir = Config::CONFIG['sitedir'] +
|
45
|
-
|
46
|
-
|
52
|
+
libdir = Config::CONFIG['sitedir'] + '/' +
|
53
|
+
Config::CONFIG['MAJOR'] + '.' +
|
54
|
+
Config::CONFIG['MINOR']
|
47
55
|
rescue ScriptError
|
48
56
|
$LOAD_PATH.each do |l|
|
49
57
|
if l =~ /site_ruby/ && l =~ /\d$/ && l !~ /#{PLATFORM}/
|
@@ -51,18 +59,18 @@ def instdir
|
|
51
59
|
break
|
52
60
|
end
|
53
61
|
end
|
54
|
-
|
55
|
-
|
62
|
+
warn "Can't find required file `rbconfig.rb'."
|
63
|
+
warn "The `midilib' files need to be installed manually in #{libdir}"
|
56
64
|
end
|
57
|
-
|
65
|
+
libdir
|
58
66
|
end
|
59
67
|
|
60
|
-
INSTALL_DIR = instdir
|
68
|
+
INSTALL_DIR = instdir
|
61
69
|
files = Dir.chdir('lib') { Dir['**/*.rb'] }
|
62
70
|
|
63
71
|
files.each do |f|
|
64
72
|
dir = File.dirname(f)
|
65
73
|
target_dir = File.join(INSTALL_DIR, dir)
|
66
74
|
mkdirs(target_dir) unless File.exist?(target_dir)
|
67
|
-
install(File.join('lib', f), File.join(INSTALL_DIR, f),
|
75
|
+
install(File.join('lib', f), File.join(INSTALL_DIR, f), 0o644, true)
|
68
76
|
end
|