Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - Rendering Music notation with ABC

#1
Rendering Music notation with ABC

<div><p>ABC is a <a href="https://abcnotation.com">human readable ascii representation</a> of music notation.&nbsp; John Chambers posted a <a href="http://trillian.mit.edu/~jc/music/abc/doc/ABCtut_History.html">brief history</a> of ABC notation and there is a <a href="https://abcnotation.com/history">newer history</a> by Chris Walshaw.</p>
<p>Unlike <a href="https://www.musicxml.com">MusicXML</a>, which is designed for exchanging music between score editing and performance applications, ABC is designed to be directly edited by humans. I can type a score in ABC with vim much faster than by fiddling with a mouse in a GUI score editor. Unlike other formats ABC works well with version control such as git. As with <a href="https://fedoramagazine.org/latex-typesetting-part-1/">Latex</a>, what you see is <em>not</em> what you get. But the notation is intuitive, the learning curve is pretty short, and the benefits are awesome.</p>
<p>While often touted as the standard for folk music, it works perfectly for Jazz lead sheets and does <a href="https://www.ucolick.org/~sla/abcmusic/sym7mov2.html">full scores</a> as well. Some GUI score editors can import/export ABC notation. I used <a href="https://en.wikipedia.org/wiki/NoteEdit">noteedit</a> for a GUI editor until it was abandoned upstream, but was able to export as ABC. The <a href="https://pagure.io/abcmusic/raw/master/f/se_tu.abc">result</a> is reasonably human readable – letting me continue to edit in ABC notation, and serving as an example of a more complete score. When you are done with this lesson, you’ll be able to turn it into a PDF!</p>
<h2 id="ancient-4th-century-hymn">Ancient 4th Century Hymn</h2>
<p>For a folk tune example, we will do a simple arrangement of a 4th century hymn, with a medieval era tune. “O Lux Beata Trinitas” is one of the twelve hymns which the Benedictine editors regarded as undoubtedly the work of <a href="https://en.wikipedia.org/wiki/Ambrose">St.&nbsp;Ambrose</a>. It is cited as by St. Ambrose by Hinemar of Rheims in his treatise De unâ et non trinâ Deitate, 857. <a href="https://hymnary.org/text/o_lux_beata_trinitas">Hymnary.org</a></p>
<p>The hymn was still popular in the Gregorian Chant era. <a href="https://www.youtube.com/watch?v=5MUWjxoOhLg">Here</a> you can see the medieval notation and hear a performance as historically accurate as you will find today.</p>
<h2 id="th-century-interpretations">20th Century Interpretations</h2>
<p>The medieval notation was updated in hymnals to <a href="https://hymnary.org/tune/o_lux_beata_trinitas#media">more modern notation</a>, This is our starting point. As reflected in those hymnals, there were no measures or bar lines in the medieval period.</p>
<p>Here are the basics of ABC:</p>
<ul>
<li>Comments are lines beginning with ‘%’.</li>
<li>Notes beginning with “middle C” are entered as CDEFGABcdefgab.</li>
<li>Following a note with a number multiplies the timevalue by that number.</li>
<li>Notes that are next to each other are joined together whenever possible. This is the only way spaces are significant.</li>
<li>Parenthesis are used to tie or slur notes together.</li>
<li>The tune begins with X: 1, where 1 is the tune number. There can be multiple tunes in a file. Folk tunes are often collected into a file. For instance, we could collect all 12 known works of St. Ambrose into a single file named ‘ambrose.abc’.</li>
<li>The title is given with T:</li>
<li>The composer or source is given with C:</li>
<li>The key (default is C major) is given with K:</li>
</ul>
<p>Here is a simple transcription of our tune into ABC:</p>
<pre class="wp-block-preformatted">X: 1
T: O lux beata Trinitas
C: Plainsong, Mode VIII
K: D
% Fedora Magazine example
(AB) (AGFG) EFG (AB) (BA) A4 (AB) (AGFG) EFG (AB) (BA) A4 (AB) d (cd) B (AG) (AB) (AGF) F4 (GA) (AGFG) EFG (AB) (BA) A4</pre>
<p>We are going to do our work in a terminal emulator. Enter the above with your favorite text editor (bonus points if that is cat) into a file named ‘lux.abc’.<br />Or <a href="https://pagure.io/abcmusic/raw/master/f/lux.abc">download lux.abc</a> with all the tunes for this lesson. To format and view this, we need ghostscript, xreader, and abcm2ps. You probably have ghostscript and xreader (or other PDF viewer) already installed on a desktop, but it doesn’t hurt to ask again.</p>
<pre class="wp-block-preformatted">$ sudo dnf install ghostscript xreader abcm2ps make</pre>
<p>I had you install make so a simple makefile can simplify rendering:</p>
<pre class="wp-block-preformatted">.SUFFIXES: .abc .ps .pdf .mid
.abc: abcm2ps $*
.abc.pdf: abcm2ps $* ps2pdf Out.ps $*.pdf
.abc.mid: abc2midi $*.abc -o $*.mid </pre>
<p>Enter or <a href="https://pagure.io/abcmusic/raw/master/f/Makefile">download</a> that as a file named ‘Makefile’. Now format and view our tune:</p>
<pre class="wp-block-preformatted">$ make lux.pdf
$ xreader lux.pdf &amp;</pre>
<p>I had you run xreader in the background, so you can switch back to your terminal. Xreader will update the view whenever lux.pdf is updated. If you are just reading this article, you can also view the output <a href="https://pagure.io/abcmusic/raw/master/f/lux.pdf">here</a>.</p>
<h2 id="adding-lyrics">Adding Lyrics</h2>
<p>Lyrics are entered with ‘w:’ under the tune line they go with. Words are hyphenated to show how the syllables go with the notes. Use ’*’ to use additional notes for the last syllable.</p>
<p>Append tune 2 to the lux.abc file, it is the same tune with lyrics:</p>
<pre class="wp-block-preformatted">X: 2
T: O lux beata Trinitas
C: Words: St. Ambrose 4th century
C: Plainsong, Mode VIII
K: D
% Fedora Magazine example
(AB) (AGFG) EFG (AB) (BA) A4 w: O* lux*** be-a-ta trin-* ni-* tas, (AB) (AGFG) EFG (AB) (BA) A4 w: et* prin-*** ci-pa-lis U-* ni-* tas,
(AB) d (cd) B (AG) (AB) (AGF) F4 w: i-* am sol* re-ce-* dit* i-*gne-us, (GA) (AGFG) EFG (AB) (BA) A4
w: in-* fun-*** de lu-men cor-*di-* bus.</pre>
<p>Now ‘make lux.pdf’ and see the results in your xreader window. Both tunes are rendered to the PDF.</p>
<h2 id="adding-measures">Adding Measures</h2>
<p>So, historical authenticity is all very fine, but I want to make a modern version. The first step for modern ears is to divide the tune into equal sized measures. My ear says that 7/8 is an excellent time signature for this tune.</p>
<ul>
<li>
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">M: 7/8</div>
</div>
<p> specifies a default meter of 7/8</li>
<li>
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">L: 1/8</div>
</div>
<p> specifies a default note length of 1/8 of a whole note. This was already the default, but now it is documented.</li>
<li>
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">Q: 1/4=80</div>
</div>
<p> specifies a suggested speed: 80 quarter notes per minute.</li>
<li>Measures are separated by bar lines represented by ‘|’.</li>
<li>There will be multiple verses, so ‘:|’ adds a repeat bar line.</li>
<li>A final bar line is ‘||’, but we don’t use it for this example.</li>
<li>It is good practice for debugging to divide the lyrics into measures as well, and not rely on automatic distribution.</li>
<li>Note that additional spaces can be added for readability.</li>
<li>Lining up the bar lines is not required, but can make it more readable.</li>
</ul>
<p>Here is tune 3 with bar lines (appended to lux.abc):</p>
<pre class="wp-block-preformatted">X: 3
T: O lux beata Trinitas (3)
C: Words: St. Ambrose 4th century
C: Plainsong, Mode VIII
M: 7/8
L: 1/8
Q: 1/4=80
K: D
% Fedora Magazine example
z(AB) (AGFG) | EFG (AB) (BA) | A3-A4 |
w: O* lux***|be-a-ta trin-* ni-*| tas, |
z(AB) (AGFG) | EFG (AB) (BA)| A3-A4 |
w: et* prin-***|ci-pa-lis U-* ni-*| tas, | (AB) d (cd) B (A |G) (AB) (AGF) F-| F7|
w:i-* am sol* re-ce-|* dit* i-*gne-us,| * |
z(GA) (AGFG) | EFG (AB) (BA) | A3-A4 :|
w:in-* fun-***| de lu-men cor-*di-*|bus. |</pre>
<h2 id="bass-line-chords-and-verses">Bass Line, Chords, and Verses</h2>
<p>Now we begin the real departure in our interpretation. First, chords are added to assist in improvising from a “lead sheet”. Then we add a suggested bass line.</p>
<ul>
<li>
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">V:1</div>
</div>
<p> and </p>
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">V:2</div>
</div>
<p> switch between voices.</li>
<li>Chords are entered in double quotes in the tune line, and are rendered above the following note.</li>
<li>Each comma after a note lowers it by an octave.</li>
<li>
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">C:</div>
</div>
<p> can also be used to document arranger and license.</li>
<li>Addition verses are added as additional lyric lines under a tune line.</li>
<li>Verse numbers can be added by using ‘~’ to join them to the next word with a non-break space. Otherwise they would be counted as words.</li>
<li>
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">%%MIDI</div>
</div>
<p> these are magic comments that are used in the next section!</li>
</ul>
<p>Here is our final tune for this lesson:</p>
<pre class="wp-block-preformatted">X: 4
T: O lux beata Trinitas (4)
C: Words: St. Ambrose 4th century
C: Plainsong, Mode VIII
C: Arranged: Stuart D. Gathman
C: Copyright 2012: Creative Commons Attribution-ShareAlike 2.0
M: 7/8
L: 1/8
Q: 1/4=80
K: D
%%MIDI gchord c3c4
%%MIDI program 75
V:1 "D"z(AB) (AGFG) | "A7"EFG (AB) (BA) | "Dsus"A3-"D"A4 |
w:i.~O* lux*** |be-a-ta trin-* ni-*| tas, |
w:ii.~Te* ma-***|ne lau-dum car-*mi-*| ne, |
w:iii.~De-* o***|Pa-tri sit glo-*ri-*| a, |
V:2 D,3 A,2 A,2 | E,3 A,2 A,2 | D,3 A,2 A,2 |
V:1 "D"z(AB) (AGFG) | "A7"EFG (AB) (BA) | "Dsus"A3-"D"A4 |
w: et* prin-***|ci-pa-lis U-* ni-*| tas, |
w: te* de-*** |pre-ce-mur ves-*pe-*|re: |
w: ei-* us-*** |que so-li Fi-*li-*| o, |
V:2 D,3 A,2 A,2 | E,3 A,2 A,2 | D,3 A,2 A,2 |
V:1 "G"(AB) d (cd) B (A |"Em"G) (AB) (AGF) F-|"D"F7 |
w: i-* am sol* re-ce-|* dit* i-*gne-us,| * |
w: te* nos-tra* sup-plex|* glo-*ri-**a | * |
w: cum* Spi-ri-*tu Pa-|* ra-*cli-**to, | * |
V:2 G,3 B,2 B,2 | D,3 B,2 B,2 | D,3 A,2 A,2 |
V:1 "A7"z(GA) (AGFG) | "A7"EFG (AB) (BA) | "Dsus"A3-"D"A4 :|
w: in-* fun-*** | de lu-men cor-*di-*| bus. |
w: per* cunc-*** | ta lau-det sae-*cu-*| la. |
w: et* nunc,*** | et in per-pe-*tu-* | um |
V:2 E,3 A,2 A,2 | C,3 A,2 A,2 | D,3 A,2 A,2 :|</pre>
<h2 id="rendering-to-midi">Rendering to MIDI</h2>
<p>Rendering that makes a nice lead sheet! What does it sound like? You will need the abc to MIDI translator and a MIDI renderer. Fedora comes with a number of MIDI synthesizer and rendering options, but we will use timidity – a simple command line utility that can render to audio files or play on your speakers.</p>
<p>Install abcMIDI and timidity:</p>
<pre class="wp-block-preformatted">$ sudo dnf install abcMIDI timidity++</pre>
<p>If you have been following the examples, you have 4 tunes in lux.abc. Render them to midi with the abc2midi utility:</p>
<pre class="wp-block-preformatted">$ abc2midi lux.abc</pre>
<p>This creates four midi files, one for each tune: lux1.mid .. lux4.mid. Use timidity to play each file to your speakers:</p>
<pre class="wp-block-preformatted">$ timidity lux1.mid</pre>
<p>When you play ‘lux4.mid’, you will hear what the ‘%%MIDI’ directives did. You can read more about abc2midi and its directives <a href="https://ifdo.ca/~seymour/runabc/abcguide/abc2midi_guide.html">here</a>. You can also hear me <a href="https://gathman.org/music/ogg/LUX%20MIX_1.ogg">singing and playing piano</a> from the lead sheet and totally butchering the Latin.</p>
<p>There is a lot more to ABC, but this has hopefully been a fun introduction!&nbsp; There are more examples in /usr/share/doc/abcm2ps/examples, and check out <a href="http://abcnotation.com/browseTunes">folk tunes from many cultures</a>.</p>
</div>


https://www.sickgaming.net/blog/2020/08/...-with-abc/
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016