From: W. Trevor King Date: Sat, 13 Nov 2010 17:05:13 +0000 (-0500) Subject: Add abcplay post. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=62818c4e82e3e68bb57a90ae0c344cef30ad90f6;p=mw2txt.git Add abcplay post. --- diff --git a/posts/abcplay.mdwn b/posts/abcplay.mdwn new file mode 100644 index 0000000..b78c890 --- /dev/null +++ b/posts/abcplay.mdwn @@ -0,0 +1,33 @@ +I've got a travel-size violin (by [Bill Whipple]) that I mess around +with. I like a lot of traditional and celtic music, and I wanted +something that would provide both a visual and aural rendition of a +song to help me learn it. + +Looking around, I found [ABC][] (see John Chamber's [page][JC] and +[tutorial][]), which is a simple, ASCII notation for sheet music. +There are lots of [software tools][] for processing ABC; my favorite +is [abcMIDI][] (which I've packaged in my [[Gentoo overlay]] and is +also packaged in the [Sunrise overlay][]). `abcMIDI` provides several +useful programs: + +* `abc2midi`: ABC to MIDI conversion, to listen to your music. +* `yaps`: ABC to PostScript conversion, to look at your music. +* `midi2abc`: MIDI to ABC conversion, when you can't find ABC source. + +My favorite ABC tune repository is [The Session][], but there are also +search tools and repositories listed on the [ABC homepage][ABC] and +[JC's page][JC]. + +To make playing ABC files as easy as possible, I've written a little +script, [[abcplay.sh]], which uses `abc2midi` to generate a MIDI file +for each tune and then plays them with [timidity++][]. + +[Bill Whipple]: http://www.wiplstix.com/ +[ABC]: http://abcnotation.com/ +[JC]: http://ecf-guest.mit.edu/~jc/music/abc/ +[tutorial]: http://ecf-guest.mit.edu/~jc/music/abc/doc/ABCtutorial.html +[software tools]: http://abcnotation.com/software +[abcMIDI]: http://abc.sourceforge.net/abcMIDI/ +[Sunrise overlay]: http://overlays.gentoo.org/proj/sunrise +[The Session]: http://www.thesession.org/ +[timidity++]: http://timidity.sourceforge.net/ diff --git a/posts/abcplay/abcplay.sh b/posts/abcplay/abcplay.sh new file mode 100755 index 0000000..ccc01e0 --- /dev/null +++ b/posts/abcplay/abcplay.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Copyright (C) 2009-2010 W. Trevor King +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# . + + +MIDI_FILE=`mktemp --tmpdir abcmidi-XXXXXX` + +USER_INTERRUPT=13 +LAST_SIGINT=0 +# Clean up and exit on SIGTERM (default signal from kill command) +trap 'rm -f "$MIDI_FILE"; exit $USER_INTERRUPT' TERM HUP +# Clean up and continue to next song on SIGINT (^C) +# If two SIGINTS come in the same second, exit. +trap 'rm -f "$MIDI_FILE"; TIME=`date +%s`; + let "DELAY = TIME - LAST_SIGINT"; + if [ "$DELAY" -eq 0 ] || [ "$DELAY" -eq 1 ]; then exit $USER_INTERRUPT; fi + LAST_SIGINT="$TIME";' INT + +for ABC_FILE in $*; do + grep '^X:' "$ABC_FILE" | cut -d: -f2 | while read REFNUM + do + abc2midi "$ABC_FILE" "$REFNUM" -o "$MIDI_FILE" + timidity "$MIDI_FILE" + rm -f "$MIDI_FILE" + done +done