Skip to content

Instantly share code, notes, and snippets.

@lwrubel
Created April 24, 2017 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lwrubel/1f19c9056b49ba51d6c30348d73197b2 to your computer and use it in GitHub Desktop.
Save lwrubel/1f19c9056b49ba51d6c30348d73197b2 to your computer and use it in GitHub Desktop.
Sonic Pi code for a sonification of the numbers of titles in Chronicling America, year by year.
require 'csv'
data = CSV.parse(File.read("/Users/lwrubel/projects/chronam-exploration/final-counts.csv"), {:headers => false})
count = 1788
notes = scale(:g2, :major, num_octaves: 5)
separator = 0.2
# for each line of data, play a drum beat and appropriate pitch
data.each do |line|
puts line
puts count
play sample :drum_bass_soft, amp: 0.1
use_synth :hollow
# newspaper page turn sample every ten years
if count % 10 == 0
play sample "/Users/lwrubel/projects/chronam-exploration/page-turn-2.wav", amp: 0.5
puts "page-turn"
end
papers = line[1].to_i
if papers != 0
# in order to reduce the range of notes from 526 to something closer to 5 octaves (22 notes), divide by 25
pitch = (papers / 25)
play notes[pitch], noise: 1
else
play papers
end
sleep separator
count += 1
end
# data/collection ends in 1924, so play up through 2017
loop do
puts count
play sample :drum_bass_soft, amp: 0.1
if count % 10 == 0
play sample "/Users/lwrubel/projects/chronam-exploration/page-turn-2.wav", amp: 0.5
end
sleep separator
count += 1
if count == 2018
stop
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment