Class: Vizcore::Audio::FixtureInput
- Defined in:
- lib/vizcore/audio/fixture_input.rb
Overview
Deterministic sample-frame input for tests and repeatable development checks.
Instance Attribute Summary
Attributes inherited from BaseInput
Instance Method Summary collapse
-
#initialize(frames:, sample_rate: 44_100, loop: true) ⇒ FixtureInput
constructor
A new instance of FixtureInput.
- #read(frame_size) ⇒ Array<Float>
- #reset ⇒ void
Methods inherited from BaseInput
Constructor Details
#initialize(frames:, sample_rate: 44_100, loop: true) ⇒ FixtureInput
Returns a new instance of FixtureInput.
12 13 14 15 16 17 |
# File 'lib/vizcore/audio/fixture_input.rb', line 12 def initialize(frames:, sample_rate: 44_100, loop: true) super(sample_rate: sample_rate) @frames = normalize_frames(frames) @loop = !!loop @index = 0 end |
Instance Method Details
#read(frame_size) ⇒ Array<Float>
21 22 23 24 25 26 27 28 29 |
# File 'lib/vizcore/audio/fixture_input.rb', line 21 def read(frame_size) count = Integer(frame_size) return Array.new(count, 0.0) unless running? frame = next_frame return Array.new(count, 0.0) unless frame normalize_frame_size(frame, count) end |
#reset ⇒ void
This method returns an undefined value.
32 33 34 |
# File 'lib/vizcore/audio/fixture_input.rb', line 32 def reset @index = 0 end |