我想从一本包含 300 多首歌曲的歌本中提取和弦,使用用 [] 定义和弦的 songs 包。然后我想绘制与外部列表匹配的和弦,并使用 gtab 命令返回和弦图或和弦定义。
这对于歌曲包来说是一个很好的功能,但与此同时,欢迎任何建议
\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}