Skip to content

Instantly share code, notes, and snippets.

@mutagene
Last active December 27, 2015 18:49
Show Gist options
  • Save mutagene/7372289 to your computer and use it in GitHub Desktop.
Save mutagene/7372289 to your computer and use it in GitHub Desktop.
automate transcription of disquiet junto human readable form
#!/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
@disquiet
Copy link

disquiet commented Nov 8, 2013

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