Re: Adding metronome click track to MIDI

2020-06-04 Thread Matt Wallis

On 03/06/2020 15:55, Francesco Petrogalli wrote:

Hi all,

I need to add  a metronome click sound to the MIDI generated with
lilypond, to allow people sync up a record-from-home session. A quick
web search didn't bring up anything that I could have used. Is there a
special midi instrument I could use for that?


Hi Francesco,

The solution I use for click tracks uses this:

https://lists.gnu.org/archive/html/lilypond-user/2019-12/msg00346.html

That will give you a definition of clickTrackForMusic. All you need to 
do then is to provide the time signature and the music.


When I use it I do this:

-

clickPart = \clickTrackForMusic \timeSignature \music

% Click track:
clickStaff = \new DrumStaff = "click" {
  \set DrumStaff.instrumentName = #"Click "
  \clickPart
}

-

It automatically adjusts the length of the click track to the length of 
the music, but does not handle changes of time signature or tempo.


Matt





Re: Adding metronome click track to MIDI

2020-06-04 Thread Valentin Villenave
On 6/4/20, Francesco Petrogalli  wrote:
> thank you both for your help. I have created a solution based on your
> examples. I hope you don't mind the copy and paste + tweak exercise,

Hey, that’s what the list is for!  Also, I’ve uploaded a copy of my
own function onto http://lsr.di.unimi.it/LSR/Item?id=1114 which makes
it Public Domain.

> The code that works for me is the following, I will merge it when I
> get an "OK go" from both of you:
> https://github.com/fpetrogalli/trr/pull/1/files

Note that if you’re using a \score block specially for MIDI output,
then you don’t need a Devnull, you could simply use a \new Staff or
\new DrumStaff and therefore you’d no longer need all the \consists
lines.

Or even shorter, instead of \new whatever, you can just type
  \drums \repeat unfold 83 {wbh4. trim4. trim4. trim4.}
which also removes the need for midiInstrument and \drummode.

> The `unfold 83` is a bit ugly, but it allows me to obtain what I need
> without having to dig into lilypond internals and scheme syntax.

I can understand that!  Also note that the <>\ff is just for dynamics
(to make the clicks louder) so whether you want to keep it or not, is
up to you.

Cheers,
-- V.



Re: Adding metronome click track to MIDI

2020-06-03 Thread Francesco Petrogalli
Robin, Valentin,

thank you both for your help. I have created a solution based on your
examples. I hope you don't mind the copy and paste + tweak exercise,
as I am assuming that you are happy for me to give a CC BY SA 4.0
license to code that is based on the examples you have published in
the mailing list. FWIW, I have credited both of you in the commit
messages. Please let me know if my assumption is correct. Conversely,
if you rather not have this code included in the source of this open
source project, I will remove it and try to find an alternative
solution. [*]

The code that works for me is the following, I will merge it when I
get an "OK go" from both of you:

https://github.com/fpetrogalli/trr/pull/1/files

The `unfold 83` is a bit ugly, but it allows me to obtain what I need
without having to dig into lilypond internals and scheme syntax.

Kind regards,

Francesco

[*] Admittedly, I should have dont this the other way around, first
ask about using your code, and then including it into my project on
github. Hopefully what I have done, although not formally correct, is
in line with the open source spirit of the lilypond community in terms
of sharing snippets and examples.

On Wed, Jun 3, 2020 at 11:04 AM Valentin Villenave
 wrote:
>
> On 6/3/20, Francesco Petrogalli  wrote:
> > Is there a special midi instrument I could use for that?
>
> Not that I know.
> BTW, here’s a quick-and-dirty way of adding a click track, in case you
> might find it useful:
>
> %%
>
> addTicks =
> #(define-music-function (m) (ly:music?)
>#{ << $m
>  \new Devnull \with {
>\consists Drum_note_performer
>\consists Staff_performer
>\consists Dynamic_performer
>midiInstrument = #"woodblock"
>  } \drummode {
><>\ff \repeat unfold
>$(ly:moment-main-numerator
>  (ly:moment-div
>   (ly:music-length m)
>   (ly:make-moment 1 4)))
>rb4 }>> #})
>
> music = \relative  c' { c2 d e f g a b c }
>
> \score {
>   \new Staff \addTicks \music
>   \layout {}
>   \midi {}
> }
>
> 
>
> Cheers,
> -- V.



Re: Adding metronome click track to MIDI

2020-06-03 Thread Valentin Villenave
On 6/3/20, Francesco Petrogalli  wrote:
> Is there a special midi instrument I could use for that?

Not that I know.
BTW, here’s a quick-and-dirty way of adding a click track, in case you
might find it useful:

%%

addTicks =
#(define-music-function (m) (ly:music?)
   #{ << $m
 \new Devnull \with {
   \consists Drum_note_performer
   \consists Staff_performer
   \consists Dynamic_performer
   midiInstrument = #"woodblock"
 } \drummode {
   <>\ff \repeat unfold
   $(ly:moment-main-numerator
 (ly:moment-div
  (ly:music-length m)
  (ly:make-moment 1 4)))
   rb4 }>> #})

music = \relative  c' { c2 d e f g a b c }

\score {
  \new Staff \addTicks \music
  \layout {}
  \midi {}
}



Cheers,
-- V.



Re: Adding metronome click track to MIDI

2020-06-03 Thread Robin Bannister

Francesco Petrogalli wrote:


I need to add  a metronome click sound to the MIDI generated with
lilypond, to allow people sync up a record-from-home session.


Here is a clock ticking:  {wbh4 trim4 wbl4 trim4}


Cheers,
Robin