Jay McGavren's Journal

2009-08-15

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
end

And 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...
2009-08-08

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_loop

string_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)}"
end

The result:

Read more...
2009-08-04

Heh...

In my Google search results (I go by “nephariuz” in various online forums)…

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/

Read more...
2009-07-28

Video podcasts on MythTV with MythNetTV

MythNetTV is an early but effective MythTV extension that downloads podcasts and adds them to your recordings list, just like the free downloads feature on TiVo (except you can subscribe to anything you want, provided the format’s supported).

These commands will install and configure the app (be sure to substitute the path you want videos saved to):

sudo apt-get install mythnettv
mkdir /your/dir/here
mythnettv --datadir=/your/dir/here

Subscribe to some geeky shows:

mythnettv subscribe "http://revision3.com/pixelperfect/feed/Xvid-Small" "PixelPerfect"
mythnettv subscribe "http://www3.youtube.com/rss/global/top_rated.rss" "YouTubeTopRated"
mythnettv subscribe "http://revision3.com/trs/feed/Xvid-Small" "TotallyRadShow"
mythnettv subscribe "http://applebytepodcast.cnettv.com/" "CnetAppleByte"
mythnettv subscribe "http://buzzreportpodcast.cnettv.com/" "CnetBuzzReport"
mythnettv subscribe "http://cnetnewspodcast.cnettv.com/" "CnetNewsDaily"
mythnettv subscribe "http://firstlookpodcast.cnettv.com/" "CnetFirstLook"
mythnettv subscribe "http://hackspodcast.cnettv.com/" "CnetHacks"
mythnettv subscribe "http://howtopodcast.cnettv.com/" "CnetHowTo"
mythnettv subscribe "http://realdealvideopodcast.cnettv.com/" "CnetRealDeal"
mythnettv subscribe "http://revision3.com/coop/feed/Xvid-Small" "Co-Op"
mythnettv subscribe "http://www.onnetworks.com/feeds/1460/video/rss.xml?target=site" "PlayValue"

Get show lists for all subscriptions, then download 10 shows:

mythnettv update
mythnettv download 10

List the next 10 shows that will be downloaded:

mythnettv nextdownload 10

Download 1 show from the given subscription:

mythnettv download 1 CnetNewsDaily

List subscriptions:

mythnettv list

More info on these commands and others:

man mythnettv

Read more...
2009-07-27

My preferred sites...

As recommended by Google Preferred Site Search (now in Labs). These were probably gleaned from my search history, and yup, they look about right.

api.rubyonrails.org

code.google.com

giantrobots.thoughtbot.com

github.com

groups.google.com

linuxforums.org

linuxquestions.org

macosxhints.com

mythtv.org

railscasts.com

ruby-doc.org

ubuntuforums.org

Read more...