2014-12-22 22:23 GMT+01:00 Stan Mulder <st4588...@earthlink.net>: >> How about compiling your code with >> lilypond -dpreview -dresolution=200 your-file.ly >> ? >> (or whatever resolution is apropiate) > > > Oh wow! That -dpreview trims the file nicely. I was prepared to use > ImageMagik's convert program to trim the whitespace thusly, "convert -trim > filename.png outfile.png" -- but now I don't have to do that. > > I guess the question is, since I've got to construct a lot of repetitive > lines of code for each chord, am I doing this in the most efficient manner? > This would be great for a for-loop kind of thing. Do you see any way to > simplify or automate my code? Maybe with macros, or something else? > > > \version "2.19.15" > %#(set-global-staff-size 30) > > \include "lilypond-book-preamble.ly" > \paper { oddFooterMarkup = ##f } > \include "english.ly" > %\include "predefined-plectrum-banjo-fretboards.ly" > \include "predefined-guitar-fretboards.ly" > > plec = { > %\set Staff.stringTunings = #plectrumTuning > \override FretBoard.fret-diagram-details.number-type = #'arabic > \override FretBoard.fret-diagram-details.finger-code = #'in-dot > } > > chord_C = \chordmode { c } #(define output-suffix "chord_C") \book { > << \new ChordNames { \chord_C } \new FretBoards { \plec \chord_C } >> } > chord_Cm = \chordmode { c:m } #(define output-suffix "chord_Cm") \book { > << \new ChordNames { \chord_Cm } \new FretBoards { \plec \chord_Cm } >> } > > > > > > _______________________________________________ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user
Well, below my attempt. It reads and builds all chords from 'default-fret-table' outputting them in scores. Each with ChordName- and FretBoards-context. Each score will be put out as a single book. Finally you'll get 153 books. ;) Will last some minutes ... Compiling it with lilypond -dpreview -dresolution=200 file.ly will return some unwanted additional files, they are deleted. It woud be better to not create them at all. Though, I don't know how. Known issues and warnings ;) I didn't mange to get proper descriptive names for the books. I don't know, whether those chords are complete, are there others. Please, read all comments!! \version "2.19.8" \include "predefined-guitar-fretboards.ly" fretprop = \override FretBoard.fret-diagram-details.finger-code = #'in-dot %% Get the pitches for each chord from 'default-fret-table' %% stored in a list %% Are there other chords? Stored elsewhere? #(define chrds-from-default-fret-table (map cdar (hash-table->alist default-fret-table))) %% Make an EventChord from each list of pitches from %% 'chrds-from-default-fret-table' %% Duration is hardcoded %% Store them in a list #(define my-chrds (map (lambda (pitches) (make-event-chord (map (lambda (p) (make-music 'NoteEvent 'duration (ly:make-duration 0) 'pitch p)) pitches))) chrds-from-default-fret-table)) %% Make a list of scores containing 'ChordNames' and 'FretBoards' of each %% chord from 'my-chords' #(define scrs (map (lambda (c) #{ \score { << \new ChordNames { $c } \new FretBoards { \fretprop $c } >> } #}) my-chrds)) %% Get the name of the current input-file myname = #(ly:parser-output-name parser) %% put out a book for each score %% TODO: How to get proper names for each book? %% As a poor solution, a number is added writescore = #(define-void-function (parser location) () (for-each (lambda (score i) (let* ((my-new-book (ly:make-book $defaultpaper $defaultheader score))) (ly:book-process my-new-book $defaultpaper $defaultlayout (format "~a-~a" myname (1+ i))))) ;; 'scrs' contains 153 scores!! ;; For testing comment it and uncomment the next code-line scrs ;; for testing comment the previous line and use the following list, ;; containing a single chord ;(list (first scrs)) (iota (length scrs)))) \writescore %% Compiling it with: %% lilypond -dpreview -dresolution=200 file.ly %% (or whatever resolution is apropiate) %% will result in several .eps-, .pdf- and .png-files %% %% Delete unwanted files: %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% BE VERY CAREFUL WHAT YOU DELETE !!!!!! %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% TODO: Better than deleting those files, would be not to create them at all! %% How to do? %% delete preview .eps-files #(for-each (lambda (i) (if (file-exists? (format "~a-~a.preview.eps" myname (1+ i))) (delete-file (format "~a-~a.preview.eps" myname (1+ i))))) (iota (length scrs))) %% delete preview .pdf-files #(for-each (lambda (i) (if (file-exists? (format "~a-~a.preview.pdf" myname (1+ i))) (delete-file (format "~a-~a.preview.pdf" myname (1+ i))))) (iota (length scrs))) %% delete default .pdf-files #(for-each (lambda (i) (if (file-exists? (format "~a-~a.pdf" myname (1+ i))) (delete-file (format "~a-~a.pdf" myname (1+ i))))) (iota (length scrs))) HTH, Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user