class SMF::Sequence::EncodeXML

Public Instance Methods

allnotesoff(ch) click to toggle source
# File lib/smf/toy/xml.rb, line 242
def allnotesoff(ch) channelmodemessage('AllNotesOff', ch) end
allsoundoff(ch) click to toggle source
# File lib/smf/toy/xml.rb, line 239
def allsoundoff(ch) channelmodemessage('AllSoundOff', ch) end
channelprefix(ch) click to toggle source
# File lib/smf/toy/xml.rb, line 293
def channelprefix(ch)
  e = REXML::Element.new('ChannelPrefix', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['ch'] = ch.to_s
end
channelpressure(ch, val) click to toggle source
# File lib/smf/toy/xml.rb, line 216
def channelpressure(ch, val)
  e = REXML::Element.new('ChannelPressure', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['ch'] = ch.to_s
  e.attributes['val'] = val.to_s
end
controlchange(ch, num, val) click to toggle source
# File lib/smf/toy/xml.rb, line 201
def controlchange(ch, num, val)
  e = REXML::Element.new('ControlChange', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['ch'] = ch.to_s
  e.attributes['num'] = num.to_s
  e.attributes['val'] = val.to_s
end
copyrightnotice(text) click to toggle source
# File lib/smf/toy/xml.rb, line 278
def copyrightnotice(text) text('CopyrightNotice', text) end
cuepoint(text) click to toggle source
# File lib/smf/toy/xml.rb, line 283
def cuepoint(text) text('CuePoint', text) end
delta(delta) click to toggle source
# File lib/smf/toy/xml.rb, line 175
def delta(delta) @offset += delta end
devicename(text) click to toggle source
# File lib/smf/toy/xml.rb, line 285
def devicename(text) text('DeviceName', text) end
endoftrack() click to toggle source
# File lib/smf/toy/xml.rb, line 305
def endoftrack
  e = REXML::Element.new('EndOfTrack', @doctr)
  e.attributes['offset'] = @offset.to_s
end
exclusivef0(data) click to toggle source
# File lib/smf/toy/xml.rb, line 260
def exclusivef0(data) put_binary('ExclusiveF0', data) end
exclusivef7(data) click to toggle source
# File lib/smf/toy/xml.rb, line 261
def exclusivef7(data) put_binary('ExclusiveF7', data) end
generalpurposetext(text) click to toggle source
# File lib/smf/toy/xml.rb, line 277
def generalpurposetext(text) text('GeneralPurposeText', text) end
header(format, ntrks, division, tc) click to toggle source
# File lib/smf/toy/xml.rb, line 161
def header(format, ntrks, division, tc)
  @doc = REXML::Document.new
  @doc << REXML::XMLDecl.new
  @docsq = REXML::Element.new('MThd', @doc)
  @docsq.attributes['format'] = format.to_s
  @docsq.attributes['division'] = division.to_s
  @docsq.attributes['tc'] = tc.to_s
end
instrumentname(text) click to toggle source
# File lib/smf/toy/xml.rb, line 280
def instrumentname(text) text('InstrumentName', text) end
keysignature(sf, mi) click to toggle source
# File lib/smf/toy/xml.rb, line 336
def keysignature(sf, mi)
  e = REXML::Element.new('KeySignature', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['sf'] = sf.to_s
  e.attributes['mi'] = mi.to_s
end
localcontrol(ch, val) click to toggle source
# File lib/smf/toy/xml.rb, line 241
def localcontrol(ch, val) channelmodemessage('LocalControl', ch, val) end
lyric(text) click to toggle source
# File lib/smf/toy/xml.rb, line 281
def lyric(text) text('Lyric', text) end
marker(text) click to toggle source
# File lib/smf/toy/xml.rb, line 282
def marker(text) text('Marker', text) end
midiport(num) click to toggle source
# File lib/smf/toy/xml.rb, line 299
def midiport(num)
  e = REXML::Element.new('MIDIPort', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['num'] = num.to_s
end
monomode(ch, val) click to toggle source
# File lib/smf/toy/xml.rb, line 245
def monomode(ch, val) channelmodemessage('MonoMode', ch, val) end
noteoff(ch, note, vel) click to toggle source
# File lib/smf/toy/xml.rb, line 177
def noteoff(ch, note, vel)
  e = REXML::Element.new('NoteOff', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['ch'] = ch.to_s
  e.attributes['note'] = note.to_s
  e.attributes['vel'] = vel.to_s
end
noteon(ch, note, vel) click to toggle source
# File lib/smf/toy/xml.rb, line 185
def noteon(ch, note, vel)
  e = REXML::Element.new('NoteOn', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['ch'] = ch.to_s
  e.attributes['note'] = note.to_s
  e.attributes['vel'] = vel.to_s
end
omnioff(ch) click to toggle source
# File lib/smf/toy/xml.rb, line 243
def omnioff(ch) channelmodemessage('OmniOff', ch) end
omnion(ch) click to toggle source
# File lib/smf/toy/xml.rb, line 244
def omnion(ch) channelmodemessage('OmniOn', ch) end
pitchbendchange(ch, val) click to toggle source
# File lib/smf/toy/xml.rb, line 223
def pitchbendchange(ch, val)
  e = REXML::Element.new('PitchBendChange', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['ch'] = ch.to_s
  e.attributes['val'] = val.to_s
end
polymode(ch) click to toggle source
# File lib/smf/toy/xml.rb, line 246
def polymode(ch) channelmodemessage('PolyMode', ch) end
polyphonickeypressure(ch, note, val) click to toggle source
# File lib/smf/toy/xml.rb, line 193
def polyphonickeypressure(ch, note, val)
  e = REXML::Element.new('PolyphonicKeyPressure', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['ch'] = ch.to_s
  e.attributes['note'] = note.to_s
  e.attributes['val'] = val.to_s
end
programchange(ch, num) click to toggle source
# File lib/smf/toy/xml.rb, line 209
def programchange(ch, num)
  e = REXML::Element.new('ProgramChange', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['ch'] = ch.to_s
  e.attributes['num'] = num.to_s
end
programname(text) click to toggle source
# File lib/smf/toy/xml.rb, line 284
def programname(text) text('ProgramName', text) end
resetallcontrollers(ch) click to toggle source
# File lib/smf/toy/xml.rb, line 240
def resetallcontrollers(ch) channelmodemessage('ResetAllControllers', ch) end
result() click to toggle source
# File lib/smf/toy/xml.rb, line 347
def result() @doc.to_s(0) end
sequencenumber(num) click to toggle source
# File lib/smf/toy/xml.rb, line 263
def sequencenumber(num)
  e = REXML::Element.new('SequenceNumber', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['num'] = num.to_s
end
sequencerspecific(data) click to toggle source
# File lib/smf/toy/xml.rb, line 343
def sequencerspecific(data) put_binary('SequencerSpecific', data) end
settempo(tempo) click to toggle source
# File lib/smf/toy/xml.rb, line 310
def settempo(tempo)
  e = REXML::Element.new('SetTempo', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['tempo'] = tempo.to_s
end
smpteoffset(hr, mn, se, fr, ff, tc) click to toggle source
# File lib/smf/toy/xml.rb, line 316
def smpteoffset(hr, mn, se, fr, ff, tc)
  e = REXML::Element.new('SMPTEOffset', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['hr'] = hr.to_s
  e.attributes['mn'] = mn.to_s
  e.attributes['se'] = se.to_s
  e.attributes['fr'] = fr.to_s
  e.attributes['ff'] = ff.to_s
  e.attributes['tc'] = tc.to_s
end
text0a(text) click to toggle source
# File lib/smf/toy/xml.rb, line 286
def text0a(text) text('Text0A', text) end
text0b(text) click to toggle source
# File lib/smf/toy/xml.rb, line 287
def text0b(text) text('Text0B', text) end
text0c(text) click to toggle source
# File lib/smf/toy/xml.rb, line 288
def text0c(text) text('Text0C', text) end
text0d(text) click to toggle source
# File lib/smf/toy/xml.rb, line 289
def text0d(text) text('Text0D', text) end
text0e(text) click to toggle source
# File lib/smf/toy/xml.rb, line 290
def text0e(text) text('Text0E', text) end
text0f(text) click to toggle source
# File lib/smf/toy/xml.rb, line 291
def text0f(text) text('Text0F', text) end
timesignature(nn, dd, cc, bb) click to toggle source
# File lib/smf/toy/xml.rb, line 327
def timesignature(nn, dd, cc, bb)
  e = REXML::Element.new('TimeSignature', @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['nn'] = nn.to_s
  e.attributes['dd'] = dd.to_s
  e.attributes['cc'] = cc.to_s
  e.attributes['bb'] = bb.to_s
end
track_start() click to toggle source
# File lib/smf/toy/xml.rb, line 170
def track_start()
  @offset = 0
  @doctr = REXML::Element.new('MTrk', @docsq)
end
trackname(text) click to toggle source
# File lib/smf/toy/xml.rb, line 279
def trackname(text) text('TrackName', text) end

Private Instance Methods

channelmodemessage(name, ch, val=nil) click to toggle source
# File lib/smf/toy/xml.rb, line 230
def channelmodemessage(name, ch, val=nil)
  e = REXML::Element.new(name, @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['ch'] = ch.to_s
  e.attributes['val'] = val.to_s if val
end
put_binary(name, data) click to toggle source
# File lib/smf/toy/xml.rb, line 248
def put_binary(name, data)
  e = REXML::Element.new(name, @doctr)
  e.attributes['offset'] = @offset.to_s
  s = ''
  data.each_byte do |c|
    s << format('\\%03o', c)
  end
  e.attributes['data'] = s
end
text(name, text) click to toggle source
# File lib/smf/toy/xml.rb, line 269
def text(name, text)
  e = REXML::Element.new(name, @doctr)
  e.attributes['offset'] = @offset.to_s
  e.attributes['text'] = text.dump[1..-2]
end