Re: Is there a SIMPLE way to add a MIDI "clap" to a score w/o a drum voice or staff?

"J. G. Stalnaker" <[email protected]>
Newsgroups gmane.comp.gnu.lilypond.general
Message-ID <CACqnVhB0mUB-eNYJBcLSs5XEXkdq8R8hm0kAtJ3W+a886u41NA@mail.gmail.com>
Kevin,

Haven't seen a reply come through the list. If there has been one, I apologize,

If there hasn't been one, I think your SIMPLE request was the block.
There may be some programmatic way to get what you want (which of
course is perhaps far from simple), but I don't have the coding Scheme
knowledge and LP knowledge to help with that.  But I do know of a
fairly uncomplicated way to get what you want. The following is based
on my knowledge of LP from years of using Frescobaldi and its way to
do score orginization, e.g.,

%%%% LP %%%%
\version "2.24.0"
\include "english.ly"
voiceOne = {
%Notes
}
voiceTwo - {
%Notes
}
voiceOnePart = \new Staff \with {
  instrumentName = "voiceOne"
} { \voiceOne }
voiceTwoPart = \new Staff \with {
  instrumentName = "voiceTwo"
} { \voiceTwo }
\score {
  <<
\voiceOnePart
\voiceTwoPart
 >>
\layout { }
\midi {}
 }
%%%%%%%%

First you need to reorganize your music so it has two score blocks,
one of which ouputs only PDF and the other of which outputs only MIDI.
Something that looks like the code below. This is happily a simple
copy/paste in LP (one of the things I love about LP) then renaming
things to keep them separate. Splitting \layout{} and \midi{} like
this, lets you add things to the midi score block that won't get
printed on the PDF score ouput! I've used this to create a more
complicated midi file (duplicating voices and assigning alternative
midi instruments to them, etc.).

Now, duplicate the voice you have in which you put that Clap
diirective (in the pseudo code below note the \clapPart which is as
good a name as any). Search/Replace in this voice the notes (a, b, c,
d, e, f, g (if using English; modify as necessary)) and replace with
"s" (effectively silencing note output; can also add very long
s<measure value>*<measures>, e.g., s1*24 gets 24 measures of silence
in 4/4 time). Go to the spot in the voice where you have the Clap mark
and change the "s" to a note value that corresponds to the percussion
sound that gets you as close to a clap as possible.

I'll note that the FluidR3_GM.sf2 soundfont I use has a woodblock
sound on instrument channel 115 and this is a legit midiInstrument
name in Lilypond. So maybe test that sound before trying the more
"annoying search for a clap sound" process below.

Now the hard part: you need to confirm that the midi soundfont you use
has a percussion instrument with the right sound, map that sound to
the right channel number that matches one of LP's internal
midiInstrument names, assign that instrument name to clapVoice. E.g.,
Clap might be midi instrument 115, but LP's internal midiInstrument
name for channel 115 is woodblock. so you use your sounfont, but in LP
use "woodblock" and the midi output will have the sound in your
soundfont (I confirm this works, because I often use a soundfont of
organ sounds, none of which "exist" in LP, so I created a map of
channel numbers to map LP midiInstrument name and their channel #s to
the ones in the organ font I want to use). Looks wierd to have
"AcoustingPiano" in the LP file but have a FullConcertOrgan midi file,
but it works.

When you publish the score the "midi" score block will be used for the
midi output and it will have the clap sound you chose, but the PDF
score will not have that clapVoice part added to it.

%%%% LP %%%%
\book {
  \bookpart {
    \score {
      <<
        \sopranoPart
        \altoPart
        \tenorPart
        \bassPart
      >>
      \layout { }
    }
  }
  \bookpart {
    \score {
      <<
        \sopranoPart
        \altoPart
        \tenorPart
        \bassPart
        \clapPart
     >>
      \midi {
        \tempo 8=138
      }
    }
  }
}
%%%%%%%%

Hope this helps,

Regards,

Guy S.

--

"There is only love, and then oblivion. Love is all we have to set
against hatred." (paraphrased) Ian McEwan


On Fri, Jun 12, 2026 at 3:25 PM Kevin Cole <[email protected]> wrote:
>
> Hi,
>
> I have an instrumental score with a single clap and shout in the
> middle of it. I was able to produce the printed appearance that I want
> with:
>
> %%%%%%%%%%%%%%
> \version "2.26.0"
> \language "english"
>
> {
>   e'2 f'2                 |
>   r2 r4
>   \override NoteHead.style = #'cross
>   b'4^\markup \italic "Hey!"
>   \revert NoteHead.style  |
>   c''2 d''2               |
> }
> %%%%%%%%%%%%%%
>
> However, I'd like to have a MIDI clap at "Hey!" -- but only if adding
> such would be as short and simple as the code above.
>
> Is such a thing possible? (The documentation I found appeared overly
> complex and incomprehensible for something that would seem to be a
> common enough musical occurrence. So, I figured I was probably
> searching for the wrong thing.)
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.