1

From a songbook with 300+ songs I want to extract the chords using the songs package which define chords with []. Then I would like to draw the chord that match an external list and return the chord diagrams or chord definitions using gtab commands.

it would be a nice feature for the songs package, but in the meantime any tips are welcome

     \begin{filecontents*}{tabs.txt}
A,X02220:001230
C#sus4,4:XX3341
Bb,X13331:012341
D,X00230:000123
E,022100:023100
F,133211:134211
    \end{filecontents*}

    \documentclass{book}
    \usepackage{xparse}
    \usepackage{songs}
    \ExplSyntaxOn
    \ior_new:N \g_fedelibre_get_tabs_ior
    \prop_new:N \g_fedelibre_tabs_prop

    \cs_new_protected:Npn \fedelibre_add_to_prop:w #1,#2!!
     {
      \prop_gput:Nnn \g_fedelibre_tabs_prop {#1} {#2}
     }
    \ior_open:Nn \g_fedelibre_get_tabs_ior {tabs.txt} 
    \ior_str_map_inline:Nn \g_fedelibre_get_tabs_ior
     {
      \fedelibre_add_to_prop:w #1!!
     } 
    \DeclareDocumentCommand{ \fedetab }{ v }
     {
      \prop_get:NnNTF \g_fedelibre_tabs_prop {#1} \l_tmpa_tl
       {
        \fedelibre_gtab:nV {#1} \l_tmpa_tl
       }
       {
        \msg_term:n {Maybe~ you~ have~ mispelled~ your~ tab!}
       }
     }
    \cs_set_eq:NN \fedelibre_gtab:nn \gtab
    \cs_generate_variant:Nn \fedelibre_gtab:nn { nV }
    \ExplSyntaxOff


    \begin{document}
    \begin{songs}{}
    \beginsong{First Song}
    \beginverse
    \[A]Sed ut perspiciatis \[E]unde omnis iste \[Bb]natus error
    \[E] sit voluptatem \[A]accusantium doloremque \[Bb]laudantium
    \endverse
    \beginverse
    \[A]Quis autem vel eum iure \[E]reprehenderit qui \[Bb] in ea 
    \[E]voluptate velit esse \[A]quam nihil molestiae \[Bb]consequatur
    \endverse
    \endsong

    \beginsong{Second Song}
    \beginverse
    \[A]Sed ut perspiciatis \[D]unde omnis iste \[Bb]natus error
    \[E] sit voluptatem \[F]accusantium doloremque \[A]laudantium
    \endverse
    \beginverse
    \[D]Quis autem vel eum iure \[E]reprehenderit qui \[Bb] in ea 
    \[F]voluptate velit esse \[D]quam nihil molestiae \[Bb]consequatur
    \endverse
    \endsong

    \end{songs}
    % need code here to extract the list of all chords in the songbook
    % that contains more than 300 songs
    % with that list, I need the unique occurence of chords
    % then proceed to print each chord with \fedetab
    %for \fedetab info see this thread
    % http://tex.stackexchange.com/questions/151004/songs-package-how-to-store-gtab-definitions-in-an-external-file/151102
    {\bfseries\Large Chords used in the Songbook A  Bb  D  E  F}
    \newline
    \newline
    \fedetab{A}  \fedetab{Bb} \fedetab{D} \fedetab{E} \fedetab{F}

    \end{document}

Songs with overlapping chords

What I want to accomplish is Unique chords Printed

  • 1
    Welcome. Many of us here aren't very familiar with typesetting music, which adds weight to the usual request for a minimum working example that we can test. – Chris H Nov 9 '16 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.