On Tue 25 May 2010, 13:00 David Raleigh Arnold wrote: > Sometimes you want to move some lilypond notes quick. This bash script > does it. It requires sed and xsel. A windows version should be similar. > If for some reason there is a problem, octava-up.sed and ottava-down.sed > may be moved. The '"'"' makes perfect sense, eventually, but it's > gnarly. Regards, daveA I'd say, doing this in Scheme is a much better thing in some cases --- it is "rollbackable" easily, configurable and so on. In some cases :-)
As for me :-) I wrote for myself some function to octaviate up or down those pitches, which are below or above some position specified (as a distance from middle C) --- it's based on http://lsr.dsi.unimi.it/LSR/Item?id=445 (but seems to process chords correctly, does not produce doubled pitches (prima)). Now i've just modified (stripped down) it to move those pitches up or down, deleting original pitch while moving, see attached. Again, a "threshold" is a distance from middle C. I wish i did it smarter, probably (one tool to octaviate/move, with selective pitch deletion in a chords) --- but i am not sure i need it actually. Well, it does not add ties, i've added it to \mel where wanted .) > > :::::::::::::::::::::::::::::::::::::::::::::::::::::::: > > #!/bin/bash > # ottava > # sed and xsel must be installed. -- Dmytro O. Redchuk
<<attachment: octaviateIf.png>>
% % Based on: % http://lsr.dsi.unimi.it/LSR/Item?id=445 % % Also helped: % http://lsr.dsi.unimi.it/LSR/Item?id=266 % #(set-global-staff-size 16) #(define (octave-shift note step) "Shift octave for note by step." (let* ((new-note (ly:music-deep-copy note)) (new-pitch (ly:make-pitch (+ step (ly:pitch-octave (ly:music-property note 'pitch))) (ly:pitch-notename (ly:music-property note 'pitch)) (ly:pitch-alteration (ly:music-property note 'pitch))))) (set! (ly:music-property new-note 'pitch) new-pitch) new-note)) #(define (no-octaved-pitch? elements pitch) "Checks if 'target' pitch does exist in elements." (if (null? elements) #t (let ((p (ly:music-property (car elements) 'pitch))) (if (and (eq? (ly:music-property (car elements) 'name) 'NoteEvent) (eqv? (ly:pitch-octave pitch) (ly:pitch-octave p)) (eqv? (ly:pitch-notename pitch) (ly:pitch-notename p)) (eqv? (ly:pitch-alteration pitch) (ly:pitch-alteration p))) #f (no-octaved-pitch? (cdr elements) pitch))))) #(define (octaviate-chord elements oct-step thresh) "Walks through elements 'NoteEvent by 'NoteEvent and octaviates pitch by oct-step if this pitch 'exceeds' given threshold and there is no pitch in a chord which (pitch) equals to 'target' pitch." (let ((exceeds? (if (< 0 oct-step) < >)) (whole-chord elements)) (let loop ((elts elements)) (cond ((null? elts) elts) ((and (eq? (ly:music-property (car elts) 'name) 'NoteEvent) (exceeds? (ly:pitch-steps (ly:music-property (car elts) 'pitch)) thresh) (no-octaved-pitch? whole-chord (ly:music-property (octave-shift (car elts) oct-step) 'pitch))) (cons (octave-shift (car elts) oct-step) (loop (cdr elts)))) (else (cons (car elts) (loop (cdr elts)))))))) #(define (octaviate music oct-step thresh) (if (eq? (ly:music-property music 'name) 'EventChord) (ly:music-set-property! music 'elements (octaviate-chord (ly:music-property music 'elements) oct-step thresh))) music) makeOctaves = #(define-music-function (parser location step thresh mus) (integer? integer? ly:music?) (music-map (lambda (x) (octaviate x step thresh)) mus)) octaviateUpIfExceeds = #(define-music-function (parser location thresh mus) (integer? ly:music?) #{ \makeOctaves #1 #$thresh $mus #}) octaviateDownIfExceeds = #(define-music-function (parser location thresh mus) (integer? ly:music?) #{ \makeOctaves #-1 #$thresh $mus #}) melOne = \relative c, { <dis dis'>8( e dis')~ dis8.( cis16 b8 \times 2/3 { ais' ~ ais, gis' } dis) cis( dis <dis dis''>) } \relative c' { \clef "bass" \time 3/8 \key gis \minor % \override Score.RehearsalMark #'self-alignment-X = #LEFT % \mark\markup "As is" \melOne \break % \mark\markup "Up if below -6" \octaviateUpIfExceeds #-6 \melOne \break % \mark\markup "Down if above -6" \octaviateDownIfExceeds #-6 \melOne \break % \mark\markup "Down then Up" \octaviateUpIfExceeds #-6 \octaviateDownIfExceeds #-6 \melOne } \paper { indent = 0 line-width = 10\cm } \header { tagline = "" } % vim: set ts=2:
_______________________________________________ lilypond-user mailing list [email protected] http://lists.gnu.org/mailman/listinfo/lilypond-user
