class AudioStream::Rate
Constants
- SYNC_1
- SYNC_16
- SYNC_1_128
- SYNC_1_128D
- SYNC_1_128T
- SYNC_1_16
- SYNC_1_16D
- SYNC_1_16T
- SYNC_1_2
- SYNC_1_32
- SYNC_1_32D
- SYNC_1_32T
- SYNC_1_4
- SYNC_1_4D
- SYNC_1_4T
- SYNC_1_64
- SYNC_1_64D
- SYNC_1_64T
- SYNC_1_8
- SYNC_1_8D
- SYNC_1_8T
- SYNC_2
- SYNC_3
- SYNC_32
- SYNC_3_4
- SYNC_4
- SYNC_5_4
- SYNC_6
- SYNC_64
- SYNC_6_4
- SYNC_7_4
- SYNC_8
Public Class Methods
freq(v)
click to toggle source
# File lib/audio_stream/rate.rb, line 82 def self.freq(v) new(freq: v) end
msec(v)
click to toggle source
# File lib/audio_stream/rate.rb, line 74 def self.msec(v) new(sec: v*0.001) end
new(sec: nil, sample: nil, freq: nil, sync: nil)
click to toggle source
# File lib/audio_stream/rate.rb, line 3 def initialize(sec: nil, sample: nil, freq: nil, sync: nil) @sec = sec @sample = sample @freq = freq @sync = sync end
sample(v)
click to toggle source
# File lib/audio_stream/rate.rb, line 78 def self.sample(v) new(sample: v) end
sec(v)
click to toggle source
# File lib/audio_stream/rate.rb, line 70 def self.sec(v) new(sec: v) end
sync(v)
click to toggle source
# File lib/audio_stream/rate.rb, line 86 def self.sync(v) new(sync: v) end
Public Instance Methods
*(other)
click to toggle source
# File lib/audio_stream/rate.rb, line 50 def *(other) other = other.to_f if @sample return self.class.new(sample: @sample * other) end if @sec return self.class.new(sec: @sec * other) end if @freq return self.class.new(freq: @freq / other) end if @sync return self.class.new(sync: @sync * other) end end
frame(soundinfo)
click to toggle source
# File lib/audio_stream/rate.rb, line 15 def frame(soundinfo) sample(soundinfo).to_f / soundinfo.window_size end
frame_phase(soundinfo)
click to toggle source
# File lib/audio_stream/rate.rb, line 42 def frame_phase(soundinfo) sample_phase(soundinfo) * soundinfo.window_size end
freq(soundinfo)
click to toggle source
# File lib/audio_stream/rate.rb, line 37 def freq(soundinfo) return @freq if @freq soundinfo.samplerate.to_f / sample(soundinfo) end
sample(soundinfo)
click to toggle source
# File lib/audio_stream/rate.rb, line 19 def sample(soundinfo) if @sample return @sample end if @sec return @sec.to_f * soundinfo.samplerate end if @freq return soundinfo.samplerate.to_f / @freq end if @sync return @sync / 480.0 * soundinfo.sync_rate end end
sample_phase(soundinfo)
click to toggle source
# File lib/audio_stream/rate.rb, line 46 def sample_phase(soundinfo) 2.0 * Math::PI / sample(soundinfo) end
sec(soundinfo)
click to toggle source
# File lib/audio_stream/rate.rb, line 10 def sec(soundinfo) return @sec if @sec sample(soundinfo).to_f / soundinfo.samplerate end