Re: [NTG-context] Building a guitar chord using MP
Hurray! I've got first draft version of guitar chord building macro. (With the help of this excellent manual http://www.tug.org/docs/metapost/mpman.pdf ) % -- working version --- \startuseMPgraphic{chordgrid}{e,B,G,D,A,E} def fretmark(expr a,b) = % a = string number % b = fret number pickup pencircle scaled 3pt; drawdot(b*7-3, a*4.5-4.5); enddef; drawoptions(withpen pencircle scaled 0.4pt withcolor black) ; draw hlingrid(0, 5, 1, 0.8cm, 1cm) ; draw vlingrid(0, 4, 1, 1cm, 0.8cm) ; fretmark(1,\MPvar{e}); fretmark(2,\MPvar{B}); fretmark(3,\MPvar{G}); fretmark(4,\MPvar{D}); fretmark(5,\MPvar{A}); fretmark(6,\MPvar{E}); \stopuseMPgraphic \define[6]\Ch {\dontleavehmode \useMPgraphic{chordgrid}{e={#1},B={#2},G={#3},D={#4},A={#5},E={#6}}% \hskip2mm} \starttext \Ch{1}{3}{1}{2}{1}{4} \stoptext However, my current trouble is chord caption (like Am). Except wrong placement of the label, adding seventh non-numerical argument to the macro throws an error. % -- does not work --- \startuseMPgraphic{chordgrid}{e,B,G,D,A,E,Cptn} def fretmark(expr a,b) = % a = string number % b = fret number pickup pencircle scaled 3pt; drawdot(b*7-3, a*4.5-4.5); enddef; drawoptions(withpen pencircle scaled 0.4pt withcolor black) ; draw hlingrid(0, 5, 1, 0.8cm, 1cm) ; draw vlingrid(0, 4, 1, 1cm, 0.8cm) ; fretmark(1,\MPvar{e}); fretmark(2,\MPvar{B}); fretmark(3,\MPvar{G}); fretmark(4,\MPvar{D}); fretmark(5,\MPvar{A}); fretmark(6,\MPvar{E}); label.top(\MPvar{Cptn}, (2,0)); \stopuseMPgraphic \define[7]\Ch {\dontleavehmode \useMPgraphic{chordgrid}{e={#1},B={#2},G={#3},D={#4},A={#5},E={#6},Cptn={#7}}% \hskip2mm} \starttext \Ch{1}{3}{1}{2}{1}{4}{Am} \stoptext ! Missing number, treated as zero. <to be read again> A \theMPvariable ->A m <argument> ...\hbox {\scratchdimen \theMPvariable sp}\ifdim \wd \scratchbox ... \secondoftwoarguments #1#2->#2 \prepareMPvariable ...epareMPvariable {\@@meta #1} \fi \next1 #1,->\prepareMPvariable {#1} \doprocesscommaitem ... l.29 \Ch{1}{3}{1}{2}{1}{4}{Am} ? Regards, Vyatcheslav
participants (1)
-
Vyatcheslav Yatskovsky