Is there a way to get a "round" to play in the MIDI without making several staggered identical voices?

2023-09-20 Thread Kevin Cole
I'm not quite sure how to ask the question.

Is there a way to play the same melody as different voices with different
time offsets -- i.e. without duplicating it and adding rests at the
beginnings of the duplicates? (I only want it in the MIDI part, as the
printed part would only need to display the basic melody once.)


Re: Is there a way to get a "round" to play in the MIDI without making several staggered identical voices?

2023-09-20 Thread Henning Hraban Ramm

Am 20.09.23 um 15:37 schrieb Kevin Cole:

I'm not quite sure how to ask the question.

Is there a way to play the same melody as different voices with 
different time offsets -- i.e. without duplicating it and adding rests 
at the beginnings of the duplicates? (I only want it in the MIDI part, 
as the printed part would only need to display the basic melody once.)


You mean like a round?

I split the melody into single parts (entries) and re-combine them 
differently for layout and midi.

See attachment.

Hraban\version "2.22.0"
%\include "../global.ly"
\include "articulate.ly" % für besseres MIDI

\header{
  title = "Hejo, spann den Wagen an"
  poet = "mündl. überl."
  %composer = "M: "
  %arranger = "arr."
  %instrument = "2 voc + git"
  source = "Codex Patomomomensis"
  %maintainer = "Henning Hraban Ramm"
  %maintainerWeb = "http://angerweit.tikon.ch/lieder/";
  lastupdated = "2015-10-05"
}


global = {
  \clef treble
  \key b \minor
  \time 4/4
}

akkorde = \chordmode {
  \repeat unfold 6 {
e2:m b:m
  }
}

dynamics = \relative c {
  r4\mp
}

einsatzI = \relative c' {
  e2^\markup{1.} d | e8 e e e b2 |
}

einsatzII = \relative c' {
  e4^\markup{2.} e fis fis | g8 g g g fis2 |
}

einsatzIII = \relative c'' {
  b8^\markup{3.} b b b b4 b | b8 b b b b( a) g( fis)
}


einsatzIIIend = \relative c'' {
  b8^\markup{3.} b b b b4 b | b8 b b b b4 b
}


oberstimme = \relative c' {
  \einsatzI
  \einsatzII
  \einsatzIII
  \bar ":|."
}

einsatzLeer = \relative c' { s1 s }

textI = \lyricmode {
  %\set stanza = "1. "
  He -- jo, spann den Wa -- gen an,
  denn der Wind treibt Re -- gen ü -- bers Land.
  Hol die gold -- nen Gar -- ben,
  hol die gold -- nen Gar -- ben.
}

% Papier-Ausgabe
\score {
  \transpose e a
  <<
\context ChordNames {
  \akkorde
}
\context Staff = Oben <<
  \global
  \context Voice = "eins" \oberstimme
>>
\new Lyrics \lyricsto "eins" { \textI }
  >>
  \layout { }
}
\markup{ \vspace #2.0 }
\markup {
  \fill-line {
\hspace #0.1 % Abstand vom linken Rand
\column {
  \line {
"de"
\column {
  "Hejo, spann den Wagen an,"
  "denn der Wind treibt Regen übers Land."
  "Hol die goldnen Garben,"
  "hol die goldnen Garben."
  %"‿"
}
  }
  \vspace #1.5 % Abstand zwischen Strophen
  \line {
"–"
\column {
  "Blut, Blut, Räuber saufen Blut."
  "Mord und Brand und Pulverdampf sind gut."
  "Hoch vom Galgen wimmert’s,"
  "hoch vom Galgen wimmert’s."
}
  }
}
\hspace #0.5  % Abstand zwischen Spalten
\column {
  \line {
"en"
\column {
  "Hey ho, anybody home?"
  "Food and drink and money have I none."
  "Yet I will be merry,"
  "yet I will be merry."
}
  }
}
\hspace #0.1 % Abstand zum rechten Rand
  }
}

% MIDI
\score {
  \unfoldRepeats {
\transpose e a
<<
  \set Score.midiReverbLevel = #0.5
  \set Score.midiChorusLevel = #0.5
  \context Staff = "chords" <<
\set Staff.midiInstrument = "fx 4 (atmosphere)"
\context Voice = "vchords" {
  \transpose c c, << \dynamics \akkorde >>
}
  >>
  \context Staff = oberI <<
\articulate
\set Staff.midiInstrument = "recorder"
\set Staff.midiPanPosition = #-0.5
\set Staff.midiBalance = #-0.5
\context Voice = "vober" {
  \repeat unfold 3 { \oberstimme }
  \einsatzI \einsatzII
}
  >>
  \context Staff = oberII <<
\articulate
\set Staff.midiInstrument = "viola"
\set Staff.midiPanPosition = #0.75
\set Staff.midiBalance = #0.75
\context Voice = "vober" {
  \einsatzLeer
  \repeat unfold 3 { \oberstimme }
  \einsatzI
}
  >>
  \context Staff = oberIII <<
\articulate
\set Staff.midiInstrument = "voice oohs"
\set Staff.midiPanPosition = #0.25
\set Staff.midiBalance = #0.25
\context Voice = "vober" {
  \einsatzLeer \einsatzLeer
  \repeat unfold 2 { \oberstimme }
  \einsatzI \einsatzII \einsatzIIIend
}
  >>
>>
  }
  \midi {
\tempo 4 = 120
  }
}


Re: Array variables and loops (for lyrics)

2023-09-20 Thread Mauro Levra

On 17/09/2023 00:11, Jean Abou Samra wrote:

Is is possible to conditionally execute the #@ expression based on
whether the 'textArray' variable is bound?



\version "2.24.2"

textArray = <<
   { \lyricmode { \set stanza = "1" fo -- o bar } }
   { \lyricmode { \set stanza = "2" fo -- o bar } }




\score {
   <<
 \new Voice = "soprano" { c'1 1 1 }
 #@(if (defined? 'textArray)
   (map (lambda (mus) #{ \new Lyrics { \lyricsto "soprano" { #mus } } 
#})
(ly:music-property textArray 'elements))
   '())
   >>
}




Thank you very much Jean.

I was missing the '().
Without the empty '() in the else branch, when the if condition is false 
nothing is returned to the #@ operator.




Re: Array variables and loops (for lyrics)

2023-09-20 Thread Jean Abou Samra
Le mercredi 20 septembre 2023 à 20:37 +0200, Mauro Levra a écrit :
> Without the empty '() in the else branch, when the if condition is false 
> nothing is returned to the #@ operator.


Well, that “nothing” actually is something — it's *unspecified* , a
special value used in Guile when a value is expected but there
is no useful value to return. *unspecified* is not a list, thus
#@ doesn't like it because #@ inserts elements from a list, so
it expects a list. As a result, you indeed have to use the empty
list '() as a fallback.



signature.asc
Description: This is a digitally signed message part


Re: Is there a way to get a "round" to play in the MIDI without making several staggered identical voices?

2023-09-20 Thread H. S. Teoh
On Wed, Sep 20, 2023 at 09:37:27AM -0400, Kevin Cole wrote:
>I'm not quite sure how to ask the question. 
>Is there a way to play the same melody as different voices with different
>time offsets -- i.e. without duplicating it and adding rests at the
>beginnings of the duplicates? (I only want it in the MIDI part, as the
>printed part would only need to display the basic melody once.)

Assign the music to a variable, and reuse it multiple times:

myMusic = {
... % music notes here
}

% Printed score
\score {
\new Staff {
\myMusic
}
\layout {}
}

% MIDI
\score {
<<
\new Staff {
\myMusic
}
\new Staff {
R1  % whatever time offset you want here
\myMusic
}
\new Staff {
R1*2% deeper time offset
\myMusic
}
>>
\midi {}
}


T

-- 
"The whole problem with the world is that fools and fanatics are always so 
certain of themselves, but wiser people so full of doubts." -- Bertrand 
Russell. "How come he didn't put 'I think' at the end of it?" -- Anonymous