Module: MIDICommunicationsWindows::TypeConversion

Extended by:
TypeConversion
Included in:
TypeConversion
Defined in:
lib/midi-communications-windows/type_conversion.rb

Overview

Utility methods for converting between MIDI data formats.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.numeric_bytes_to_hex_string(bytes) ⇒ String

Converts an array of numeric bytes to a hex string.

Examples:

TypeConversion.numeric_bytes_to_hex_string([0x90, 0x40, 0x40])
# => "904040"

Parameters:

  • bytes (Array<Integer>) —

    numeric bytes, e.g. [0x90, 0x40, 0x40]

Returns:

  • (String) —

    uppercase hex, two characters per byte, e.g. '904040'



16
17
18
# File 'lib/midi-communications-windows/type_conversion.rb', line 16

def numeric_bytes_to_hex_string(bytes)
  bytes.map { |byte| format('%02X', byte) }.join
end

Instance Method Details

#numeric_bytes_to_hex_string(bytes) ⇒ String

Converts an array of numeric bytes to a hex string.

Examples:

TypeConversion.numeric_bytes_to_hex_string([0x90, 0x40, 0x40])
# => "904040"

Parameters:

  • bytes (Array<Integer>) —

    numeric bytes, e.g. [0x90, 0x40, 0x40]

Returns:

  • (String) —

    uppercase hex, two characters per byte, e.g. '904040'



16
17
18
# File 'lib/midi-communications-windows/type_conversion.rb', line 16

def numeric_bytes_to_hex_string(bytes)
  bytes.map { |byte| format('%02X', byte) }.join
end