Class: Vizcore::Analysis::FeatureReplay
- Inherits:
-
Object
- Object
- Vizcore::Analysis::FeatureReplay
- Defined in:
- lib/vizcore/analysis/feature_replay.rb
Overview
Replays recorded analysis features as a pipeline-compatible source.
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#call(_samples = nil) ⇒ Hash<Symbol, Object>
Recorded audio analysis for the next frame.
- #frame_count ⇒ Object
-
#initialize(path:) ⇒ FeatureReplay
constructor
A new instance of FeatureReplay.
Constructor Details
#initialize(path:) ⇒ FeatureReplay
Returns a new instance of FeatureReplay.
13 14 15 16 17 18 19 |
# File 'lib/vizcore/analysis/feature_replay.rb', line 13 def initialize(path:) @path = Pathname.new(path.to_s). payload = load_payload @metadata = deep_symbolize(payload.fetch("metadata", {})) @features = load_features(payload) @cursor = 0 end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/vizcore/analysis/feature_replay.rb', line 11 def @metadata end |
Instance Method Details
#call(_samples = nil) ⇒ Hash<Symbol, Object>
Returns recorded audio analysis for the next frame.
23 24 25 26 27 |
# File 'lib/vizcore/analysis/feature_replay.rb', line 23 def call(_samples = nil) audio = @features.fetch(@cursor) @cursor = (@cursor + 1) % @features.length deep_dup(audio) end |
#frame_count ⇒ Object
29 30 31 |
# File 'lib/vizcore/analysis/feature_replay.rb', line 29 def frame_count @features.length end |