Method: Synthesizer::Modulation::Adsr#plot_data

Defined in:
lib/synthesizer/modulation/adsr.rb

#plot_data(soundinfo) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/synthesizer/modulation/adsr.rb', line 109

def plot_data(soundinfo)
  samplecount = soundinfo.window_size.to_f
  note_on = note_on_envelope(soundinfo, samplecount, sustain: false)
  note_off = note_off_envelope(soundinfo, samplecount, sustain: false)
  last = 0.0

  xs = []
  ys = []

  note_on.each {|y|
    xs << xs.length
    ys << y
  }

  last = ys.last || 0.0
  note_off.each {|y|
    xs << xs.length
    ys << y * last
  }

  {x: xs, y: ys}
end