Class: MusicTheory::Play

Inherits:
Object
  • Object
show all
Includes:
Output
Defined in:
lib/music_theory/play.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Output

#buffer_format, #format, #output_track, #play, #sample_rate

Constructor Details

#initialize(playable_music = [], options = {}) ⇒ Play

Returns a new instance of Play.



8
9
10
11
12
13
14
# File 'lib/music_theory/play.rb', line 8

def initialize(playable_music = [], options = {} )
  @playable_music    = playable_music
  @output_file_name  = options[:output_file_name] || 'music'
  @play              = options[:play] || true
  extract_samples
  play if play
end

Instance Attribute Details

#output_file_nameObject

Returns the value of attribute output_file_name.



6
7
8
# File 'lib/music_theory/play.rb', line 6

def output_file_name
  @output_file_name
end

#playable_musicObject

Returns the value of attribute playable_music.



6
7
8
# File 'lib/music_theory/play.rb', line 6

def playable_music
  @playable_music
end

#samplesObject

Returns the value of attribute samples.



6
7
8
# File 'lib/music_theory/play.rb', line 6

def samples
  @samples
end

Instance Method Details

#extract_samplesObject



16
17
18
# File 'lib/music_theory/play.rb', line 16

def extract_samples
  @samples = playable_music.map  { |music| music.samples }.flatten
end