class SMF::Sequence::Encode
Public Instance Methods
allnotesoff(ch)
click to toggle source
# File lib/smf/io.rb, line 1068 def allnotesoff(ch) channelmodemessage(ch, 0x7b, 0) end
allsoundoff(ch)
click to toggle source
# File lib/smf/io.rb, line 1065 def allsoundoff(ch) channelmodemessage(ch, 0x78, 0) end
channelprefix(ch)
click to toggle source
# File lib/smf/io.rb, line 1122 def channelprefix(ch) de @ev.putc(0xff) @ev.putc(0x20) @ev.putl(1) @ev.putc(ch) end
channelpressure(ch, val)
click to toggle source
# File lib/smf/io.rb, line 1040 def channelpressure(ch, val) de sb(ch | 0xd0) db(val) end
controlchange(ch, num, val)
click to toggle source
# File lib/smf/io.rb, line 1027 def controlchange(ch, num, val) de sb(ch | 0xb0) db(num) db(val) end
copyrightnotice(text)
click to toggle source
# File lib/smf/io.rb, line 1107 def copyrightnotice(text) text(0x2, text) end
cuepoint(text)
click to toggle source
# File lib/smf/io.rb, line 1112 def cuepoint(text) text(0x7, text) end
delta(delta)
click to toggle source
# File lib/smf/io.rb, line 998 def delta(delta) @delta = delta end
devicename(text)
click to toggle source
# File lib/smf/io.rb, line 1114 def devicename(text) text(0x9, text) end
endoftrack()
click to toggle source
# File lib/smf/io.rb, line 1138 def endoftrack de @ev.putc(0xff) @ev.putc(0x2f) @ev.putl(0) @cieot = true end
error(mesg)
click to toggle source
# File lib/smf/io.rb, line 1209 def error(mesg) raise ReadError, mesg end
exclusivef0(data)
click to toggle source
# File lib/smf/io.rb, line 1074 def exclusivef0(data) de @ev.putc(0xf0) @ev.putl(data.length) @ev.puts(data) end
exclusivef7(data)
click to toggle source
# File lib/smf/io.rb, line 1081 def exclusivef7(data) de @ev.putc(0xf7) @ev.putl(data.length) @ev.puts(data) end
generalpurposetext(text)
click to toggle source
# File lib/smf/io.rb, line 1106 def generalpurposetext(text) text(0x1, text) end
header(format, ntrks, division, tc)
click to toggle source
# File lib/smf/io.rb, line 934 def header(format, ntrks, division, tc) @ws = WS::PO.new @ws.puts('MThd') @ws.puti32(6) @ws.puti16(format) @ws.puti16(ntrks) if tc div1 = 0x100 - tc div2 = division else div1 = division >> 8 div2 = division & 0xff end @ws.putc(div1) @ws.putc(div2) end
instrumentname(text)
click to toggle source
# File lib/smf/io.rb, line 1109 def instrumentname(text) text(0x4, text) end
keysignature(sf, mi)
click to toggle source
# File lib/smf/io.rb, line 1181 def keysignature(sf, mi) sf = WS::PO.s2u(sf, 8) de @ev.putc(0xff) @ev.putc(0x59) @ev.putl(2) @ev.putc(sf) @ev.putc(mi) end
localcontrol(ch, val)
click to toggle source
# File lib/smf/io.rb, line 1067 def localcontrol(ch, val) channelmodemessage(ch, 0x7a, val) end
lyric(text)
click to toggle source
# File lib/smf/io.rb, line 1110 def lyric(text) text(0x5, text) end
marker(text)
click to toggle source
# File lib/smf/io.rb, line 1111 def marker(text) text(0x6, text) end
midiport(num)
click to toggle source
# File lib/smf/io.rb, line 1130 def midiport(num) de @ev.putc(0xff) @ev.putc(0x21) @ev.putl(1) @ev.putc(num) end
monomode(ch, val)
click to toggle source
# File lib/smf/io.rb, line 1071 def monomode(ch, val) channelmodemessage(ch, 0x7e, val) end
noteoff(ch, note, vel)
click to toggle source
# File lib/smf/io.rb, line 1000 def noteoff(ch, note, vel) de if @@replace_noteoff sb(ch | 0x90) db(note) db(0) else sb(ch | 0x80) db(note) db(vel) end end
noteon(ch, note, vel)
click to toggle source
# File lib/smf/io.rb, line 1013 def noteon(ch, note, vel) de sb(ch | 0x90) db(note) db(vel) end
omnioff(ch)
click to toggle source
# File lib/smf/io.rb, line 1069 def omnioff(ch) channelmodemessage(ch, 0x7c, 0) end
omnion(ch)
click to toggle source
# File lib/smf/io.rb, line 1070 def omnion(ch) channelmodemessage(ch, 0x7d, 0) end
pitchbendchange(ch, val)
click to toggle source
# File lib/smf/io.rb, line 1046 def pitchbendchange(ch, val) de sb(ch | 0xe0) val += 0x2000 lsb = val & 0x7f msb = (val >> 7) & 0x7f db(lsb) db(msb) end
polymode(ch)
click to toggle source
# File lib/smf/io.rb, line 1072 def polymode(ch) channelmodemessage(ch, 0x7f, 0) end
polyphonickeypressure(ch, note, val)
click to toggle source
# File lib/smf/io.rb, line 1020 def polyphonickeypressure(ch, note, val) de sb(ch | 0xa0) db(note) db(val) end
programchange(ch, num)
click to toggle source
# File lib/smf/io.rb, line 1034 def programchange(ch, num) de sb(ch | 0xc0) db(num) end
programname(text)
click to toggle source
# File lib/smf/io.rb, line 1113 def programname(text) text(0x8, text) end
resetallcontrollers(ch)
click to toggle source
# File lib/smf/io.rb, line 1066 def resetallcontrollers(ch) channelmodemessage(ch, 0x79, 0) end
result()
click to toggle source
# File lib/smf/io.rb, line 1207 def result() @ws.to_s end
sequencenumber(num)
click to toggle source
# File lib/smf/io.rb, line 1088 def sequencenumber(num) de @ev.putc(0xff) @ev.putc(0x0) @ev.putl(2) @ev.puti16(num) end
sequencerspecific(data)
click to toggle source
# File lib/smf/io.rb, line 1191 def sequencerspecific(data) de @ev.putc(0xff) @ev.putc(0x7f) @ev.putl(data.length) @ev.puts(data) end
settempo(tempo)
click to toggle source
# File lib/smf/io.rb, line 1146 def settempo(tempo) de @ev.putc(0xff) @ev.putc(0x51) @ev.putl(3) @ev.puti24(tempo) end
smpteoffset(hr, mn, se, fr, ff, tc)
click to toggle source
# File lib/smf/io.rb, line 1154 def smpteoffset(hr, mn, se, fr, ff, tc) unless [24, 25, 29, 30].include? tc warn('smpteoffset/tc: invalid format') end de @ev.putc(0xff) @ev.putc(0x54) @ev.putl(5) hr |= ({24=>0, 25=>1, 29=>2, 30=>3}[tc] || 0) << 5 @ev.putc(hr) @ev.putc(mn) @ev.putc(se) @ev.putc(fr) @ev.putc(ff) end
text0a(text)
click to toggle source
# File lib/smf/io.rb, line 1115 def text0a(text) text(0xa, text) end
text0b(text)
click to toggle source
# File lib/smf/io.rb, line 1116 def text0b(text) text(0xb, text) end
text0c(text)
click to toggle source
# File lib/smf/io.rb, line 1117 def text0c(text) text(0xc, text) end
text0d(text)
click to toggle source
# File lib/smf/io.rb, line 1118 def text0d(text) text(0xd, text) end
text0e(text)
click to toggle source
# File lib/smf/io.rb, line 1119 def text0e(text) text(0xe, text) end
text0f(text)
click to toggle source
# File lib/smf/io.rb, line 1120 def text0f(text) text(0xf, text) end
timesignature(nn, dd, cc, bb)
click to toggle source
# File lib/smf/io.rb, line 1170 def timesignature(nn, dd, cc, bb) de @ev.putc(0xff) @ev.putc(0x58) @ev.putl(4) @ev.putc(nn) @ev.putc(dd) @ev.putc(cc) @ev.putc(bb) end
track_end()
click to toggle source
# File lib/smf/io.rb, line 961 def track_end @ws.puts('MTrk') unless @cieot delta(0) endoftrack end ev = @ev.to_s chunk_body(ev) @ws.puti32(ev.length) @ws.puts(ev) end
track_start()
click to toggle source
# File lib/smf/io.rb, line 951 def track_start @ev = WS::PO.new @running = 0 @cieot = false end
trackname(text)
click to toggle source
# File lib/smf/io.rb, line 1108 def trackname(text) text(0x3, text) end
unknownchunk(ckid, body)
click to toggle source
# File lib/smf/io.rb, line 973 def unknownchunk(ckid, body) @ws.puts(ckid) chunk_body(ev) @ws.puti32(body.length) @ws.puts(body) end
unknownmeta(type, data)
click to toggle source
# File lib/smf/io.rb, line 1199 def unknownmeta(type, data) de @ev.putc(0xff) @ev.putc(type) @ev.putl(data.length) @ev.puts(data) end
Private Instance Methods
channelmodemessage(ch, num, val)
click to toggle source
# File lib/smf/io.rb, line 1056 def channelmodemessage(ch, num, val) de sb(ch | 0xb0) db(num) db(val) end
chunk_body(body)
click to toggle source
# File lib/smf/io.rb, line 957 def chunk_body(body) end
db(data)
click to toggle source
# File lib/smf/io.rb, line 992 def db(data) @ev.putc(data & 0x7f) end
de()
click to toggle source
# File lib/smf/io.rb, line 980 def de @ev.putl(@delta) end
sb(stat)
click to toggle source
# File lib/smf/io.rb, line 984 def sb(stat) @ev.putc(stat) unless stat == @running case stat when 0x80..0xef; @running = stat when 0xf0..0xf7; @running = 0 end end
text(type, text)
click to toggle source
# File lib/smf/io.rb, line 1096 def text(type, text) de @ev.putc(0xff) @ev.putc(type) @ev.putl(text.length) @ev.puts(text) end