%! % % PostScript source - print blank chord diagrams for fretted instruments % % Author: A.W. Rogers % This PostScript program generates one or more pages of blank chord diagrams % for fretted string instruments. It is set up for guitar chords, but the % parameters can easily be modified for other instruments - for example, to % print mandolin chord diagrams, define /nstrings as 4 and /nfrets as 5. % % The user specifies the desired fret and string spacing (in inches), and % the program automatically determines how many diagrams can fit on each % page (ensuring that the row/column spacing is at least half the diagram % width/height). This supersedes an earlier version where the user specified % the number of rows and columns per page and the program scaled the diagrams % accordingly. % % Andrew % user-tweakable parameters /nstrings 6 def % number of strings /nfrets 4 def % number of frets (not including nut) /stringspace 0.15 def % spacing between strings (inches) /fretspace 0.25 def % spacing between frets (inches) /pagemargin 0.5 def % page margin (inches) /linewidth 0.5 def % fret/string line width (points) /nutlinewidth 1.5 def % nut line width (points) % draw chord diagram (lower left corner at current point) /drawbox { /x linewidth -0.5 mul def /xx boxwidth linewidth add def gsave currentpoint translate linewidth setlinewidth 1 1 nstrings { % draw strings /n exch 1 sub def n stringspace mul 0 moveto 0 boxheight rlineto stroke } for 1 1 nfrets { % draw frets /n exch 1 sub def x n fretspace mul moveto xx 0 rlineto stroke } for nutlinewidth setlinewidth % draw nut x boxheight moveto xx 0 rlineto stroke grestore } def % initial setup /inch {72 mul} def /stringspace stringspace inch def /fretspace fretspace inch def /pagemargin pagemargin inch def /boxheight nfrets fretspace mul def /boxwidth nstrings 1 sub stringspace mul def pagemargin pagemargin translate /pageheight 11 inch pagemargin 2 mul sub def /pagewidth 8.5 inch pagemargin 2 mul sub def % determine how many fit on a page - minimum spacing 1/2 {height|width} /ncolumns pagewidth 2 mul boxwidth 3 mul div 0.34 add cvi def /nrows pageheight 2 mul boxheight 3 mul div 0.34 add cvi def /X pagewidth boxwidth ncolumns mul sub ncolumns 1 sub div boxwidth add def /Y pageheight boxheight nrows mul sub nrows 1 sub div boxheight add def % print them 0 1 nrows 1 sub { /y exch Y mul def 0 1 ncolumns 1 sub { X mul y moveto drawbox } for } for showpage .