module MVLC::Helper::Numbers

Number conversion

Public Instance Methods

to_midi_value(num) click to toggle source

Converts a percentage to a 7-bit int value eg 50 -> 0x40 @param [Integer] num @return [Integer]

# File lib/mvlc/helper/numbers.rb, line 11
def to_midi_value(num)
  Scale.transform(num).from(0..100).to(0..127.0).round
end
to_percent(num) click to toggle source

Converts a MIDI 7-bit int value to a percentage eg 0x40 -> 50 @param [Integer] num @return [Integer]

# File lib/mvlc/helper/numbers.rb, line 18
def to_percent(num)
  Scale.transform(num).from(0..127).to(0..100.0).round
end