From: andrew Date: Tue, 13 May 2014 04:16:37 +0000 (-0700) Subject: Added Songbook X-Git-Url: https://defaria.com/gitweb/?a=commitdiff_plain;h=60e48d48fa976ac3e33c69ea1a815d23b756b24d;hp=8e8e34a5c3dc7ed9571d6df719b04dd87d05f179;p=clearscm.git Added Songbook --- diff --git a/songbook/background.jpg b/songbook/background.jpg new file mode 100644 index 0000000..2d289dc Binary files /dev/null and b/songbook/background.jpg differ diff --git a/songbook/displayartist.php b/songbook/displayartist.php new file mode 100644 index 0000000..627aa16 --- /dev/null +++ b/songbook/displayartist.php @@ -0,0 +1,47 @@ + + + + + + Songbook" Artist + + + + + + +
+Home +

Andrew DeFaria's Songbook

+ +

+
+ +
+ +"; + +foreach ($artistsSongs as $artistSong) { + print "
  • "; + print basename ($artistSong, ".pro"); + print "
  • "; +} // foreach +?> + + + diff --git a/songbook/index.new.php b/songbook/index.new.php new file mode 100644 index 0000000..14fccff --- /dev/null +++ b/songbook/index.new.php @@ -0,0 +1,54 @@ + + + + + + Songbook + + + + + + + + + + +"; + } +?> + +
    +

    Andrew DeFaria's Songbook

    +
    + +
    + +

    As a professional musician do yourself a favor and invest in a tablet or if +you must an iPad and get either SongBook (for Android) or OnSong for iPad then +send me a request to sign up for Dropbox which integrates with these apps and +your "songbook" will be automated. Note that Songbook is also available for +Windows. More info on this is available here. For +people who must remain with paper...

    + +

    The following songs are available here. Click on a song title to have the +song lyrics rendered in your browser. You can print the result if you wish to +have a paper copy. If new songs are added by me or others this page will +automatically update so you can come back here and get your copy.

    + + + +
    +Search:   + +
    + + diff --git a/songbook/index.php b/songbook/index.php new file mode 100644 index 0000000..8b32bbd --- /dev/null +++ b/songbook/index.php @@ -0,0 +1,55 @@ + + + + + + Songbook + + + + + + + + + + +"; + } +?> + +
    +

    Andrew DeFaria's Songbook

    +
    + +
    + +

    As a professional musician do yourself a favor and invest in a tablet or if +you must an iPad and get either SongBook (for Android) or OnSong (for iPad) then +send me a request to sign up for Dropbox which integrates with these apps and +your "songbook" will be automated. Note that Songbook is also available for +Windows. More info on this is available here. For +people who must remain with paper...

    + +

    The following songs are available here. Select an artist or a song and then +Go or type in a lyric or song title into the search box. You can print the +result if you wish to have a paper copy. If new songs are added by me or others +this page will automatically update so you can come back here and get your +copy.

    + + + +
    +Search:   + +
    + + diff --git a/songbook/news.html b/songbook/news.html new file mode 100644 index 0000000..7c6f562 --- /dev/null +++ b/songbook/news.html @@ -0,0 +1,97 @@ + + + + + + Songbook + + + + + + + + + +
    +

    Songbook News

    +
    + +
    + +

    Recent Changes

    + +

    I've made some more changes:

    + +
      + +
    • Removed the list of songs from the front page. There were getting to be just +too many songs listed to be helpful. Instead I now have a drop down list of +artists and songs as well as a search box. Select an artist or a song and then +select go to go to an artist page or a song page. Or search for a term. The search +will search for a word or phrase in the title, artist or in the song itself. The +search is not that bright but works fairly well.
    • + +
    • There's a new artist's page which shows you all of the artists songs in one +page. Many artists have only one or a few songs. Some artists have quite a few +songs.
    • + +
    • The song pages now are on auto play. If they have music assoicated with them +then their music will start playing automatically.
    • +
    + +

    Past Changes

    + +
      +
    • Changed the home icon to something much bigger. Clicking on this gets you + back to the Songbook home page.
    • + +
    • Now if the song has an associated .mp3 file in the Media folder that + exactly matches the song's title then a little HTML5 MP3 player will + appear. You can play the song while you read the words and follow the + chords! Note: You can right click and save the song's mp3 file to + your computer. If the song does not have a corresponding .mp3 file then + no .mp3 player is displayed. For example, Amie.
    • + +
    • Again, if the song has a corresponding .mp3 file I now re-write the .pro + file to include {musicpath:/sdcard/SongBook/Medai/<title>.mp3}. + This string "links" the ChordPro file with music such that (in SongBook, the + app I use on my Android Tablet) you can play the song's mp3 file on your + tablet! I'm not sure if OnSong (the iPad equivalent of SongBook) does the same + thing. If you sign up for sharing my songbook via DropBox (send me email if + you want an invite) you should be all set.
    • +
    + +

    Note: Currently my code is very picky. The file name for the .pro file +and the .mp3 file must match exactly - is case sensitive, etc. If you +have access to my songbook in DropBox and wish to add a .pro file and it's +corresponding .mp3 file then be sure to match the names up correctly and put the +.mp3 file in the Media folder.

    + +

    Future Changes

    + +

    Here are some of the things I'm thinking of implementing:

    + +
      +
    • I'm thinking of re-vamping the main page. Instead of listing all the + songs, which are getting to be a bit much, I would like to possibly make a + little search facility that would scan the .pro files for text matching in the + song titles and lyrics themselves.
    • + +
    • Another change I'm thinking of making is making it so that when you hover + over a chord a little popup happens that shows the chord's fingering. Sorta + like it's done over on tabs-ulitimate-guitar.com (For example: + here). + Anybody know how to do that?
    • + +
    • Maybe a simple editor so people can edit songs directly.
    • + +
    • Maybe interfacing with Dropbox to display information about the last + person to update the songfile...
    • +
    + +
    + + + diff --git a/songbook/search.php b/songbook/search.php new file mode 100644 index 0000000..edd23f2 --- /dev/null +++ b/songbook/search.php @@ -0,0 +1,84 @@ + + + + + + Songbook" Artist + + + + + + + + + +
    +Home +

    Andrew DeFaria's Songbook

    + +

    +
    + +
    + + 0) { + print "
      "; +} // if + +foreach ($songmatches as $songmatch) { + $artist = getArtist ($songmatch); + $title = basename ($songmatch, ".pro"); + print "
    1. $title"; + print " ($artist)
    2. "; +} // foreach + +if (count ($songmatches) > 0) { + print "
    "; +} // if +?> + +
    + + + diff --git a/songbook/songbook.html b/songbook/songbook.html new file mode 100644 index 0000000..fd3faf8 --- /dev/null +++ b/songbook/songbook.html @@ -0,0 +1,157 @@ + + + + + + Songbook + + + + + + + +
    +

    Songbook/OnSong and chordpro (.pro) files

    +
    + +
    + +

    Rather than carry around sheets of paper for everybody, fumbling +and trying to find the right song sheet etc., you can use your +computer to help automate this process.

    + +

    A chordpro file (signified by a .pro extension) is not a fancy file +format, but it gets the job done and is easy to edit with any editor +like notepad. You can google "chordpro" and read all about the format +if you like.

    + +

    If you have a iPad or a Android tablet you can have all of your +songs with you wherever you go. Linked +with DropBox and everybody can +be on the same page. Worst case you have all of the music you know at +your fingertips. There are two apps, one for iPads +(OnSong) +and the other for Android and PCs +(Songbook) +that will work with .pro file to render them nicely on your iPad or +Android tablet. And Songbook also works on your Windows PC where +you can print out copies of the songs if you inist on dealing with +paper.

    + +

    Finally, you could go to my website and render any of the songs in +my Songbook using the web (described below).

    + +

    Chordpro file format

    + +

    You can go +to http://defaria.com/songbook/Songs +and you'll see a list of all the files in that directory, the .pro +files of the songs I have. You can click on any of them but what you +will get is an unrendered version of the .pro file. For example: If +you click on Brown Eyed Girl.pro you'll see:

    + +
    +    {t:Brown Eyed Girl}
    +    {st:Van Morrison}
    +    {key:G}
    +
    +    [G]Hey, where did [C]we go, da[G]ys when the ra[D]ins came
    +    [G]Down in the holl[C]ow, [G]playin' a ne[D]w game
    +    [G]Laughin' and a-s[C]ingin' hey-hey, [G]skippin' and a-j[D]umpin'
    +    [G]In the misty mor[C]ning fog, with o[G]ur he[D]arts thumpin and yo[C]u[D]
    +    My Brown-eyed gi[G]rl[Em], yo[C]u my[D] brown eyed [G]girl [D]
    +
    +    [G]Hey whatever [C]happened, [G]Tuesday went [D]so slow
    +    [G]Goin down the [C]old mine with a [G]transistor [D]radio
    +    [G]Standin' in the [C]sunlight laughin', [G]hide behind the [D]rainbow's wall
    +    [G]Slippin' and a-[C]slidin', [G]all along the [D]waterfall with [G]you
    +    My Brown-eyed gi[G]rl[Em], yo[C]u my[D] brown eyed [G]girl [D]
    +
    +    {soc}
    +    [D]Do you remember when we used to [G]sing
    +    Sha-la-la [C]la-la la-la [G]la-la la-la [D]de-da
    +    [G]Sha-la-la [C]la-la la-la [G]la-la la-la [D]de-da
    +    La-de-[G]da[D]
    +    {eoc}
    +
    +    [G][Em][C][D][G][D]
    +
    +    So hard to find my way, now that I'm all on my own
    +    Saw you just the other day, my how you have grown
    +    Cast my memory back there lord, sometimes I'm overcome, thinkin'bout
    +    Making love in the green grass, behind the stadium with you
    +    My brown eyed girl, you my brown eyed girl
    +
    +    {soc}
    +    [D]Do you remember when we used to [G]sing
    +    Sha-la-la [C]la-la la-la [G]la-la la-la [D]de-da
    +    [G]Sha-la-la [C]la-la la-la [G]la-la la-la [D]de-da
    +    La-de-[G]da
    +    {eoc}
    +
    + +

    You see things like {t:Brown Eyed Girl} (title) and {key:G} as well +as embedded tags for the chords ([G], [C], etc). Doesn't look as +pretty right? But when you include the webchord.cgi portion you are +running a script named webchord.cgi which reads the file from the +parameter chordpro (that's why you need the chordpro=song.pro portion) +and then reformats stuff into HTML that looks pretty, centering the +title of the song, putting the chords over the words and bolding the +text between {soc} and {eoc} (start of chorus, end of chorus). So +given the above SongTitle="Brown Eyed Girl" we can formulate the URL +to render it thusly:

    + +
    http://defaria.com/bin/webchord.cgi?chordpro=/web/songbook/Songs/Brown Eyed Girl.pro
    + +

    You can do the same thing for the other songs there too.

    + +

    I should just write a quick script that gets all of the .pro files +in the directory songbook/Songs and then formulates a page of links +that have the webchord.cgi links to render them like:

    + + + +

    You have to fill in the <SongTitle> portion of the link. So, for +example, you take:

    + +
    +http://defaria.com/songbook/Songs/webchord.cgi?chordpro=<SongTitle>.pro +
    + +

    pop it into the address bar of your browser then change <SongTitle> +to the title of the song you want to render:

    + +
    +http://defaria.com/bin/webchord.cgi?chordpro=/web/songbook/Songs/Amie.pro +
    + +

    Note:

    + +
      +
    • URLs are case sensitive! ...chordpro=amie.pro is not the same as ...chordpro=Amie.pro
    • +
    • Browsers tend to change spaces in a URL to %20. %20 is the octal representation for a space character. So if you see %20 in a URL like http://defaria.com/bin/webchord.cgi?chordpro=/web/songbook/Songs/Back%20in%20the%20USSR.pro. Don't fear - they're merely spaces.
    • +
    + +

    Songbook for PC

    + +

    You can get a Windows PC version of Songbook +at http://linkesoft.com/songbook/windows.html. It +will run on your PC and render songs like:

    + + + +

    It's $20 and you can even print out your stuff if you still use +paper or need paper for other people.

    + +
    + + + diff --git a/songbook/songbook.jpg b/songbook/songbook.jpg new file mode 100644 index 0000000..343a1c4 Binary files /dev/null and b/songbook/songbook.jpg differ diff --git a/songbook/songbook.php b/songbook/songbook.php new file mode 100644 index 0000000..f3893b8 --- /dev/null +++ b/songbook/songbook.php @@ -0,0 +1,87 @@ +"; + print "Songs:  "; + print ""; + print ""; + print ""; +} // songsDropdown + +function artistsDropdown () { + global $songs; + + $artists = getArtists ($songs); + + print "
    "; + print "Artists:  "; + print ""; + print ""; + print "
    "; +} // artistsDropdown + +function getArtist ($song) { + $lyrics = file_get_contents ($song); + + if (preg_match ("/\{(st|subtitle):(.*)\}/", $lyrics, $matches)) { + return trim ($matches[2]); + } else { + return ""; + } // if +} // getArtist + +function getArtists ($songs) { + $artists = array(); + + foreach ($songs as $song) { + $artist = getArtist ($song); + + if ($artist != '') { + $artists[$artist] = 1; + } // if + } // foreach + + return array_keys ($artists); +} // getArtists + +function formatTable ($songs) { + echo "
      "; + + foreach ($songs as $song) { + $artist = getArtist ($song); + + $title = basename ($song, ".pro"); + + echo "
    1. $title"; + + if ($artist != "") { + echo " ($artist)"; + } // if + } // foreach + + echo "
    "; +} // formatTable \ No newline at end of file diff --git a/songbook/webchord.cgi b/songbook/webchord.cgi new file mode 100755 index 0000000..28d0969 --- /dev/null +++ b/songbook/webchord.cgi @@ -0,0 +1,311 @@ +#!/usr/bin/perl + +# Web Chord v1.1 - A CGI script to convert a ChordPro file to HTML +# Copyright 1998-2003 Martin Vilcans (martin@mamaviol.org) +# +# CGI parameters: +# chopro - This parameter can be submitted by a form as a text field or file +# upload. +# +# History: +# 1998-07-20 Version 1.0 +# 2003-08-03 Version 1.1 Uses stylesheets +# 2014-02-05 Added things particular to my implementation of Songbook at +# http://defaria.com/songbook + +use strict; +use warnings; + +use CGI qw(:standard); +use CGI::Carp qw (fatalsToBrowser); +use File::Basename; + +my ($chopro, $output, $i); + +my $documentRoot = "/web"; +my $debug = param ('debug'); +my $infile = param ('chordpro'); + + +sub debug ($) { + my ($msg) = @_; + + return unless $debug; + + print "Debug: $msg
    "; + + return; +} # debug + +sub warning ($) { + my ($msg) = @_; + + debug "warning"; + + print "Warning $msg
    "; + + return; +} # warning + +sub error { + my ($msg) = @_; + + print "Web Chord: Error" . + "

    Error

    \n$msg\n

    " . + ""; + + exit; +} # error + +sub musicFileExists ($) { + my ($song) = @_; + + debug "ENTER musicFileExists ($song)"; + + my $title = fileparse ($song, qr/\.pro/); + my $musicfile = "/songbook/Media/$title.mp3"; + + if (-r "$documentRoot$musicfile") { + debug "Exists!"; + + return $title; + } else { + debug "Could not find $documentRoot$musicfile"; + + return undef; + } # if +} # musicFileExists + +sub updateMusicpath ($$) { + my ($chopro, $song) = @_; + + my $title = musicFileExists $song; + + # If there's no corresponding music file then do nothing + return unless $title; + + # If the .pro file already has musicpath then do nothing + if ($chopro =~ /\{musicpath:.*\}/) { + debug "$song already has musicpath"; + } # if + + return if $chopro =~ /\{musicpath:.*\}/; + + # Otherwise append the musicpath + my $songfile; + + open $songfile, '>>', $song + or undef $songfile; + + unless (defined $songfile) { + my $msg = "Unable to open $song for append - $!
    "; + $msg .= "
    Please notify Andrew DeFaria so this can be corrected.
    "; + $msg .= "
    Thanks"; + warning $msg; + + return; + } # unless + + my $songbase = '/sdcard'; + $songbase = '/storage/emulated/0'; + + print $songfile "{musicpath:$songbase/SongBook/Media/$title.mp3}\n"; + + close $songfile; + + return; +} # updateMusicPath + +# Outputs the HTML code of the chordpro file in the first parameter +sub chopro2html ($$) { + my ($chopro, $song) = @_; + + $chopro =~ s/\/\>/g; # replace > with > + $chopro =~ s/\&/\&/g; # replace & with & + + my $title; + + if(($chopro =~ /^{title:(.*)}/mi) || ($chopro =~ /^{t:(.*)}/mi)) { + $title = $1; + } else { + $title = "ChordPro song"; + } + print < + +$title + + + +END + + $title = musicFileExists $song; + + if ($title) { + updateMusicpath $chopro, $song; + } # if + + print << "END"; + + + + +END + + if ($title) { + print <<"END"; + +END + } # if +print <<"END"; + + +
    Home + +
    +END + my $mode = 0; # mode defines which class to use + + #mode = 0 1 2 3 + # normal chorus normal+tab chorus+tab + my @lClasses = ('lyrics', 'lyrics_chorus', 'lyrics_tab', 'lyrics_chorus_tab' ); + my @cClasses = ('chords', 'chords_chorus', 'chords_tab', 'chords_chorus_tab' ); + + while($chopro ne '') { + $chopro =~ s/(.*)\n?//; # extract and remove first line + $_ = $1; + chomp; + + if(/^#(.*)/) { # a line starting with # is a comment + print "\n"; # insert as HTML comment + } elsif(/{(.*)}/) { # this is a command + $_ = $1; + if(/^title:/i || /^t:/i) { # title + print "

    $'

    \n"; + } elsif(/^subtitle:/i || /^st:/i) { # subtitle + print "

    $'

    \n"; + } elsif(/^start_of_chorus/i || /^soc/i) { # start_of_chorus + $mode |= 1; + } elsif(/^end_of_chorus/i || /^eoc/i) { # end_of_chorus + $mode &= ~1; + } elsif(/^comment:/i || /^c:/i) { # comment + print "($')\n"; + } elsif(/^comment_italic:/i || /^ci:/i) { # comment_italic + print "($')\n"; + } elsif(/^comment_box:/i || /^cb:/i) { # comment_box + print "

    $'

    \n"; + } elsif(/^start_of_tab/i || /^sot/i) { # start_of_tab + $mode |= 2; + } elsif(/^end_of_tab/i || /^eot/i) { # end_of_tab + $mode &= ~2; + } else { + print "\n"; + } + } else { # this is a line with chords and lyrics + my(@chords,@lyrics); + @chords=(""); + @lyrics=(); + s/\s/\ /g; # replace spaces with hard spaces + while(s/(.*?)\[(.*?)\]//) { + push(@lyrics,$1); + push(@chords,$2 eq '\'|' ? '|' : $2); + } + push(@lyrics,$_); # rest of line (after last chord) into @lyrics + + if($lyrics[0] eq "") { # line began with a chord + shift(@chords); # remove first item + shift(@lyrics); # (they are both empty) + } + + if(@lyrics==0) { # empty line? + print "
    \n"; + } elsif(@lyrics==1 && $chords[0] eq "") { # line without chords + print "
    $lyrics[0]
    \n"; + } else { + print ""; + print "\n"; + my($i); + for($i = 0; $i < @chords; $i++) { + print ""; + } + print "\n\n"; + for($i = 0; $i < @lyrics; $i++) { + print ""; + } + print "
    $chords[$i]
    $lyrics[$i]
    \n"; + } # if + } # if + } # while +} # chordpro2html + +## Main +print header; + +unless ($infile) { + error "No chordpro parameter"; +} # unless + +open my $file, '<', $infile + or error "Unable to open file $infile - $!"; + +{ + local $/; + $chopro = <$file>; +} + +chopro2html ($chopro, $infile); + +print end_html(); + +exit; + +