automate transcription of disquiet junto human readable form
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
#!/usr/bin/ruby | |
notes = ["A","A#","B","C","C#","D","D#","E","F","F#","G","G#"] | |
prev_note = "-" | |
ARGV.join('').each_byte do |c| | |
cur_note = nil | |
if c >= "a"[0] && c <= "z"[0] | |
cur_note = notes[ (c - "a"[0])%12 ] | |
elsif c >= "A"[0] && c <= "Z"[0] | |
cur_note = "*emphasis* " + notes[ (c - "A"[0])%12 ] | |
elsif c == ","[0] or c == ";"[0] | |
cur_note = notes[ (notes.index(prev_note)-1)%12] | |
elsif c == "."[0] or c == "!"[0] or c == "?"[0] | |
cur_note = notes[ (notes.index(prev_note)+1)%12] | |
elsif c == " "[0] or c == "\t"[0] || c == "\n"[0] || c == "-"[0] | |
puts "(silence)" | |
else | |
puts "percussion" | |
end | |
if cur_note | |
puts cur_note | |
prev_note = cur_note | |
end | |
end |
Thanks so much for having done this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage:
./disquiet0097.rb "eyes-only records, a compression rifle... a spring pistol.\t\nYates.\n\t He grimaces"