Thursday, November 26, 2015

Some thoughts on automatic playing of trills

With its version 2.75, the Noteworthy Composer score-writing software supports a plug-in concept called "Objects." Among the objects provided so far by various people is one that will play trills, written by Mike Shawaluk. This triggered my to think a little bit about "the generalized trill:" What would be a sensible set of parameters that control how a trill is played?

I think I can contribute a little bit to this because I am one of the—probably not too numerous—people who "design trills" for real instruments: When I arrange for crank and other mechanical instruments, I have to painstakingly lay out the separate notes that are played, with exact duration and speed. A little bit of this is explained here, but of course that text still assumes that there is a "human trill manufacturer." The extension of these thoughts to "automatic trill manufacturing" is the goal of this pamphlet.


An example


Before I try to say a little bit about my ideas of a trill's parameters, one should of course look at—and listen to—at least a few examples. To this end, I selected—for no particular reason—the beginning of Jeremiah Clarke's "Prince of Denmark's March" (also known as "Trumpet Voluntary") and ornamented it with nine trills. Here is the score:


The original score for harpsichord can be seen in this score on IMSLP on page 13 (the 18th page in the PDF). That score from the year 1700 contains, by the way, an interesting section "Rules for Graces" which I will completely ignore for reasons explained below.

I will "design" the first trill for Clarke's march in detail in the next section, but I'd like to present an, in my opinion, acceptable expansion of all the trills just to show how complex such simple trills may become. In a later section, I will explain for a few of these trills why I "designed" them as I did (clicking on the notes will play an MP3 file):



The scope of this discussion: Deciding on the note lengths, not the notes


My discussion (and algorithm) is concerned with assigning lengths to the notes that are played during trill so that the trill "sounds good."

I do not consider how these notes are "correctly selected." Especially, my discussion here is not (at all) about writing "historically correct" trills. In the piano example above, the notes in the trills above may or may not be acceptable for Jeremiah Clarke's march regarding our historical knowledge of trills in the 17th century (in this case, we know that the piano trills are definitely against the rules of the time, as these are laid out in the score as mentioned above). Rather, I assume that the performer has decided on the notes in the trill "according to her or his artistic taste" beforehand; and now has the problem to decide on the precise note lengths for each and every note in the trill so that they will create a "good sounding trill." This important step is usually ignored by texts on trills. It is often added as a footnote or in an appendix in scores either for beginners, or when "special trills" do occur. But virtually always, the descriptions given there are only very crude approximations to what is really played—almost always, all the notes in the various parts of a trill (the preparation, the shake proper, and the termination) are shown as being of equal length, which is usually wrong: A standard trill typically starts a little slow in the preparation, has a continuous speed in the shake, and finally either speeds up or slows down a little in the termination. Capturing these variations manually, and then algorithmically will be the topic of the next sections.


Working out a trill


Let me write out the first trill of this melody in single notes. For this, we have to select a few "structural" parameters:
  • Should the shake of the trill (i.e., the two quickly alternating notes in the trill) start with the main note, or with an auxiliary note?
  • What is the secondary note, or equivalently, what is interval of the shake?
  • Should there be an explicit preparation, i.e., a non-trilling start?—this could be a longer holding note before the proper trill begins, or a short scale (2 or 3 grace notes) leading into the trill.
  • What should the final notes—the termination—of the trill look like? Typical possibilities include again a longer note or a turn (playing once around the main note).
I will not talk about how to answer these questions. They have been covered more or less in many tractates over the centuries—especially the question of the starting note of a trill. However, we should think a little bit about how the answers are described in a score, which is the precondition to playing them automatically as desired by the composer or arranger. In printed scores, three variations are used and combined, as far as I can see:
  • There is no indication at all—the selection of preparation or starting note as well as termination is (thought to be) understood by everyone according to "well-known" rules.
  • Grace notes indicate special wishes of the composer or arranger.
  • Some other markings are used, e.g., a "turn" mark (lying S) near the "tr" indicating that the trill should end with a turn.
For the demonstration trill, I have decided that the playing instrument is a piano, and "therefore" I start with the main note (i.e., I use J.Hummel's arguments from 1828). The two grace notes at the end are interpreted—as is usual—to mean that the trill should end with a turn.

Here is a first attempt to expand this trill to thirtysecond notes. The turn at the end is a little slower than the trill (clicking on all subsequent score sections will start a corresponding MP3 file):


I am not at all happy with this: This is simply too fast.

Here is a second attempt with sixteenth notes and now a turn that is a little faster than the trill:


This one is definitely too slow.

Here is a third attempt, derived from the fast version, but this time with a somewhat slower preparation—maybe this "leads" the ear into the fast trilling:


Well ... the somewhat slower preparation does help a little, but the speed of the shake is simply too high.

The fourth version uses an intermediate triplet tempo. Again, the preparation is a little bit slower (normal sixteenths):


Now this sounds reasonable! Still, I'd like one more tweak: In the termination, I'd like to "slow down" a little. I do this by making the last note again a complete sixteenth. For compensation, two of the turn notes get even faster:


With much concentration, you might hear the small difference—an ordinary listener would probably not be able to distinguish the two versions.


More trills and some musical justification of their expansions


I have already shown an expansion of the 8 bars of Clarke's march at the beginning. Here are two more expansions of the trills, this time more in line with what we know about trill playing in Clarke's times insofar that the trills now start on the auxiliary note above the trill's main note. The first expansion is for a "lovely flute:"


Here are some thoughts on the design of the first trill: The slightly longer notes in the preparation and, even more so, starting the trill on the auxiliary note give the beginning of this trill a huge stress: We hear very distinctly that this note is important in some way. The fast shake is then actually somewhat relaxing. Even more so, the notes in the termination are again a tiny bit longer than the shake notes, reducing their "power" so that they "glide" into the following long note (in measure 2), thereby stressing that note. I am not quite sure how a trill can, at the same time, stress a note, but then stress the subsequent note even more: But this is evidently what happens here with the G in measure 1 and the following A in measure 2. Similar effects can be heard with the other longer trills.

Here is another possibly expansion of the same trills, this time from (or for) a more "aggressive flute player:"


I do not know whether you like the "lovely flute" or the "aggressive flute" more—but certainly both are legitimate or at least musically possible expansions of the trills in the first score.

What can be seen from the scores—and has been explained somewhat more extensively in the previous section—is that a trill by no means consists of notes of equal length. Rather, the trill in itself needs a complex structure to give a satisfying musical experience. The question is whether one can create such "nice" or at least "acceptable" trills from only a few parameters, instead of painstakingly writing out all the single notes.


Parameters for playing a trill


The above trills were all hand-crafted by me, as a "benchmark" against which I could test automatically created trills. How can one create similar trills "from a set of rules," as is the case in a program? Obviously, the "structural parameters" mentioned above are always necessary:
  • What is the trill's main note?
  • What is the trill's interval?
  • Is the starting note the main note of the trill or the auxiliary note?
  • What are the notes of the preparation, if any?
  • And what are the notes of the termination, if any?
Additionally, we need at least one tempo parameter, namely
  • What is the length of a single note in the shake?
However, the examples above show that we need some more parameters to control the tempo of the various notes. What is needed, what is superfluous? Here is my suggestion:
  • For each note in the preparation and the termination, we need an additional factor relating the length of this note to the standard note length in the shake.
With these parameters, I now try to generate the trills in Clarke's march.


Automatic trill generation


I have written a small experimental Lua program that takes, as input, a "trill definition" containing the parameters given above. The output is a Noteworthy Composer clip that can be pasted into a score to have the trill played. You can download the commented source of the Lua program here; currently, it takes hardwired Lua structures as input and writes its result to the standard output via print.

Here is the definition of the first trill:


  twoNotePreparationB2 = {
       { deltaPitch = 0, stretch = 1.3 },
       { deltaPitch = 2, stretch = 1.3 }
     }
  threeNoteTermination2 = {
       { deltaPitch = 0, stretch = 0.9 },
       { deltaPitch = -2, stretch = 0.9 },
       { deltaPitch = 0, stretch = 1.1 }
     }

  printTrillNotes({
     zeroPitch = 71,
     pitch = 67, -- g4
     length = 1/2,
     shakeNoteLength = 5/128,
     shakeDeltaPitch = 2,
     preparation = twoNotePreparationB2,
     termination = threeNoteTermination2
  })


The preparation and termination shown above are two of a set of standard preparations and terminations that work, in my opinion, well enough for standard trills. A user-friendly program (e.g. a Noteworthy Composer trill object!) would give the user the possibility to choose from a list of preparation and termination types as well as the basic speed of the trill (which defines the shakeNoteLength), and then try to find the various deltaPitch values by looking at the current key and surrounding accidentals; but give the user possibilities to override the pitches.

The program, as currently written, allows only for note lengths that are integral multiples of 1/128. Triplets are not possible: At first, I thought that triplet notes are necessary for nice-sounding trills. However, the difference between a triplet note and the multiples of 1/128 near it is so small that it is not perceptible. When manually writing trills, triplet notes help to keep the number of notes and of ties down; but with automatic note generation, one can hopefully ignore this issue.

Also, there is not yet a satisfying definition for prallers and mordents. Therefore, in the following scores, such trills are copied over from the manually written scores.

Here, now, are trills for "piano" and "lovely flute" in Clarke's march, generated from straightforward trill definitions (that are contained in the Lua file linked above):



I, for my part, find these trills as nice as my manual ones. And they are certainly nicer than trills without preparations and terminations.

(I leave the generation of trills for the "aggressive flute" as an exercise to the reader ...).

Some open issues


In order to claim that the parameters shown above are enough to get every trill to play satisfyingly, one would have to define and listen to many trills of different musical periods. I suspect that a few additional parameters might be necessary for the following features:
  • It might be necessary to change the speed of the shake throughout the trill. Hopefully, a linear change of the speed (or the shake note length) is sufficient, but of course a "speed shape" consisting of a line graph describing multiple speeds and speed changes might be a better (but more complex) choice.
  • Prallers and mordents have their own structure: There is a short trill of a selected speed, and then a longer note filling up the rest of the note length. A definition using a fixed length instead of a "stretch factor" might be better suited for these.
  • Finally, a turn looks very much like a "trill without shake". Actually, I have defined the turn in measure 6 of my example score exactly like that—but it might be that a simpler structure, or at least a simpler user interface is more suited to describe a turn.
I close my text on trills with these final remarks and hope that someone out there may find it at least a little bit interesting.

Sunday, August 2, 2015

A Spiritual

Yesterday, when I was at the supermarket, a short piece of text and a melody popped into my mind. When I cam home, I wrote down a sketch of it, then I lay down for a short (actually not so short) nap ...

Later in the afternoon, I extended the idea to a complete piece: For a soloist and maybe a descant voice (male/female, preferably), choir, and a piano for accompagniment, but also some solo parts. Here is the score, a link to a demo MP3, and a link to a Noteworthy-Composer file ( click on the score opens a complete PDF file):


When I walked along the road (MP3)

When I walked along the road (Noteworthy-Composer-Datei)

Maybe I can convince our choir to sing it ...

Tuesday, October 28, 2014

"hmm_ShowRanges" - a Noteworthy Composer 2 user tool for checking ranges in scores

Contents

  1.   Introduction
  2.   Example 1
  3.   Example 2
  4.   The rules for range chords
  5.   Example 3
  6.   Example 4

Introduction


I have written a small script that can be used to mark notes that fall outside a given range. This should be helpful when writing for instruments or voices with a limited range – in other words, almost always.

I should have written this script years ago, but somehow I waited until yesterday when, in a few hours, I learned (the necessary few pieces of) PHP and concentrated on the little algorithms behind ...

Of course, this piece of code makes heavy reuse of ideas and code already around – I was "standing on the shoulders of giants," so-to-speak: The idea is inspired by the adp_Ranges script, whereas the code uses NW2's nwc2clips library. I have to thank the people who provided one and the other.

The script can be downloaded here (as a ZIP file). It requires the installation of the "NWC2 User Tool Starter Kit", which can be found here.

The following paragraphs contain a short introduction how to use the script. All the examples below use a quite useless melody, which includes some clef changes and strange chords at the end:

Example 1


In the simplest case, one wants to mark all notes outside a given range. The steps for range checking are:
  1. Write a "range chord" at the beginning – here, a simple octave. In real life, one would mark this chord as "Visible: Never," but here, I left it visible to show its effects more clearly:
  1. Mark the range chord and all the notes you want to check:
  1. Run the script.
Here is the result (after deselecting) – all the notes outside the range have been colored like the "range chord":
The "range chord" (octave) specified that the range between (and including) the two C's is the "normal range," which is left unmodified. All notes below the lower C or above the upper C are colored. It is intentional that the notes outside the range are colored, as it is customary that ranges are defined "inclusively," i.e., the boundary notes of the range are considered to be inside the range.

As one can see, the script works also over clef changes and for chords with stems in both directions.

By the way, a simple Ctrl-Z reverts all the changes – so that your next printout will still be black-on-white!

Example 2


Here is another example, this time with two ranges:
  • The inner range from e to b is the "convenient range," which can be sung or played easily.
  • The outer range from c to the upper e is the "complete range," which can be sung or played with some effort.
The notes outside these two ranges are supposed to be "off-limits."
Here is the result when marking all notes and running the tool:
One can see that the notes in the innermost range keep their noteheads and color, the notes in between the inner and the outer range get pink triangular heads, and the notes outside the outer range get red round noteheads.

The rules for range chords


Before I continue with two more examples, let me state the rules for writing a range chord:
  • A range chord must consist of an even number of notes.
  • The outermost (lowest and highest) note define the outermost range. Because of this, they must have the same notehead and the same color.
  • When these two notes are removed ("peeled off"), the now outermost notes define the next range. Again, they must have the same notehead and color.
  • This "layering of note pairs" can be continued arbitrarily (but I have used a maximum of three ranges up to now).
  • The lower notes of two ranges can be equal (but not the upper ones – up to now, I do not need this, and the algorithms would have become even more complicated with identical upper notes).
  • Range chords will be "seen" by tool regardless of their visibility. Therefore, I find it practical to assign them visibility "Never" (except when editing them, so that I can see the noteheads' colors).
If the first chord of the selected notes does not follow these rules, the script will probably behave erratically, as I have not yet added enough error handling. In many cases, it will simply skip the chord and try to use the next chord as "range chord" – probably not what one expects, but so it goes ... But whatever happens, Ctrl-Z should revert to the previous state in all cases!

Example 3


Ranges must "nest properly" – this follows from the rules above; but see example 4! -, but ranges can have the same lower boundary note. Incidentally, this made the internal algorithm quite a bit harder, but it is necessary for standard and extended ranges of brass and other instruments.

Here is an example where both the inner range and the outer range start at middle C. It makes sense to use whole notes ("semibreve") in this case, because they are placed side by side (the heads of shorter double notes are placed on top of each other). For variety, the outer range is green:
Here is the result of marking everything and running the script:

Example 4


At times, it is necessary to range check for different reasons with quite independent range definitions. For example, for a clarinet, one might want to check for notes above the b flat/b "break," in addition to the standard range check.

Of course, one can simply put multiple range chords at the beginning of a system and, depending on the check, start the note selection with the second, third, etc. range chord. The only problem is that this would change included range chords – e.g. the second range chord, if the selection starts at the first one:
However, the script is so nice to not change chords that are marked with "Visibility: Never." This is a useful idea anyway, so that the range chords do not show up in printed scores, but in addition it helps to keep the range chords unchanged.

Here is the result when running the script on the full selection ...
... and here we see what happens when the selection starts at the second chord:

In a way, this allows for overlapping or "non-layered" ranges – i.e., one can subvert the rule that ranges must "nest properly."

This is the end of my description of the "hmm_ShowRanges" script. I'd be happy if it is of some help for you ... or you ... or you!

Saturday, April 26, 2014

Small prelude on GrandOrgue

Here is a small prelude I wrote in 2011, and its rendition on the GrandOrgue organ simulator:

This is my first attempt of reproducing a composition directly on the computer—I try to learn more about this in the months to come, and hope to post more organ, and later other, pieces!

Friday, May 10, 2013

Surprise 1 - the solution

But? ... the refrain of this song, called "When I Hear a Syncopated Tune" is not syncopated! Yes, there is a syncopation in the final turn of the refrain, which is repeated three times—but the "earworm" melody of the refrain does not want to follow its lyrics. For whichever reason.
By the way, it is hard to believe that Mr. Hirsch (who certainly knew all about syncopations—we are at the end of ragtime's high time!) wanted to present an intricate contradictory riddle to his audience. With this light entertaining piece, I'd rather assume that the text was written after the melody had been composed ... or something like that. But I do not know the historical facts.
The refrain of this song can also be heard in this video posted at youtube , starting around 3:33.

Does also this song, called "Those Ragtime Melodies" subvert its title? I'm not so sure here: Nowadays, a "ragtime" must be syncopated in Scott-Joplin-ish manner—but it might well have been that many songs around 1900 were sold under this heading even though they were not syncopated. Still, also this song surprised me.

Thursday, May 9, 2013

Surprise 1

Sometimes, a piece of music contains, somewhere in the middle, a surprise: Something you would not have expected. Of course, Haydn's "Surprise Symphony" is one of these pieces, with a rather overt and shocking surprise at just the right moment. Haydn's symphonies contain more such unexpected turns (I might show a few more sometime), but for the moment, I'll concentrate on other pieces with quirks or parts or motifs that surprised at least me.

Here is an example (the "solution" will follow in another posting): In 1918, Louis Hirsch composed a nice song for the Ziegfeld Follies in New York, with lyrics by Gene Buck: "When I Hear a Syncopated Tune." Here is a link to a recording of this song, with a refrain that's hard to forget ...

When I Hear a Syncopated Tune (from the Ziegfeld Follies, 1918)

... but?!?

Tuesday, April 30, 2013

Amuck rag

In a few past posting, diatonic scale, chromatic scale and diminished chords transformed themselves to ragtimes. But enough is enough, I said, and stopped writing ragtimes. Yet, an augmented chord took hold of my mind and wanted also its share of syncopation. However, I refused—and so the chord ran amuck.


Amuck Rag:
Here is a video of my attempt to play my composition—I confess that I do not wholly succeed! If you can do it better, I might be inclined to send you some small gift!