Sha256: 8d8580c70c187b25f98e5a7d61aa98cae7ecd3b5694b501055fdf32ad0577e80

Contents?: true

Size: 1 KB

Versions: 10

Compression:

Stored size: 1 KB

Contents

# This sketch demonstrates how to create synthesized sound with Minim 
# using an AudioOutput and an Oscil. An Oscil is a UGen object, 
# one of many different types included with Minim. For many more examples 
# of UGens included with Minim, have a look in the Synthesis 
# folder of the Minim examples.
#

load_library 'minim'
include_package 'ddf.minim'
include_package 'ddf.minim.ugens'

attr_reader :minim, :out, :wave

def setup
  size(512, 200, P3D)  
  @minim = Minim.new(self)
  
  # use the getLineOut method of the Minim object to get an AudioOutput object
  @out = minim.get_line_out()
  
  # create a sine wave Oscil, set to 440 Hz, at 0.5 amplitude
  @wave = Oscil.new( 440, 0.5, Waves::SINE )
  # patch the Oscil to the output
  wave.patch(out)
end

def draw
  background(0)
  stroke(255)  
  # draw the waveforms
  (0 ... out.buffer_size - 1).step do |i|
    line( i, 50 + out.left.get(i)*50, i+1, 50 + out.left.get(i+1)*50 )
    line( i, 150 + out.right.get(i)*50, i+1, 150 + out.right.get(i+1)*50 )
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/library/minim/synthesize_sound.rb
ruby-processing-2.6.2 samples/processing_app/library/minim/synthesize_sound.rb
ruby-processing-2.6.1 samples/processing_app/library/minim/synthesize_sound.rb
ruby-processing-2.6.0 samples/processing_app/library/minim/synthesize_sound.rb
ruby-processing-2.5.1 samples/processing_app/library/minim/synthesize_sound.rb
ruby-processing-2.5.0 samples/processing_app/library/minim/synthesize_sound.rb
ruby-processing-2.4.4 samples/processing_app/library/minim/synthesize_sound.rb
ruby-processing-2.4.3 samples/processing_app/library/minim/synthesize_sound.rb
ruby-processing-2.4.2 samples/processing_app/library/minim/synthesize_sound.rb
ruby-processing-2.4.1 samples/processing_app/library/minim/synthesize_sound.rb