Rhythm visualization

Launch the rhythm visualization demo

Continuing from my first iteration on a visual metronome, this is an improvement to simplify things while providing greater control in the UI for: tempo, cycles (bars), beats, and emphasis highlighting (nth). My intention is for this to evolve toward a metric modulation visualization.

I moved from the traditional European music notation of left to right / top to bottom, and used a more abstract top to bottom / left to right orientation. Most often I work with more bars than beats, so this worked nicely for laptop screen dimensions. Also, I enjoy nudging the musician away from the usual way we visually experience music.

Thanks to James Edwards article on javascript timing, and of course the jQuery team.

Posted in code, javascript, jQuery, music | Leave a comment

Wellspring

Listen to “Wellspring”

Posted in music | Leave a comment

Willow Weep for Me

Listen to “Willow Weep for Me”

Posted in music | Leave a comment

Do Nothing Till You Hear From Me

Listen to “Do Nothing Till You Hear From Me”

Posted in music | Leave a comment

Command finished notification with Ruby

I wanted a visual notification in Ubuntu when long running commands finished in Terminal. My solution, run the command and pipe it into notify.

$ a-long-running-command | notify

notify.rb

#!/usr/bin/env ruby
require 'rubygems'
require 'libnotify'
Libnotify.show :summary => "Command finished.", :body => "#{ARGF.read}"

Make it executable

chmod u+x ~/scripts/notify.rb

add an alias to it in ~/.bashrc

alias notify="~/scripts/notify.rb"

Requires:
ruby
, rubygems, and libnotify.

Similar solutions:
“alert” alias (I’ll be switching to this in Maverick),
a python version

Posted in code, ruby, ubuntu | Leave a comment

nomad

A little flavor of Tinariwen. Tuned D G D G A D.

Listen to “nomad”

Posted in music | Leave a comment

Visual Metronome

/*
 * metronome
 */
int stage = 600;
int mains = int(random(3,9) );
int subs = int(random(3,6) );
float moon_size = 3;
int bpm = 60;
int active_main = 0;
int active_sub = 0;
color main_color = #292B89;
color first_color = #1A1B55;
color active_color = 0x95FFFFFF;
int my_frame_rate = 12;
float bps = float(bpm) / 60 ;

void setup() {
  size(stage, stage);
  frameRate(my_frame_rate);
  noStroke();
}
void draw() {
  background(#989898);
  if( frameCount % (my_frame_rate/bps) < 1 ){
    active_main+=1;
    if(active_main>=mains){
      active_main=0;
    }
  }
  if( frameCount % (my_frame_rate/bps/subs) < 1 ){
    active_sub+=1;
    if(active_sub==subs){
      active_sub=0;
    }
  }
  Circle a = new Circle(width/2, height/2, stage/2, mains);
  a.make_moons( active_main );
  a.moons[active_main].make_moons( active_sub );
}
void mouseMoved(){
  mains = 2 + mouseX /(stage/10);
  moon_size = mains/1.555;
  active_main=0;
}
class Circle{
  float r, x, y;
  int active_moon, each_angle, sections;
  Circle moons[] = new Circle[23];

  Circle(float x_init,float y_init,float r_init, int divisions_init){
    x = x_init;
    y = y_init;
    r = r_init;
    sections = divisions_init;
    each_angle = 360 / sections;
  }
  void make(){
    ellipse(x, y, r, r);
  }
  void make_moons( int active_moon ){
    int angle = each_angle;
    for(int i = 0; i < sections; i+=1 ){
      float moon_x = x + cos(radians(angle)) * (r/2);
      float moon_y = y + sin(radians(angle)) * (r/2);
      moons[i] = new Circle(moon_x, moon_y, r / 4, subs);
      if(i==active_moon){fill(active_color);}else if(i==0){fill(first_color);} else{fill(main_color);} // HIGHLIGHT FIRST & ACTIVE MOON
      moons[i].make();
      angle = angle + each_angle;
    }
  }
}
Posted in javascript | 2 Comments

Splash

Listen to “Splash”

Posted in music | 2 Comments

Ruby Duration

Download ruby duration lib

Duration.new recieves a string describing a duration of time, and converts it into: seconds, and a standard readable format.
Or, you can pass Duration.new an integer representing seconds, and receive the same standard readable format.

Usage:

Passing a String

duration = Duration.new("2weeks 8 hr 30m")
duration.seconds  # => 1240200
duration.readable  # => "2 weeks, 8 hours and 30 mins"

Passing an Fixnum (of seconds)

duration = Duration.new(1240200)
duration.readable  # => "2 weeks, 8 hours and 30 mins"

 

Example valid input strings:

“2 weeks”, “2wks”, “2w”,
“8h”, “8 hrs”,”8 hours”,
“30m”, “0:30″, “30 minutes”, “30min”,
“2 weeks, 8 hours and 30 minutes”, “2w 8h 30m”, “2w 8:30″,
“4 hours 30 minutes”, “4 hours and 30m”, “4h 30min”, “4:30″, “4.5″, “4.50″, “4h, 30 min”, “4.5 hours”, “4.50h”

 

ahabman added functionality, extended and mashed-up this stack overflow article and english friendly timespan

Posted in ruby | 1 Comment

rails template

Usage $ rails app_name -m ./ahabman_template.rb


run "rm README"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
run "rm -f public/javascripts/*"

gem 'ruby-openid', :lib => 'openid'
rake("gems:install", :sudo => true)

plugin "kamui_restful_authentication", :git => 'git://github.com/kamui/restful-authentication.git'
plugin 'exception_notifier', :git => 'git://github.com/rails/exception_notification.git'
plugin 'open_id_authentication', :git => 'git://github.com/rails/open_id_authentication.git'
#plugin 'asset_packager', :git => 'http://synthesis.sbecker.net/pages/asset_packager'
plugin 'role_requirement', :git => 'git://github.com/timcharper/role_requirement.git'
#plugin 'acts_as_taggable_redux', :git => 'http://github.com/geemus/acts_as_taggable_redux/tree/master'
#plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'

generate("authenticated user sessions --include-activation --include-forgot-password --email-as-login")
generate("roles", "Role User")

#rake('acts_as_taggable:db:create')
rake("open_id_authentication:db:create")
rake('db:migrate')

route "map.root :controller => 'sessions', :action => 'signup' "

run "echo generated from ahabman_template > README"
run "cp config/database.yml config/example_database.yml"

#if yes?("Do you want this thing?")
# ...
#end

#my_var = ask("was up")
#generate :something, my_var

puts "SUCCESS!"
Posted in rails | Leave a comment