Class: Fet::Generator::SingleNoteListening

Inherits:
Object
  • Object
show all
Defined in:
lib/fet/generator/single_note_listening.rb

Overview

Class that generates MIDI files for the single note listening exercises

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tempo:) ⇒ SingleNoteListening

Returns a new instance of SingleNoteListening.



7
8
9
10
11
12
# File 'lib/fet/generator/single_note_listening.rb', line 7

def initialize(tempo:)
  self.tempo = tempo
  self.note = Fet::Note.new("C")
  self.octave_value = 4
  self.midi_value = MidiNote.from_note(note.full_note, octave_value).midi_value
end

Class Method Details

.directory_prefixObject

NOTE: this is explicitly changed in tests, so no need to check for coverage :nocov:



16
17
18
# File 'lib/fet/generator/single_note_listening.rb', line 16

def self.directory_prefix
  return ""
end

Instance Method Details

#generateObject

:nocov:



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fet/generator/single_note_listening.rb', line 21

def generate
  MusicTheory::MAJOR_KEYS.each do |root_note_name|
    root_midi_value = MAJOR_ROOT_MIDI_VALUES[root_note_name]
    create_midi_file("major", root_note_name, root_midi_value)
  end

  MusicTheory::MINOR_KEYS.each do |root_note_name|
    root_midi_value = MINOR_ROOT_MIDI_VALUES[root_note_name]
    create_midi_file("minor", root_note_name, root_midi_value)
  end
end