Replacing default MIDI instrument equalization: Difference between revisions
Appearance
Import snippet from LSR |
m Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series |
||
| Line 3: | Line 3: | ||
The following example sets the minimum and maximum volumes for flute and clarinet respectively." | The following example sets the minimum and maximum volumes for flute and clarinet respectively." | ||
<lilypond version="2.24 | <lilypond version="2.24"> | ||
#(define my-instrument-equalizer-alist '()) | #(define my-instrument-equalizer-alist '()) | ||
Revision as of 18:57, 16 November 2025
The default MIDI instrument equalizer can be replaced by setting the instrumentEqualizer property in the Score context to a user-defined Scheme procedure that uses a MIDI instrument name as its argument along with a pair of fractions indicating the minimum and maximum volumes respectively to be applied to that specific instrument.
The following example sets the minimum and maximum volumes for flute and clarinet respectively."
\version "2.24"
#(define my-instrument-equalizer-alist '())
#(set! my-instrument-equalizer-alist
(append
'(
("flute" . (0.7 . 0.9))
("clarinet" . (0.3 . 0.6)))
my-instrument-equalizer-alist))
#(define (my-instrument-equalizer s)
(let ((entry (assoc s my-instrument-equalizer-alist)))
(if entry
(cdr entry))))
\score {
<<
\new Staff {
\key g \major
\time 2/2
\set Score.instrumentEqualizer = #my-instrument-equalizer
\set Staff.midiInstrument = "flute"
\new Voice \relative {
r2 g''\mp g fis~
4 g8 fis e2~
4 d8 cis d2
}
}
\new Staff {
\key g \major
\set Staff.midiInstrument = "clarinet"
\new Voice \relative {
b'1\p a2. b8 a
g2. fis8 e
fis2 r
}
}
>>
\layout { }
\midi { }
}