* Re: Building a guitar chord using MP
[not found] <mailman.501.1271102166.4277.ntg-context@ntg.nl>
@ 2010-04-12 21:57 ` Vyatcheslav Yatskovsky
0 siblings, 0 replies; 9+ messages in thread
From: Vyatcheslav Yatskovsky @ 2010-04-12 21:57 UTC (permalink / raw)
To: ntg-context
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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Building a guitar chord using MP
2010-04-10 10:01 ` Vyatcheslav Yatskovsky
@ 2010-04-10 20:26 ` Henning Hraban Ramm
0 siblings, 0 replies; 9+ messages in thread
From: Henning Hraban Ramm @ 2010-04-10 20:26 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 2010-04-10 um 12:01 schrieb Vyatcheslav Yatskovsky:
> 1) Recently we concluded that on-the-fly insertion of Lilypond
> images does not work.
It should work again since a while.
If you need the fret diagrams above lyrics, I'd use LilyPond without a
Staff context.
If you need fret diagrams dispersed in a text, then you'd have to
\lower each one (i.e. I could implement a global voffset option).
see also
http://wiki.contextgarden.net/LilyPond#Typesetting_fret_diagrams
http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Common-notation-for-fretted-strings#Fret-diagram-markups
http://lilypond.org/doc/v2.12/Documentation/user/lilypond/Predefined-fretboard-diagrams
> 2) Generation of dozens of stand alone chords requires dozens of
> calls to lilypond, and, thus, terrifically slow.
> Am I right with this?
Of course LilyPond would be called for every chord if you place them
as snippets. But only once, as long as they don't change.
Wouldn't you need to call MetaPost for every diagram? (I guess in MkIV
it's a library, thus faster.)
You didn't tell us what you finally want to accomplish - in your first
post you talk only about one fret diagram.
Oh, BTW:
Can anyone explain to me, how I can implement the catcode trickery for
hyphens (in http://wiki.contextgarden.net/LilyPond#Typesetting_fret_diagrams)
in the module?
Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Building a guitar chord using MP
2010-04-10 9:56 ` Vyatcheslav Yatskovsky
@ 2010-04-10 12:30 ` Taco Hoekwater
0 siblings, 0 replies; 9+ messages in thread
From: Taco Hoekwater @ 2010-04-10 12:30 UTC (permalink / raw)
To: mailing list for ConTeXt users
Vyatcheslav Yatskovsky wrote:
>> I usually tackle this sort of thing by first drawing the entire image
>> in metapost code alone. Then, when that works, write a tex command
>> that fills in bits and pieces of the metapost image.
>
> I understand your idea. Indeed, MP code draws underlying grid. How to
> overlay circles on it using TeX? Please, an example.
First, create a metapost macro to draw a dot on a bar using two
arguments. Let's assume this is "mark(a,b)". I won't write that
metapost macro for you, you have to do that yourself.
\startuseMPgraphic{chordgrid}{e,B,G,D,A,E}
drawoptions(withpen pencircle scaled 0.4pt withcolor black) ;
draw hlingrid(0, 5, 1, 0.8cm, 1cm) ;
draw vlingrid(0, 4, 1, 1cm, 0.8cm) ;
draw mark(1,\MPvar{e});
draw mark(2,\MPvar{B});
draw mark(3,\MPvar{G});
draw mark(4,\MPvar{D});
draw mark(5,\MPvar{A});
draw mark(6,\MPvar{E});
\stopuseMPgraphic
\define[6]\Ch
{\dontleavehmode
\useMPgraphic{chordgrid}{e={#1},B={#2},G={#3},D={#4},A={#5},E={#6}}}%
\hskip2mm}
Best wishes,
Taco
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Building a guitar chord using MP
[not found] <mailman.466.1270861320.4277.ntg-context@ntg.nl>
2010-04-10 9:56 ` Vyatcheslav Yatskovsky
@ 2010-04-10 10:01 ` Vyatcheslav Yatskovsky
2010-04-10 20:26 ` Henning Hraban Ramm
1 sibling, 1 reply; 9+ messages in thread
From: Vyatcheslav Yatskovsky @ 2010-04-10 10:01 UTC (permalink / raw)
To: ntg-context
Hi Hraban
> I wouldn't use MetaPost at all (because I can't) but use LilyPond's
> great possibilities...
> (Never tried fret diagrams with the LilyPond module, but it should work.)
I thought about it, and i have two objections (maybe, false ones)
against using Lily:
1) Recently we concluded that on-the-fly insertion of Lilypond images
does not work.
2) Generation of dozens of stand alone chords requires dozens of calls
to lilypond, and, thus, terrifically slow.
Am I right with this?
--
Best Regards,
Vyatcheslav Yatskovsky
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Building a guitar chord using MP
[not found] <mailman.466.1270861320.4277.ntg-context@ntg.nl>
@ 2010-04-10 9:56 ` Vyatcheslav Yatskovsky
2010-04-10 12:30 ` Taco Hoekwater
2010-04-10 10:01 ` Vyatcheslav Yatskovsky
1 sibling, 1 reply; 9+ messages in thread
From: Vyatcheslav Yatskovsky @ 2010-04-10 9:56 UTC (permalink / raw)
To: ntg-context
> I usually tackle this sort of thing by first drawing the entire image
> in metapost code alone. Then, when that works, write a tex command
> that fills in bits and pieces of the metapost image.
I understand your idea. Indeed, MP code draws underlying grid. How to
overlay circles on it using TeX? Please, an example.
--
Best Regards,
Vyatcheslav Yatskovsky
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Building a guitar chord using MP
2010-04-09 18:05 ` Vyatcheslav Yatskovsky
2010-04-09 18:30 ` Taco Hoekwater
@ 2010-04-10 8:35 ` R. Bastian
1 sibling, 0 replies; 9+ messages in thread
From: R. Bastian @ 2010-04-10 8:35 UTC (permalink / raw)
To: ntg-context
On Fri, 09 Apr 2010 21:05:06 +0300
Vyatcheslav Yatskovsky <yatskovsky@gmail.com> scribit:
> Hello,
>
> I have interesting task. I want to build a picture of a guitar chord
> using metapost.
>
> For now, I only knew how to make a chord grid:
>
> \startreusableMPgraphic{chordgrid}
> drawoptions(withpen pencircle scaled 0.4pt withcolor black) ;
> draw hlingrid(0, 5, 1, 0.8cm, 1cm) ;
> draw vlingrid(0, 4, 1, 1cm, 0.8cm) ;
> \stopreusableMPgraphic
>
> \define[0]\ChGrid{\dontleavehmode\useMPgraphic{chordgrid}\hskip2mm}
>
> \starttext
> \ChGrid
> \stoptext
>
> I need to change it so that I could specify fret numbers, i.e. six
> numbers for each string, and draw a filled circles in these positions.
>
> I've started with a command like this
>
> \define[6]\Ch{\dontleavehmode\useMPgraphic{chordgrid}...
>
> I'm not sure what to do next... How to pass these parameters into MP,
> how to organize the loop...
>
> For a test, \Ch[1][3][1][2][1][1] should produce
>
> |-O-|---|---|---|
> |-O-|---|---|---|
> |---|-O-|---|---|
> |-O-|---|---|---|
> |---|---|-O-|---|
> |-O-|---|---|---|
>
> Please, help me with it.
Lilypond ?
>
> --
> Best Regards,
> Vyatcheslav Yatskovsky
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
> archive : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
>
--
René Bastian
www.pythoneon.org
www.musiques-rb.org
http://www.soundsurvey.org.uk/
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Building a guitar chord using MP
2010-04-09 18:30 ` Taco Hoekwater
@ 2010-04-09 20:55 ` Henning Hraban Ramm
0 siblings, 0 replies; 9+ messages in thread
From: Henning Hraban Ramm @ 2010-04-09 20:55 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 2010-04-09 um 20:30 schrieb Taco Hoekwater:
> Vyatcheslav Yatskovsky wrote:
>> Please, help me with it.
>
> I usually tackle this sort of thing by first drawing the entire image
> in metapost code alone. Then, when that works, write a tex command
> that fills in bits and pieces of the metapost image.
I wouldn't use MetaPost at all (because I can't) but use LilyPond's
great possibilities...
(Never tried fret diagrams with the LilyPond module, but it should
work.)
Greetlings from Lake Constance!
Hraban
---
http://www.fiee.net/texnique/
http://wiki.contextgarden.net
https://www.cacert.org (I'm an assurer)
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Building a guitar chord using MP
2010-04-09 18:05 ` Vyatcheslav Yatskovsky
@ 2010-04-09 18:30 ` Taco Hoekwater
2010-04-09 20:55 ` Henning Hraban Ramm
2010-04-10 8:35 ` R. Bastian
1 sibling, 1 reply; 9+ messages in thread
From: Taco Hoekwater @ 2010-04-09 18:30 UTC (permalink / raw)
To: mailing list for ConTeXt users
Vyatcheslav Yatskovsky wrote:
>
> Please, help me with it.
I usually tackle this sort of thing by first drawing the entire image
in metapost code alone. Then, when that works, write a tex command
that fills in bits and pieces of the metapost image.
Best wishes,
Taco
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Building a guitar chord using MP
[not found] <mailman.459.1270827309.4277.ntg-context@ntg.nl>
@ 2010-04-09 18:05 ` Vyatcheslav Yatskovsky
2010-04-09 18:30 ` Taco Hoekwater
2010-04-10 8:35 ` R. Bastian
0 siblings, 2 replies; 9+ messages in thread
From: Vyatcheslav Yatskovsky @ 2010-04-09 18:05 UTC (permalink / raw)
To: ntg-context
Hello,
I have interesting task. I want to build a picture of a guitar chord
using metapost.
For now, I only knew how to make a chord grid:
\startreusableMPgraphic{chordgrid}
drawoptions(withpen pencircle scaled 0.4pt withcolor black) ;
draw hlingrid(0, 5, 1, 0.8cm, 1cm) ;
draw vlingrid(0, 4, 1, 1cm, 0.8cm) ;
\stopreusableMPgraphic
\define[0]\ChGrid{\dontleavehmode\useMPgraphic{chordgrid}\hskip2mm}
\starttext
\ChGrid
\stoptext
I need to change it so that I could specify fret numbers, i.e. six
numbers for each string, and draw a filled circles in these positions.
I've started with a command like this
\define[6]\Ch{\dontleavehmode\useMPgraphic{chordgrid}...
I'm not sure what to do next... How to pass these parameters into MP,
how to organize the loop...
For a test, \Ch[1][3][1][2][1][1] should produce
|-O-|---|---|---|
|-O-|---|---|---|
|---|-O-|---|---|
|-O-|---|---|---|
|---|---|-O-|---|
|-O-|---|---|---|
Please, help me with it.
--
Best Regards,
Vyatcheslav Yatskovsky
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-04-12 21:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <mailman.501.1271102166.4277.ntg-context@ntg.nl>
2010-04-12 21:57 ` Building a guitar chord using MP Vyatcheslav Yatskovsky
[not found] <mailman.466.1270861320.4277.ntg-context@ntg.nl>
2010-04-10 9:56 ` Vyatcheslav Yatskovsky
2010-04-10 12:30 ` Taco Hoekwater
2010-04-10 10:01 ` Vyatcheslav Yatskovsky
2010-04-10 20:26 ` Henning Hraban Ramm
[not found] <mailman.459.1270827309.4277.ntg-context@ntg.nl>
2010-04-09 18:05 ` Vyatcheslav Yatskovsky
2010-04-09 18:30 ` Taco Hoekwater
2010-04-09 20:55 ` Henning Hraban Ramm
2010-04-10 8:35 ` R. Bastian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).