[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MIDI channel assignments
From: |
David Santamauro |
Subject: |
MIDI channel assignments |
Date: |
Thu, 30 Jun 2011 05:01:36 -0400 |
Hi,
it's been a while since I had time to work with LilyPond but coming
back to it I'm trying to make one tiny adjustment to MIDI output:
specify exact channel (staff/voice contexts).
I need this because, like was mentioned here:
http://lists.gnu.org/archive/html/lilypond-user/2011-05/msg00165.html
... I use sound libraries inside my sequencer and the templates I have
setup there have orchestra families on different MIDI ports
port-1
ch-1 => woodwinds/flute-general
ch-2 => woodwinds/flute-legato
port-2
ch-1 => strings/violin-1-legator
ch-2 => strings/violin-1-pizz
etc ...
What I did was simply allow: \set midiChannel = 1
I haven't done extensive testing but behavior should default to
midiChannelMapping if midiChannel is not set.
I should proababy add a warning message if channel is out of range, but
it was just a proof-of-concept.
Any interest in this from anyone else?
git diff
diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc
index bab8ae0..d649292 100644
--- a/lily/staff-performer.cc
+++ b/lily/staff-performer.cc
@@ -213,6 +213,16 @@ int
Staff_performer::get_channel (string instrument)
{
SCM channel_mapping = get_property ("midiChannelMapping");
+
+ /* allow specific designation of MIDI channel */
+ SCM ch = get_property ("midiChannel");
+ if (scm_is_number(ch))
+ {
+ int c = scm_to_int(ch);
+ if (c > 0 && c < 17)
+ return c - 1;
+ }
+
map<string, int>& channel_map
= (channel_mapping != ly_symbol2scm ("instrument"))
? channel_map_
diff --git a/scm/define-context-properties.scm
b/scm/define-context-properties.scm index dab5211..90b97d8 100644
--- a/scm/define-context-properties.scm
+++ b/scm/define-context-properties.scm
@@ -364,6 +364,7 @@ event when notes with the same pitch, in the same
MIDI-file track, overlap.") @code{midiMinimumVolume}.")
(midiMinimumVolume ,number? "Set the minimum loudness for MIDI.
Ranges from 0 address@hidden")
+ (midiChannel ,number? "MIDI channel (1-16) for Staff or Voice.
Default behavior is the default for @code{midiChannelMapping}")
(midiChannelMapping ,symbol? "How to map MIDI channels: per
@code{instrument} (default), @code{staff} or @code{voice}.")
(minimumFret ,number? "The tablature auto string-selecting mechanism
selects the highest string with a fret at least
thanks,
David
- MIDI channel assignments,
David Santamauro <=