Module: CoreMIDI::TypeConversion

Extended by:
TypeConversion
Included in:
TypeConversion
Defined in:
lib/coremidi/type_conversion.rb

Overview

Helper for convertig MIDI data

Instance Method Summary collapse

Instance Method Details

#numeric_bytes_to_hex_string(bytes) ⇒ String

Convert an array of numeric byes to a hex string (e.g. [0x90, 0x40, 0x40] becomes “904040”)



11
12
13
14
15
16
17
18
# File 'lib/coremidi/type_conversion.rb', line 11

def numeric_bytes_to_hex_string(bytes)
  string_bytes = bytes.map do |byte| 
    str = byte.to_s(16).upcase
    str = "0" + str if byte < 16
    str
  end
  string_bytes.join
end