Created
December 5, 2012 10:11
-
-
Save nathanl/4214476 to your computer and use it in GitHub Desktop.
Rearrange song lyrics so it's easier to put guitar chords over them
This file contains hidden or 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/env ruby | |
# Rearrange song lyrics so it's easier to put guitar chords over them: put the | |
# first lines of each verse, which share the same chords, into the first | |
# paragraph. Second lines go into the second paragraph, etc. | |
# | |
# Meant to be used with Unix piping: `cat somefile.txt | ./this_script > output.txt | |
lyrics = STDIN.read | |
paragraphs = lyrics.split("\n\n") | |
lines = paragraphs.map { |paragraph| paragraph.split("\n") } | |
transposed_lines = lines.transpose # Yay for Ruby! | |
new_paragraphs = transposed_lines.map { |paragraph| paragraph.join("\n") } | |
new_lyrics = new_paragraphs.join("\n\n") | |
puts new_lyrics |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! I will incorporate this into my guitar program some how!!