Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1601)

Side by Side Diff: scm/translation-functions.scm

Issue 5695058: Handling of open strings in tablature (Closed) Base URL: http://git.savannah.gnu.org/gitweb/?p=lilypond.git/trunk/
Patch Set: Correcting inconsistencies between ly/engraver-init.ly and the rest of the affected files Created 13 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « scm/define-context-properties.scm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ;;;; This file is part of LilyPond, the GNU music typesetter. 1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;; 2 ;;;;
3 ;;;; (c) 1998--2012 Han-Wen Nienhuys <hanwen@xs4all.nl> 3 ;;;; (c) 1998--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
4 ;;;; Jan Nieuwenhuizen <janneke@gnu.org> 4 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
5 ;;;; 5 ;;;;
6 ;;;; LilyPond is free software: you can redistribute it and/or modify 6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by 7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or 8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version. 9 ;;;; (at your option) any later version.
10 ;;;; 10 ;;;;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 defined-strings 269 defined-strings
270 defined-fingers 270 defined-fingers
271 minimum-fret 271 minimum-fret
272 maximum-stretch 272 maximum-stretch
273 tuning) 273 tuning)
274 "Determine the frets and strings used to play the notes in 274 "Determine the frets and strings used to play the notes in
275 @var{notes}, given @var{defined-strings} and @var{defined-fingers} 275 @var{notes}, given @var{defined-strings} and @var{defined-fingers}
276 along with @var{minimum-fret}, @var{maximum-stretch}, and 276 along with @var{minimum-fret}, @var{maximum-stretch}, and
277 @var{tuning}. Returns a list of @code{(string fret finger) lists." 277 @var{tuning}. Returns a list of @code{(string fret finger) lists."
278 278
279
280 (define restrain-open-strings (ly:context-property context
281 'restrainOpenStrings
282 #f))
279 (define specified-frets '()) 283 (define specified-frets '())
280 (define free-strings (iota (length tuning) 1)) 284 (define free-strings (iota (length tuning) 1))
281 285
282 (define (calc-fret pitch string tuning) 286 (define (calc-fret pitch string tuning)
283 "Calculate the fret to play @var{pitch} on @var{string} with 287 "Calculate the fret to play @var{pitch} on @var{string} with
284 @var{tuning}." 288 @var{tuning}."
285 (- (ly:pitch-semitones pitch) (ly:pitch-semitones (list-ref tuning (1- str ing))))) 289 (- (ly:pitch-semitones pitch) (ly:pitch-semitones (list-ref tuning (1- str ing)))))
286 290
287 (define (note-pitch note) 291 (define (note-pitch note)
288 "Get the pitch (in semitones) from @var{note}." 292 "Get the pitch (in semitones) from @var{note}."
(...skipping 30 matching lines...) Expand all
319 (define (close-enough fret) 323 (define (close-enough fret)
320 "Decide if @var{fret} is acceptable, given the already used frets." 324 "Decide if @var{fret} is acceptable, given the already used frets."
321 (if (null? specified-frets) 325 (if (null? specified-frets)
322 #t 326 #t
323 (reduce 327 (reduce
324 (lambda (x y) 328 (lambda (x y)
325 (and x y)) 329 (and x y))
326 #t 330 #t
327 (map (lambda (specced-fret) 331 (map (lambda (specced-fret)
328 (or (eq? 0 specced-fret) 332 (or (eq? 0 specced-fret)
329 (eq? 0 fret) 333 » » (and (not restrain-open-strings)
334 » » (eq? 0 fret))
330 (>= maximum-stretch (abs (- fret specced-fret))))) 335 (>= maximum-stretch (abs (- fret specced-fret)))))
331 specified-frets)))) 336 specified-frets))))
332 337
333 (define (string-qualifies string pitch) 338 (define (string-qualifies string pitch)
334 "Can @var{pitch} be played on @var{string}, given already placed 339 "Can @var{pitch} be played on @var{string}, given already placed
335 notes?" 340 notes?"
336 (let* ((fret (calc-fret pitch string tuning))) 341 (let* ((fret (calc-fret pitch string tuning)))
337 » (and (or (eq? fret 0) (>= fret minimum-fret)) 342 » (and (or (and (not restrain-open-strings)
343 » » (eq? fret 0))
344 » » (>= fret minimum-fret))
338 (close-enough fret)))) 345 (close-enough fret))))
339 346
340 (define (open-string string pitch) 347 (define (open-string string pitch)
341 "Is @var{pitch} and open-string note on @var{string}, given 348 "Is @var{pitch} and open-string note on @var{string}, given
342 the current tuning?" 349 the current tuning?"
343 (let* ((fret (calc-fret pitch string tuning))) 350 (let* ((fret (calc-fret pitch string tuning)))
344 (eq? fret 0))) 351 (eq? fret 0)))
345 352
346 (define (set-fret! pitch-entry string finger) 353 (define (set-fret! pitch-entry string finger)
347 (let ((this-fret (calc-fret (car pitch-entry) 354 (let ((this-fret (calc-fret (car pitch-entry)
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 with the subordinate symbols being interfaces." 694 with the subordinate symbols being interfaces."
688 (let loop ((forms forms)) 695 (let loop ((forms forms))
689 (if (cheap-list? forms) 696 (if (cheap-list? forms)
690 `(list 697 `(list
691 ,@(map (lambda (form) 698 ,@(map (lambda (form)
692 (if (pair? (car form)) 699 (if (pair? (car form))
693 `(cons ',(caar form) (lambda ,(cdar form) ,@(cdr form))) 700 `(cons ',(caar form) (lambda ,(cdar form) ,@(cdr form)))
694 `(cons ',(car form) ,(loop (cdr form))))) 701 `(cons ',(car form) ,(loop (cdr form)))))
695 forms)) 702 forms))
696 forms))) 703 forms)))
OLDNEW
« no previous file with comments | « scm/define-context-properties.scm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b