Class: RoadToRubykaigi::Audio::WavSource

Inherits:
Object
  • Object
show all
Includes:
WaveFile
Defined in:
lib/road_to_rubykaigi/audio/wav_source.rb

Instance Method Summary collapse

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/road_to_rubykaigi/audio/wav_source.rb', line 31

def finished?
  @position >= @buffer.size
end

#gainObject



12
13
14
# File 'lib/road_to_rubykaigi/audio/wav_source.rb', line 12

def gain
  0.3
end

#generateObject



16
17
18
19
20
21
22
23
24
# File 'lib/road_to_rubykaigi/audio/wav_source.rb', line 16

def generate
  if @position < @buffer.size
    sample = @buffer[@position]
    @position += 1
    sample
  else
    0.0
  end
end

#rewindObject



26
27
28
29
# File 'lib/road_to_rubykaigi/audio/wav_source.rb', line 26

def rewind
  @position = 0
  self
end

#sample_rateObject



8
9
10
# File 'lib/road_to_rubykaigi/audio/wav_source.rb', line 8

def sample_rate
  44_100
end