# This example shows how to create a cluster of sine oscillators, change the # frequency and detune them depending on the position of the mouse in the # renderer window. The Y position determines the basic frequency of the # oscillator and X the detuning of the oscillator. The basic frequncy ranges # between 150 and 1150 Hz load_library :sound include_package 'processing.sound' # The number of oscillators NUM_SINES = 5 # A for calculating the amplitudes attr_reader :sine_volume, :sine_waves def setup size 500, 500 background 255 no_stroke create_oscillators end def create_oscillators # Create the oscillators and amplitudes @sine_waves = [] @sine_volume = [] NUM_SINES.times do |i| # The overall amplitude shouldn't exceed 1.0 # The ascending waves will get lower in volume the higher the frequency sine_volume << (1.0 / NUM_SINES) / (i + 1) # Create the Sine Oscillators and start them wav = SinOsc.new(self) wav.play sine_waves << wav end end def draw fill mouse_x, mouse_y, 0, 100 ellipse(mouse_x, mouse_y, 10, 10) # Use mouse_y to get values from 0.0 to 1.0 yoffset = (height - mouse_y) / height.to_f # Set that value logarithmically to 150 - 1150 Hz frequency = 1000**yoffset + 150 # Use mouse_x from -0.5 to 0.5 to get a multiplier for detuning the # oscillators detune = mouse_x.to_f / width - 0.5 # Set the frequencies, detuning and volume sine_waves.each_with_index do |wav, i| wav.freq(frequency * (i + 1 + i * detune)) wav.amp(sine_volume[i]) end end
Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Sunday, 25 January 2015
Testing the new processing sound library in ruby-processing
There is a new processing sound library for processing-3.0 (that also works with processing-2.0), I thought I would give it a run-out in ruby-processing:-
Labels:
library,
processing.org,
ruby-processing,
sound
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
-
▼
2015
(51)
-
▼
January
(13)
- Installing netbeans ruby-plugin and jruby_art gem
- JRubyArt vs ruby-processing
- Netbeans, the perfect ide for jruby_art
- Cranky keyboard (unless you are a northern Europea...
- Another sound library example translated to ruby-p...
- Testing the new processing sound library in ruby-p...
- Mirror, a Dan Shiffman video capture sketch
- Experimenting with refinements
- Configuring ruby processing
- A Golan Levin video capture sketch translate to ru...
- A simplified ASCII video capture sketch in ruby pr...
- A Ben Fry video capture sketch in ruby-processing
- Video capture with ruby-processing
-
▼
January
(13)
About Me
- monkstone
- I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2
No comments:
Post a Comment