Module: FMOD::Convert

Defined in:
lib/fmod/convert.rb

Class Method Summary collapse

Class Method Details

.int32_to_64(hi32, lo32) ⇒ Object

since ruby will automatically convert to a Bignum if needed, this should work fine even on 32-bit platforms



6
7
8
# File 'lib/fmod/convert.rb', line 6

def self.int32_to_64(hi32, lo32)
  (hi32 << 32) | lo32
end

.int64_to_32(int64) ⇒ Object



10
11
12
# File 'lib/fmod/convert.rb', line 10

def self.int64_to_32(int64)
  [(int64 & 0xFFFFFFFF00000000) >> 32, int64 & 0xFFFFFFFF]
end

.ms_to_samples(ms, opts = {}) ⇒ Object



14
15
16
17
# File 'lib/fmod/convert.rb', line 14

def self.ms_to_samples(ms, opts={})
  opts = opts.keyword_args(:sample_rate => FMOD.system.sample_rate) # samples per second
  ms * opts.sample_rate / 1000
end

.samples_to_ms(samples, opts = {}) ⇒ Object



19
20
21
22
# File 'lib/fmod/convert.rb', line 19

def self.samples_to_ms(samples, opts={})
  opts = opts.keyword_args(:sample_rate => FMOD.system.sample_rate) # samples per second
  (samples / opts.sample_rate) * 1000
end