Class: Fet::MidilibInterface
- Inherits:
-
Object
- Object
- Fet::MidilibInterface
- Defined in:
- lib/fet/midilib_interface.rb
Overview
Interface with the midilib library to generate MIDI files
Instance Method Summary collapse
- #create_listening_midi_file ⇒ Object
- #create_singing_midi_file(sleep_duration) ⇒ Object
-
#initialize(tempo:, progression:, notes:, info:, filename:) ⇒ MidilibInterface
constructor
A new instance of MidilibInterface.
Constructor Details
#initialize(tempo:, progression:, notes:, info:, filename:) ⇒ MidilibInterface
Returns a new instance of MidilibInterface.
9 10 11 12 13 14 15 16 17 |
# File 'lib/fet/midilib_interface.rb', line 9 def initialize(tempo:, progression:, notes:, info:, filename:) self.tempo = tempo self.progression = progression self.notes = notes self.info = info self.filename = filename self.sequence = MIDI::Sequence.new self.track = generate_instrument_track end |
Instance Method Details
#create_listening_midi_file ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fet/midilib_interface.rb', line 19 def create_listening_midi_file # Play the chord progression set_progression_on_track add_rest(2 * quarter_note_length) play_notes_as_chord(notes, quarter_note_length) add_rest(6 * quarter_note_length) play_notes_sequentially(notes, quarter_note_length) write_sequence_to_file end |
#create_singing_midi_file(sleep_duration) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fet/midilib_interface.rb', line 32 def create_singing_midi_file(sleep_duration) # Play the chord progression set_progression_on_track # Play the note after waiting for a specified amount of time add_seconds_of_rest(sleep_duration) do play_notes_sequentially(notes, quarter_note_length) end write_sequence_to_file end |