Module: CoreMIDI::TypeConversion

Defined in:
lib/coremidi/type_conversion.rb

Overview

Helper for converting MIDI data

Class Method Summary collapse

Class 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”)

Parameters:

  • bytes (Array<Integer>)

Returns:

  • (String)


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