\version "2.18.0" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% DESCRIPTION %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% This Code puts out several books, containing a FretBoard and the ChordName. %% The chord-definitions are taken from 'default-fret-table', others may be %% added. %% %% A simple name is added to each entry of 'default-fret-table'. %% See file "simple-chord-names.ly" %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% USAGE %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% Compiling it with: %% lilypond -dpreview -dresolution=200 file.ly %% (or whatever resolution is apropiate) %% will result in several .eps-, .pdf- and .png-files, which are deleted. %% TODO: Would be better not to create those files at all. %% Though, I don't know how. %% %% I'd recommend to create a new folder in the location, where you store these %% files, naming it "chord-images". %% Then compile with: %% lilypond --output=chord-images -dpreview -dresolution=200 chords.ly %% if you want small png-files (or whatever resolution is apropiate) %% #(use-modules (ice-9 pretty-print)) \include "simple-chord-names.ly" \include "predefined-guitar-fretboards.ly" \include "predefined-plectrum-banjo-fretboards.ly" #(define my-named-default-fret-table (map (lambda (e) (append e (list (simple-chord-names (cdar e) '() '() )) )) (hash-table->alist default-fret-table))) %#(pretty-print (take my-named-default-fret-table 2)) %% Get the pitches for each chord from 'default-fret-table' %% stored in a list, add tuning and name. %% Are there other chords? Stored elsewhere? #(define chords-and-tunings-and-names (map (lambda (e) (list (cdar e) (caar e) (last e))) my-named-default-fret-table)) %#(newline) %#(pretty-print (car chords-and-tunings-and-names)) %% Make an EventChord from each list of pitches from %% 'my-named-default-fret-table' %% Duration is hardcoded %% Store them in a list, add tuning and name. #(define my-chrds-and-tunings-and-names (map (lambda (x) (list (make-event-chord (map (lambda (p) (make-music 'NoteEvent 'duration (ly:make-duration 0) 'pitch p)) (car x))) (second x) (last x))) chords-and-tunings-and-names)) %#(newline) %#(display-scheme-music (car my-chrds-and-tunings-and-names)) %% Make a list of scores containing 'ChordNames' and 'FretBoards' of each %% chord from 'my-chords', add tuning and name. fretprop = \override FretBoard.fret-diagram-details.finger-code = #'in-dot #(define scrs-with-tunings-and-names (map (lambda (c) (list #{ \score { << \new ChordNames { $(car c) } \new FretBoards { \set Staff.stringTunings = #(second c) \fretprop $(car c) } >> } #} (second c) (last c))) my-chrds-and-tunings-and-names)) %% Get the name of the current input-file %myname = #(ly:parser-output-name parser) %% put out a book for each score %% A simple descriptive name is added to the file-name writebooks = #(define-void-function (parser location) () (for-each (lambda (score) (let* ((my-new-book (ly:make-book $defaultpaper $defaultheader (car score))) (naming (format "~a-~a-~a" (cond ((eq? (second score) plectrumTuning) "banjo") ((eq? (second score) guitar-tuning) "guitar") (else "")) "chord" (last score)))) (display "\n\n")(pretty-print naming) (ly:book-process my-new-book $defaultpaper $defaultlayout naming) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; Delete unwanted files: ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; BE VERY CAREFUL WHAT YOU DELETE !!!!!! ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; comment the code which deletes a file-type, if you want to keep it ;; delete preview .eps-files (for-each (lambda (i) (if (file-exists? (format "~a.preview.eps" naming)) (delete-file (format "~a.preview.eps" naming)))) (iota (length scrs-with-tunings-and-names))) ;; delete preview .pdf-files (for-each (lambda (i) (if (file-exists? (format "~a.preview.pdf" naming)) (delete-file (format "~a.preview.pdf" naming)))) (iota (length scrs-with-tunings-and-names))) ;; delete preview .png-files ;(for-each ; (lambda (i) ; (if (file-exists? (format "~a.preview.png" naming)) ; (delete-file (format "~a.preview.png" naming)))) ; (iota (length scrs-with-tunings-and-names))) ;; delete default .pdf-files (for-each (lambda (i) (if (file-exists? (format "~a.pdf" naming)) (delete-file (format "~a.pdf" naming)))) (iota (length scrs-with-tunings-and-names))) )) ;; 'scrs-with-tunings-and-names' contains 235 scores!! ;; For testing comment it and uncomment the next code-line scrs-with-tunings-and-names ;; for testing comment the previous line and use the following list, ;; containing a single chord ;(list (first scrs-with-tunings-and-names)) )) \writebooks