Last active
September 12, 2015 15:01
-
-
Save lwrubel/63974e300b6ab47b0079 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# plays one note for each day in a year of checkout data from the library | |
# recording at https://soundcloud.com/laurasaurus5/checkouts | |
require 'csv' | |
data = CSV.parse(File.read("/Users/lwrubel/projects/datasonify/gwtransactcounts.csv"), {:headers => true, :header_converters => :symbol}) | |
# 7/1/2014 is a Tuesday and day 182 of the year | |
dailycount = 2 | |
day = 182 | |
data.each do |line| | |
checkouts = line[:count].to_f | |
next unless checkouts > 0 | |
use_synth :piano | |
# chunk counts and assign a pitch | |
# data values are roughly 0-1000 | |
rough_num = (checkouts/5).round(-1) | |
pitches = {0=>:C4, 10=>:D4, 20=>:E4, 30=>:F4, 40=>:G4, 50=>:A4, 60 =>:B4, 70=>:C5, 80=>:D5, 90=>:E5, 100=>:F5, 110=>:G5, 120=>:A5, | |
130=>:B5, 140=>:C6, 150=>:D6, 160=>:E6, 170=>:F6, 180=>:G6, 190=>:A6} | |
new_pitch = pitches[rough_num] | |
# set higher amp and play drum at the start of each week | |
if dailycount % 7 == 0 | |
beat = 1.2 | |
week_sample = :bd_zome | |
else beat = 0.5 | |
end | |
# extra drums for semester dates | |
if (day >= 237 and day <=353) | |
sem_sample = :drum_bass_soft | |
elsif (day >= 377 and day <=497) | |
sem_sample = :drum_bass_soft | |
end | |
# make noise! | |
play new_pitch, amp: beat | |
sample sem_sample, amp: 0.25 | |
sample week_sample, amp: 0.25 | |
sleep 0.15 | |
dailycount += 1 | |
day += 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment