Class: Musikov::MarkovRepository
- Inherits:
-
Object
- Object
- Musikov::MarkovRepository
- Defined in:
- lib/musikov/markov_builder.rb
Overview
This class holds the markov chains of each instrument built from the selected midi files.
Instance Attribute Summary collapse
-
#models_by_instrument ⇒ Object
Returns the value of attribute models_by_instrument.
Instance Method Summary collapse
-
#export(sequence_hash = {}, path = ".") ⇒ Object
Export the generated chains.
-
#import(paths = []) ⇒ Object
Call parser over indicated paths and trigger the markov chain building process.
-
#initialize ⇒ MarkovRepository
constructor
Initialize the map of markov chain by instrument.
Constructor Details
#initialize ⇒ MarkovRepository
Initialize the map of markov chain by instrument
15 16 17 |
# File 'lib/musikov/markov_builder.rb', line 15 def initialize @models_by_instrument = {} end |
Instance Attribute Details
#models_by_instrument ⇒ Object
Returns the value of attribute models_by_instrument.
12 13 14 |
# File 'lib/musikov/markov_builder.rb', line 12 def models_by_instrument @models_by_instrument end |
Instance Method Details
#export(sequence_hash = {}, path = ".") ⇒ Object
Export the generated chains
36 37 38 39 |
# File 'lib/musikov/markov_builder.rb', line 36 def export(sequence_hash = {}, path = ".") writer = MidiWriter.new(path) writer.write(sequence_hash) end |
#import(paths = []) ⇒ Object
Call parser over indicated paths and trigger the markov chain building process.
-
the paths can be either folders or files
-
the file indicated by the path must exist!
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/musikov/markov_builder.rb', line 23 def import(paths = []) parser = MidiParser.new(paths) sequencies = parser.parse builder = MarkovBuilder.new() sequencies.each { |sequency| builder.add(sequency) } @models_by_instrument = builder.build end |