Class: MorseCode::Wave
- Inherits:
-
Object
- Object
- MorseCode::Wave
- Includes:
- WaveFile
- Defined in:
- lib/morse_code/wave.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(message, frequency = 600, sample_rate = 8000) ⇒ Wave
constructor
A new instance of Wave.
Constructor Details
#initialize(message, frequency = 600, sample_rate = 8000) ⇒ Wave
Returns a new instance of Wave.
9 10 11 12 13 |
# File 'lib/morse_code/wave.rb', line 9 def initialize(, frequency = 600, sample_rate = 8000) @message = @sample_rate = sample_rate @sample = MorseCode::Sample.new(, frequency, sample_rate) end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/morse_code/wave.rb', line 7 def @message end |
Instance Method Details
#generate ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/morse_code/wave.rb', line 15 def generate buffer = WaveFile::Buffer.new(pcm_samples, WaveFile::Format.new(:mono, :float, @sample_rate)) WaveFile::Writer.new(filepath, WaveFile::Format.new(:mono, :pcm_16, @sample_rate)) do |writer| writer.write(buffer) end filepath end |