Logan put together a pretty impressive container for Jemini (note the rename for Google-ability) demos. Just pick from a menu to load a state. Showing a description? One line. Offering running updates on a variable’s value? One line.
class AudibleState < Gemini::BaseState
def create_ui
text "Click in different places in the window to emit a sound at different pitches and volumes."
watch('Pitch') { @pitch }
watch('Volume') { @volume }
end
def load
set_manager :sound, create(:SoundManager)
audible = create :GameObject, :Audible, :ReceivesEvents
audible.load_sound :boom, "boom.wav"
load_keymap :MouseKeymap
audible.handle_event :mouse_pressed do |message|
@pitch = message.value.pointer.x / 100.0
@volume = message.value.pointer.y / 100.0
audible.emit_sound :boom, @volume, @pitch
end
end
end:)
Aquarius lyrics Artist: Boards of Canada
yeah thats right
ORANGE
yeah thats right
ORANGE
giggle
one ORANGE (Just Fantasize) two three
Read more...MIDIator...
Well, that was easy. Heard about MIDIator (a MIDI event generator for Ruby) on a Confreaks talk, and since I already had MIDI Patchbay and SimpleSynth installed from prior attempts to get things working, I gave it a shot.
Here’s some code that hooks it into a Rinda tuplespace:
require 'rinda/rinda'
require 'rubygems'
require 'midiator'
MY_URI = ARGV[0] || "druby://127.0.0.1:9999"
DRb.start_service
space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, MY_URI))
midi = MIDIator::Interface.new
midi.autodetect_driver
loop do
key, value = space.take([/Integer/, Integer])
midi.play value, 0.01
endAnd here’s what it sounds like in action. I’m sure a better/more skilled controller would make it sound less, uh, horrible. :) Boy, it sure processes those events fast…
Read more...Ooh, purty...
mouse_client.rb:
require 'rubygems'
require 'wx'
require 'rinda/rinda'
MY_URI = "druby://127.0.0.1:9999"
TIME_TO_LIVE = 10
class MouseClient [800, 600],
:title => "Click and Drag"
)
frame.evt_close {exit}
frame.evt_motion {|event| on_mouse_motion(event)}
frame.evt_left_down {|event| on_mouse_press(event)}
frame.evt_left_up {|event| on_mouse_release(event)}
frame.show
end
def on_mouse_motion(event)
return unless event.dragging
space.write ["Integer:x", event.x], TIME_TO_LIVE
space.write ["Integer:y", event.y], TIME_TO_LIVE
end
def on_mouse_press(event); end
def on_mouse_release(event); end
end
client = MouseClient.new
DRb.start_service
client.space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, MY_URI))
client.main_loopstring_length_agent.rb:
require 'rinda/rinda'
MY_URI = ARGV[0] || "druby://127.0.0.1:9999"
DRb.start_service
space = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, MY_URI))
def scale(value)
@largest_seen = value if @largest_seen == nil or value > @largest_seen
value.to_f / @largest_seen
end
loop do
key, value = space.take([/Integer/, nil])
puts "#{key}: #{'|' * (scale(value) * 68.0)}"
endThe result:
Read more...Heh...
In my Google search results (I go by “nephariuz” in various online forums)…
Read more...nepharious :: ruby, rails, consulting We build web applications faster and for less using rapid application prototyping and development with the Ruby on Rails framework. www.nepharious.com/