Class: Clef::Midi::Exporter
- Inherits:
-
Object
- Object
- Clef::Midi::Exporter
- Includes:
- MIDI
- Defined in:
- lib/clef/midi/exporter.rb
Constant Summary collapse
- DEFAULT_VELOCITY =
90- DEFAULT_PROGRAM =
1
Instance Attribute Summary collapse
-
#channel_map ⇒ Object
readonly
Returns the value of attribute channel_map.
-
#instrument_map ⇒ Object
readonly
Returns the value of attribute instrument_map.
-
#plugins ⇒ Object
readonly
Returns the value of attribute plugins.
-
#ppqn ⇒ Object
readonly
Returns the value of attribute ppqn.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
- #export(target) ⇒ String, #write
-
#initialize(score, channel_map: ChannelMap.new, ppqn: 480, instrument_map: {}, plugins: score.plugins || Clef.plugins) ⇒ Exporter
constructor
A new instance of Exporter.
Constructor Details
#initialize(score, channel_map: ChannelMap.new, ppqn: 480, instrument_map: {}, plugins: score.plugins || Clef.plugins) ⇒ Exporter
Returns a new instance of Exporter.
21 22 23 24 25 26 27 28 29 |
# File 'lib/clef/midi/exporter.rb', line 21 def initialize(score, channel_map: ChannelMap.new, ppqn: 480, instrument_map: {}, plugins: score.plugins || Clef.plugins) raise ArgumentError, "ppqn must be a positive Integer" unless ppqn.is_a?(Integer) && ppqn.positive? @score = score @channel_map = channel_map @ppqn = ppqn @instrument_map = instrument_map @plugins = plugins end |
Instance Attribute Details
#channel_map ⇒ Object (readonly)
Returns the value of attribute channel_map.
14 15 16 |
# File 'lib/clef/midi/exporter.rb', line 14 def channel_map @channel_map end |
#instrument_map ⇒ Object (readonly)
Returns the value of attribute instrument_map.
14 15 16 |
# File 'lib/clef/midi/exporter.rb', line 14 def instrument_map @instrument_map end |
#plugins ⇒ Object (readonly)
Returns the value of attribute plugins.
14 15 16 |
# File 'lib/clef/midi/exporter.rb', line 14 def plugins @plugins end |
#ppqn ⇒ Object (readonly)
Returns the value of attribute ppqn.
14 15 16 |
# File 'lib/clef/midi/exporter.rb', line 14 def ppqn @ppqn end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
14 15 16 |
# File 'lib/clef/midi/exporter.rb', line 14 def score @score end |
Instance Method Details
#export(target) ⇒ String, #write
33 34 35 36 37 38 |
# File 'lib/clef/midi/exporter.rb', line 33 def export(target) plugins.run_hook(:on_before_midi, self) sequence = build_sequence write_sequence(sequence, target) target end |