> Date: Thu, 14 Aug 2003 22:34:30 +0200 (CEST)
> From: Martin Tarenskeen <[EMAIL PROTECTED]>
> 
> Despite the computer age and all those wonderfull abc tools, I still use a
> lot of old-fashioned music paper. Today I used abcm2ps to make printable
> empty music paper. With %%scale I can even make big size staves (for my
> very young piano pupils).
> 
> X:1
> M:none
> K:C clef=none
> x
> x
> x
> x
> % and so on. As much as fit on one page
> 
> Of course abcm2ps is giving a lot of "underfull" messages... :-)
> 
> When I have studied the docs about Postscript that some of you recommended
> to me, I will probably not need abc anymore to create empty musicpaper. It
> will probably take very few lines of simple PS code to do this.
> 
> Martin Tarenskeen

I had the same thought a while back and did exactly that.

Here's my PostScript file for generating staffpaper.  Have fun with it.
It should give you some insight into how PostScript works as well as
giving you some configurable staff paper.  The "grouping" variable
defines how many staves should be bracketed together.

Jeff


%!
%
% Last modified: 2003/02/05 00:59:26 by [EMAIL PROTECTED]
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Units of measure.  Don't modify these.                               %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% define units of measure

/point {} def                   % 1 pt = 1 pt
/inch {72 mul} def              % 1 in = 72 pt
/mm {72 mul 25.4 div} def       % 1 mm = (1/25.4) in = (72/25.4) pt
/cm {72 mul 2.54 div} def       % 1 cm = (1/2.54) in = (72/2.54) pt

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% User-Configurable Data:                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

/linespacing {5 point} def              % distance between lines

/leftmargin {0.75 inch} def             % left margin
/rightmargin {0.75 inch} def            % right margin 
/bottommargin {0.75 inch} def           % bottom margin
/topmargin {0.75 inch} def              % top margin

/grouping {1} def                       % group this many staves together

/papersize {(letter)} def               % size of paper

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Defining macros and other non-user-configurable items                %
% Don't change anything below here unless you know what you're doing!  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

/staffspacing {linespacing 9 mul} def   % staffspacing proportional to
                                        % linespacing

/groupspacing {0.5} def                 % spacing between groups
                                        % fraction of staffspacing

linespacing 32 div setlinewidth         % thickness of lines (points)
                                        % = 0.25 pt for 8pt spacing

0 bottommargin staffspacing sub translate               % define bottom of page

% fix value of grouping if someone sets it to a nonsensical number
grouping 1 lt { /grouping {1} def } if

grouping 1 eq { /groupspacing {0} def } if

papersize (letter) eq                   % dimensions of letter paper
    {
        /pagewidth {8.5 inch} def
        /pageheight {11 inch} def
    } if

papersize (legal) eq                    % dimensions of legal paper
    {
        /pagewidth {8.5 inch} def
        /pageheight {14 inch} def
    }

papersize (A4) eq                       % dimensions of A4 paper
    {
        /pagewidth {210 mm} def
        /pageheight {296 mm} def
    } if

/pageavail {                    % available space on page 
    pageheight topmargin sub bottommargin sub
} def

/groupsize {                    % size of each group (including groupspacing)
    grouping groupspacing add staffspacing mul
} def

/groupsonpage {                 % tentative number of groups on page
    pageavail groupspacing staffspacing mul add groupsize div floor
} def

/staff {
  % draw horizontal lines
    0 leftmargin add 0 moveto
    pagewidth rightmargin sub 0 
    lineto
    stroke

    0 leftmargin add 0 linespacing add moveto
    pagewidth rightmargin sub 0 linespacing add
    lineto
    stroke

    0 leftmargin add 0 linespacing 2 mul add moveto
    pagewidth rightmargin sub 0 linespacing 2 mul add
    lineto
    stroke

    0 leftmargin add 0 linespacing 3 mul add moveto
    pagewidth rightmargin sub 0 linespacing 3 mul add
    lineto
    stroke

    0 leftmargin add 0 linespacing 4 mul add moveto
    pagewidth rightmargin sub 0 linespacing 4 mul add
    lineto
    stroke

%% Uncomment the following section to draw a barline at the left side
%% of each staff

%    % draw left bar line
%    0 leftmargin add 0 moveto
%    0 leftmargin add 0 linespacing 4 mul add 
%    lineto
%    stroke

%% Uncomment the following section to draw a barline at the right side
%% of each staff

%  % draw right bar line
%    pagewidth rightmargin sub 0 moveto
%    pagewidth rightmargin sub 0 linespacing 4 mul add
%    lineto
%    stroke
} def

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Draw the staves                                                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

1 1 groupsonpage {

    1 1 grouping {
        staffspacing mul 0 exch
        gsave translate
            staff
        grestore
    } for

    grouping 1 gt {

%% Uncomment the following section to draw a barline at the right side
%% of each grouping of staves

%      % draw bar line at right side of each staff
%       pagewidth rightmargin sub staffspacing moveto
%       pagewidth rightmargin sub linespacing 4 mul 
%       groupsize add groupspacing staffspacing mul sub
%       lineto stroke

      % draw left side bracket

      % thin line
        0 leftmargin add staffspacing moveto
        0 leftmargin add linespacing 4 mul 
        groupsize add groupspacing staffspacing mul sub
        lineto stroke

      % thick line
        linespacing 3 div setlinewidth
        0 leftmargin add linespacing 2 div sub staffspacing moveto
        0 leftmargin add linespacing 2 div sub linespacing 4 mul 
        groupsize add groupspacing staffspacing mul sub
        lineto
        stroke

      % bottom curly thingy on end of thick line
        linespacing 12 div setlinewidth

        0 leftmargin add linespacing 13 mul 12 div add
        linespacing 2 div sub staffspacing linespacing -1 mul add moveto
        0 leftmargin add
        linespacing 2 div sub staffspacing linespacing -1 mul add
        linespacing 13 mul 12 div 0 90 arc stroke

      % top curly thingy on end of thick line

        0 leftmargin add linespacing 12 div add
        linespacing 2 div sub linespacing 4 mul 
        groupsize add groupspacing staffspacing mul sub
        moveto
        0 leftmargin add
        linespacing 2 div sub linespacing 4 mul 
        groupsize add groupspacing staffspacing mul sub linespacing add
        linespacing 13 mul 12 div 270 0 arc stroke

        linespacing 32 div setlinewidth
    } if

  % move up by value of groupspacing
    0 staffspacing grouping mul staffspacing groupspacing mul add translate 

} for

showpage
To subscribe/unsubscribe, point your browser to: http://www.tullochgorm.com/lists.html

Reply via email to