Re: Harmonics in tablature
Hello Wol, That is more or less a different thing, since you want a different notation for that, specifying both the fret of the note and of the harmonic. When transcribing some Pastorius I defined a little function for that which gives such results: Regards, Valentin \version "2.20" artificialHarmonicTab = #(define-music-function (fret1 fret2 music) (number? number? ly:music?) #{ \harmonicByFret #(- fret2 fret1) { \temporary \override TabNoteHead #'stencil = #(lambda (grob) (grob-interpret-markup grob #{ \markup \lower #0.6 \concat { #(number->string fret1) \override #'(angularity . 2) \parenthesize { #(number->string fret2) } } #})) $music \revert TabNoteHead #'stencil } #}) \new TabStaff { \artificialHarmonicTab 2 6 b\5 } \new Staff { \artificialHarmonicTab 2 6 b\5 } signature.asc Description: This is a digitally signed message part.
Re: Harmonics in tablature
[FORGOT TO REPLY TO THE LIST] Hi Lukas, That is a rather typical problem you get with harmonic in relative mode. Basically in relative mode the octave of the pitch is saved relative to the previous note. So this means that one would have to transpose the first note in base pitch+octave, while you would have to transpose the other notes only in basepitch. But please be away that you should not use relative mode for these thing anyway, since you will also get the same problem with the next entered note: The next note would be relative to the previous harmonic pitch, not the entered pitch, which will make scores very confusing to read. But as I said earlier, the best way to handle this would be at engraver level. Valentin Am Dienstag, 30. Juni 2020, 11:32:09 CEST schrieben Sie: > Hi, > > > In Staceys example, I stumbled across the following strange thing > > where \relative behaves strangely: > > > > mus = \relative c,, { \harmonicByRatio #1/4 2. } > > > > << > > \new TabStaff > > { > > \set Staff.stringTunings = \stringTuning > > \tabFullNotation > > \mus > > } > > \new Staff \mus > > Just to make this explicit: \harmonicByRatio and \harmonicByFret both > fail if used for chords in \relative mode. The reason is the behaviour > of calc-harmonic-pitch that can be seen in the attached file. > > (calc-harmonic-pitch looks like a direct reimplementation of \transpose > c' #pitch #mus, but it differs from \transpose in that in actually does > something - and even "the right thing" - for music inside \relative if > given only _one_ note.) > > So I agree (if I understood your remark correctly) that \harmonicByFret > and \harmonicByRatio should rather accept single pitches only. > > But you're obviously also right in that the implementation of harmonics > handling should be reconsidered because of the different ways they have > to be handled in a) staves, b) tabstaves, c) midi. Maybe I can try > something in that direction over the next few days, but I know this is > going to be pushing my understanding of Lilypond and scheme programming > to its boundaries :-). > > Lukas signature.asc Description: This is a digitally signed message part.
Re: Harmonics in tablature
On 29/06/2020 10:30, Valentin Petzel wrote: 3) Forcing a string number can be done manually easily (though this is not good if the tuning changes at some point). But in code it is quite a bit more effort to achieve the same result, because we then would need to read the string tunings from the context and determine for each single note on which string that is. By simply setting minimumFret to an appropriate value (sorry again), we can achieve the same result without coding the same thing multiple times. Only problem is that doing it this way will override minimumFret directions done before. Not that I have a clue what you're talking about here but ... You're aware that it's not uncommon to play lute music on guitar? And that guitars are then tuned to lute pitch with the 3rd g string tuned to f#? And I occasionally play harmonics on a fretted not open guitar string. (Off-topic - I went round my Aunt's once and she showed me some music her guitar teacher had given her, saying it was really hard. I spotted it was lute music and said I thought I could sight read it. She was amaZed so I retuned the guitar and struggled through it. So that was a trick she taught her guitar tutor ...) It sounds to me like this might impact what you're doing (or it might not). Cheers, Wol
Re: Harmonics in tablature
Hi, In Staceys example, I stumbled across the following strange thing where \relative behaves strangely: mus = \relative c,, { \harmonicByRatio #1/4 2. } << \new TabStaff { \set Staff.stringTunings = \stringTuning \tabFullNotation \mus } \new Staff \mus >> Just to make this explicit: \harmonicByRatio and \harmonicByFret both fail if used for chords in \relative mode. The reason is the behaviour of calc-harmonic-pitch that can be seen in the attached file. (calc-harmonic-pitch looks like a direct reimplementation of \transpose c' #pitch #mus, but it differs from \transpose in that in actually does something - and even "the right thing" - for music inside \relative if given only _one_ note.) So I agree (if I understood your remark correctly) that \harmonicByFret and \harmonicByRatio should rather accept single pitches only. But you're obviously also right in that the implementation of harmonics handling should be reconsidered because of the different ways they have to be handled in a) staves, b) tabstaves, c) midi. Maybe I can try something in that direction over the next few days, but I know this is going to be pushing my understanding of Lilypond and scheme programming to its boundaries :-). Lukas \version "2.21.0" \markup \wordwrap { \typewriter "(calc-harmonic-pitch pitch mus)" acts roughly like \typewriter "\\transpose c' $pitch #mus" but for \typewriter "\\relative" music, both fail in different ways if used for more than one note: } { \mark "\\transpose c' c'', absolute mode" \transpose c' c'' { c' d' e' c'' a' f' e' } } { \mark "calc-harmonic-pitch from c' to c'', absolute mode" #(calc-harmonic-pitch #{ c'' #} #{ c' d' e' c'' a' f' e' #}) } \relative c' { \mark "\\transpose c' c'', relative mode" \transpose c' c'' { c d e c' a f e } } \relative c' { \mark "calc-harmonic-pitch from c' to c'', relative mode" #(calc-harmonic-pitch #{ c'' #} #{ c d e c' a f e #}) }
Re: Harmonics in tablature
Hi Pierre, Using tags is pretty much the only way to achieve this from one source, but you would still need different functions for Voice and TabVoice (unless you combine them + tagging into one function, which might be useful, but unflexible. Valentin signature.asc Description: This is a digitally signed message part.
Re: Harmonics in tablature
Hi Valentin, Le lun. 29 juin 2020 à 13:30, Valentin Petzel a écrit : ... > But the hard part would be getting Staff Notation and TabStaff-Notation > right at the same time, because you usually want to notate this like this > Or similar to this. So you would need different functions for Tabnotation > and regular Notation. This having a specific engraver for harmonics would > probably be the cleanest way to do this. > Or simply use tags: http://lilypond.org/doc/v2.20/Documentation/notation/different-editions-from-one-source.html#using-tags Cheers, Pierre
Re: Harmonics in tablature
Hi Lukas, You might want to set restrainOpenStrings to #t in case the sounding pitch is in fact an open string (else minimumFret would be ignored), see appended file. The order requirement to string tuning is most likely a bug, I guess Lilypond tries to minimize the used fret by traversing the string tuning list backwards and using the first string that is tuned lower, thus assuming this order. This could probably be fixed quite easily. Artificial harmonics is hard to do, custom noteheads for that are possible. I did this for some bass score like this But the hard part would be getting Staff Notation and TabStaff-Notation right at the same time, because you usually want to notate this like this Or similar to this. So you would need different functions for Tabnotation and regular Notation. This having a specific engraver for harmonics would probably be the cleanest way to do this. Valentin harmonicByFret = #(define-music-function (fret music) (number? ly:music?) (_i "Convert @var{music} into mixed harmonics; the resulting notes resemble harmonics played on a fretted instrument by touching the strings at @var{fret}.") #{ \set harmonicDots = ##t \temporary \override TabNoteHead.stencil = #(tab-note-head::print-custom-fret-label (number->string fret)) \temporary \override NoteHead.Y-extent = #grob::always-Y-extent-from-stencil \temporary \override NoteHead.stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed) (ly:note-head::print grob)) \set restrainOpenStrings = ##t \set minimumFret = #(ly:pitch-semitones (ly:prob-property (calc-harmonic-pitch (fret->pitch (number->string fret)) (make-music 'NoteEvent 'pitch (ly:make-pitch 0 0))) 'pitch)) #(make-harmonic (calc-harmonic-pitch (fret->pitch (number->string fret)) music)) \unset restrainOpenStrings \unset minimumFret \unset harmonicDots \revert TabNoteHead.stencil \revert NoteHead.Y-extent \revert NoteHead.stencil #}) signature.asc Description: This is a digitally signed message part.
Re: Harmonics in tablature
Hi Valentin, 1) Yes. Without my mistake it calculates on which fret the sounding note would be, thus placing the note head onto the correct string. I’m sorry for that. Yes - thanks much! Now it works as expected (at least by me): If i) #pitch is the pitch of an open string (as defined with \set TabStaff.stringTunings), and ii) #fret-number is the number of a fret that "can" create a harmonic note, \harmonicByFret #fret-number #pitch now prints a) in a TabStaff: the instruction to create a harmonic on fret #fret-number on the string tuned to #pitch b) in a Staff: the resulting sounding pitch when doing so. I very much think that this should be made the standard behaviour of \harmonicByFret. [To be precise, stringTunings seems to expect that strings are created lowest-to-highest; but I readily admit that non-monotonic tunings are not really common.] If #pitch is not an open string, the result is not meaningful, as you already said. On a violin or cello, I would expect that non-open-string #pitch should create artificial harmonics (for which, in particular, one would need some kind of graphical representation in tabs indicating the use of two fingers on the same string), namely, playing #pitch on a stopped position and then adding a harmonic finger #fret-number frets above that position. But I actually do not even know if artificial harmonics are used at all on instruments for which we create tabs. 2) Yes, you are right about that. The nomenclature might be a bit confusing, but it helps to thing of the pitch in calc-harmonic-pitch as ratio. Then why is calc-harmonic-pitch hand-tailored if it could be implemented by \transpose c' #pitch #music ? About your example: What exactly does not work? This look exactly like I would expect from the lilypond code. ... and this _I_ did mess up. Sorry. In Staceys example, I stumbled across the following strange thing where \relative behaves strangely: mus = \relative c,, { \harmonicByRatio #1/4 2. } << \new TabStaff { \set Staff.stringTunings = \stringTuning \tabFullNotation \mus } \new Staff \mus >> In my desire to reproduce this problem with \harmonicByFret I custom-made it by entering a large octave offset in a relative code myself. Stupid me. But I admit that, while I spent some time yesterday to try and understand \harmonicByFret, I still have to do this for \harmonicByRatio, so maybe there's a simple explanation. 3) Forcing a string number can be done manually easily (though this is not good if the tuning changes at some point). But in code it is quite a bit more effort to achieve the same result, because we then would need to read the string tunings from the context and determine for each single note on which string that is. By simply setting minimumFret to an appropriate value (sorry again), we can achieve the same result without coding the same thing multiple times. Only problem is that doing it this way will override minimumFret directions done before. I admit that I still have to understand the way LilyPond figures out the correct position in tablature of a note: I understand that \harmonicByFret calculates the sounding pitch, but this implied that there must be a mechanism that forces a tab position for the note that does not correspond with its actual sounding pitch. (Which can also be seen if we use your improved \harmonicByFret to create a harmonic on a non-open string: The sounding pitch changes, the displayed tab doesn't.) Lukas
Re: Harmonics in tablature
Hello Carl, They can be, although I had to correct a little mistake where I forgot to replace 12 from my testing with the actual fret. You just need to be aware that this will revert any \set minimumFret = ? done before as long as lilypond cannot mask context properties. Also it might be a good idea to set restrainOpenStrings = ##t in case the harmonic pitch is just by chance the pitch of an open string. Valentin Am Samstag, 27. Juni 2020, 18:36:53 CEST schrieb Carl Sorensen: > On Sat, Jun 27, 2020 at 5:58 AM Valentin Petzel wrote: > > Hello Lukas, > > > > This is a certain limitation in how the harmonicByFret-Function works. It > > will calculate the pitch for the given note, thus the Noteheads are > > automatically placed onto higher strings. Thus you eighter will have to > > manually specify the string number, or you might do something like in the > > appended file, which is modifying the harmonicByFret-function to > > automatically use the proper string. This should work at least for open > > strings, for artificial harmonics this is not really a problem, since > > harmonicByFret sucks for that anyway. > > Can the changes you made be incorporated in the harmonicByFret > function in the distribution? > > Carl signature.asc Description: This is a digitally signed message part.
Re: Harmonics in tablature
Hi Lukas, I’m sorry, I messed that up. It should say (calc-harmonic-pitch (fret->pitch (number->string fret)) I did my intropections with that using fret=12, and then I forgot to change that when copying. See the attached file for the correction. About your points: 1) Yes. Without my mistake it calculates on which fret the sounding note would be, thus placing the note head onto the correct string. I’m sorry for that. 2) Yes, you are right about that. The nomenclature might be a bit confusing, but it helps to thing of the pitch in calc-harmonic-pitch as ratio. About your example: What exactly does not work? This look exactly like I would expect from the lilypond code. 3) Forcing a string number can be done manually easily (though this is not good if the tuning changes at some point). But in code it is quite a bit more effort to achieve the same result, because we then would need to read the string tunings from the context and determine for each single note on which string that is. By simply setting minimumFret to an appropriate value (sorry again), we can achieve the same result without coding the same thing multiple times. Only problem is that doing it this way will override minimumFret directions done before. 4) Okay, first you need to understand that harmonicByFret is more or less a hack. It transposes the music for a normal staff, but it overrides the TabNoteHead to print the given fret. If the music wasn’t transposed this would do more or less what we want (though it makes big trouble in chords!, for these you might consider to change harmonicByFret to take just one note and replace all the overrides with tweaks), but since the music is transposed up, lilypond will just place it on a higher string (since it just thinks that this was a regular high note). Your understanding is correct, but it is just that harmonicByFret is not optimal. I think the cleanest way to do this would be adding different new engravers to Voice and TabVoice that listen to some sort of harmonic event and will do everything a properly. For example you might want the staff notation of harmonics to be different, like notating the touched note and the sounding note in parentheses above. This would just not work with harmonicByFret, as it would be insanely hard to just add these notes to Voice, but not to TabVoice. Regards, Valentin \version "2.21.0" harmonicByFret = #(define-music-function (fret music) (number? ly:music?) (_i "Convert @var{music} into mixed harmonics; the resulting notes resemble harmonics played on a fretted instrument by touching the strings at @var{fret}.") #{ \set harmonicDots = ##t \temporary \override TabNoteHead.stencil = #(tab-note-head::print-custom-fret-label (number->string fret)) \temporary \override NoteHead.Y-extent = #grob::always-Y-extent-from-stencil \temporary \override NoteHead.stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed) (ly:note-head::print grob)) \set minimumFret = #(ly:pitch-semitones (ly:prob-property (calc-harmonic-pitch (fret->pitch (number->string fret)) (make-music 'NoteEvent 'pitch (ly:make-pitch 0 0))) 'pitch)) #(make-harmonic (calc-harmonic-pitch (fret->pitch (number->string fret)) music)) \unset minimumFret \unset harmonicDots \revert TabNoteHead.stencil \revert NoteHead.Y-extent \revert NoteHead.stencil #}) music = { c4 d e f g a b c' \bar "||" \harmonicByFret #12 g, \harmonicByFret #7 g, \harmonicByFret #5 g, } << \new TabStaff { \set TabStaff.stringTunings = \stringTuning \music } \new Staff { \clef bass \music } >> signature.asc Description: This is a digitally signed message part.
Re: Harmonics in tablature
- Original Message - From: "Lukas-Fabian Moser" To: Sent: Saturday, June 27, 2020 8:12 AM Subject: Harmonics in tablature Folks, Stacy's question ("Three problems with harmonics") prompted me to try LilyPond's tablature facilities for the first time. I beg forgiveness for using it not for guitar/bass but for the cello - for me it's the most convenient way since I know the fingerings/imaginary "frets" and harmonics positions by heart on that instrument, and luckily, the physics is the same :-). My question is: \version "2.21.0" music = { c4 d e f g a b c' \bar "||" \harmonicByFret #12 g, \harmonicByFret #7 g, \harmonicByFret #5 g, } << \new TabStaff { \set TabStaff.stringTunings = \stringTuning \music } \new Staff { \clef bass \music } >> The first two bars are fine and standard 1st position cello fingering. But the harmonics that follow confuse me. I read the input as "use the 12th/7th/5th fret over the open g, string". If you play this, you definitely get the sounding pitches the lower staff indicates. But why are the harmonics in tablature are printed for the d and a strings? Either I fundamentally misunderstand the way harmonics should be read in tablature, or there is a serious flaw in LilyPond's logic that determines the string number in tablature. (Yes, I know that I can fix the output by adding \3 manually, but...) Lukas I'm wondering if you expect the harmonicByFret function to be smarter than it looks it actually is. Reading the NR and doing some experimenting (I don't really understand tab notation and had to look up which fret produces which note) and it seems to me that the actual syntax is: harmonicByFret FretNo BaseNote \StringNo i.e. the combination of BaseNote and FretNo produces the sounding tone, and StringNo states where to place the Fret indication. It looks to me that the string number has to be set completely separately from the base note (i.e. the octave below the harmonic on fret 12). If you try, you'll see that specifying an e, as the base note, you get e no matter which string you say it should be sounded on. So I reckon you must use the syntax that is always shown in the NR to get this to work - i.e. essentially 3 arguments to harmonicByFret. -- Phil Holmes
Re: Harmonics in tablature
Hi Valentin, This is a certain limitation in how the harmonicByFret-Function works. It will calculate the pitch for the given note, thus the Noteheads are automatically placed onto higher strings. Thus you eighter will have to manually specify the string number, or you might do something like in the appended file, which is modifying the harmonicByFret-function to automatically use the proper string. This should work at least for open strings, for artificial harmonics this is not really a problem, since harmonicByFret sucks for that anyway. Thanks much! I think the problem is more complicated than that, or my lack of understanding more fundamental than that. With your modification, the output now is: which is _not_ correct since all the harmonics should be played on the third string. (At least on violin/cello its perfectly common to play harmonics in the "upper" half of the string, hence with "fret numbers".) On the cello, I get the sounding pitches from the lower staff by playing harmonics on the 12th, 7th, 5th fret all on the same string. (I hope it's clear that I speak of imaginary semitone frets on a cello.) 1) I think your function \set minimumFret = #(ly:pitch-semitones (ly:prob-property (calc-harmonic-pitch (fret->pitch (number->string 12)) (make-music 'NoteEvent 'pitch (ly:make-pitch 0 0))) 'pitch)) is just a complicated way of writing \set minimumFret = 12: (fret->pitch "12") looks up the partial that you get by touching the "12"th fret - which is 1st partial (hardcoded in #fret-partials) - and then translates this into a pitch-delta from c'; this yields #'(1 0 0) (hardcoded in #partial-pitch) which means c''. Hence, you basically call (calc-harmonic-pitch pitch-c'' pitch-c'). This yields c'', hence the call of pitch-semitones returns 12. 2) Now, calc-harmonic-pitch (which seems to have been written by Carl 10 years ago, so I'm very glad he chimed in already) seems to me to be basically a variant of \transpose, for instance: \version "2.21.0" chp = #(define-music-function (p m) (ly:pitch? ly:music?) (calc-harmonic-pitch p m)) mus = \relative c' { c4 d e f g } \new Staff { \chp f' \mus } (But, as I already remarked yesterday, I think that calc-harmonic-pitch does not work correctly for chords in \relative music: \version "2.21.0" chp = #(define-music-function (p m) (ly:pitch? ly:music?) (calc-harmonic-pitch p m)) mus = \relative c' { c4 e f g } \new Staff { \chp c'' \mus } If this is expected behaviour, then at least I do not understand it.) 3) Ok, assuming that my diagnosis is correct and you actually just achieve \set minimumFret = 12 (at least it's obvious that your code does not depend on the parameters given to harmonicByFret): This shouldn't be what we need, I think, because we explicitly asked for frets no. 7 and 5, respectively. We shouldn't force a minimum fret, but a string number. 4) All of this makes so little sense to me that I'm sure I suffer from some fundamental misunderstanding of the way the harmonics implementation is supposed to work. I have no idea why LilyPond, when we minimumFret to 12, created a harmonic note on the string above with fret number smaller than 12. So I probably should ask: Is my understanding correct that printing <7> on a certain second string in a tablature diagram should mean that this string should be played with an open harmonic with finger on the 7th fret? Lukas
Re: Harmonics in tablature
On Sat, Jun 27, 2020 at 5:58 AM Valentin Petzel wrote: > > Hello Lukas, > > This is a certain limitation in how the harmonicByFret-Function works. It will > calculate the pitch for the given note, thus the Noteheads are automatically > placed onto higher strings. Thus you eighter will have to manually specify the > string number, or you might do something like in the appended file, which is > modifying the harmonicByFret-function to automatically use the proper string. > This should work at least for open strings, for artificial harmonics this is > not really a problem, since harmonicByFret sucks for that anyway. > Can the changes you made be incorporated in the harmonicByFret function in the distribution? Carl
Re: Harmonics in tablature
Hello Lukas, This is a certain limitation in how the harmonicByFret-Function works. It will calculate the pitch for the given note, thus the Noteheads are automatically placed onto higher strings. Thus you eighter will have to manually specify the string number, or you might do something like in the appended file, which is modifying the harmonicByFret-function to automatically use the proper string. This should work at least for open strings, for artificial harmonics this is not really a problem, since harmonicByFret sucks for that anyway. Regards, Valentin \version "2.21.0" harmonicByFret = #(define-music-function (fret music) (number? ly:music?) (_i "Convert @var{music} into mixed harmonics; the resulting notes resemble harmonics played on a fretted instrument by touching the strings at @var{fret}.") #{ \set harmonicDots = ##t \temporary \override TabNoteHead.stencil = #(tab-note-head::print-custom-fret-label (number->string fret)) \temporary \override NoteHead.Y-extent = #grob::always-Y-extent-from-stencil \temporary \override NoteHead.stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed) (ly:note-head::print grob)) \set minimumFret = #(ly:pitch-semitones (ly:prob-property (calc-harmonic-pitch (fret->pitch (number->string 12)) (make-music 'NoteEvent 'pitch (ly:make-pitch 0 0))) 'pitch)) #(make-harmonic (calc-harmonic-pitch (fret->pitch (number->string fret)) music)) \unset minimumFret \unset harmonicDots \revert TabNoteHead.stencil \revert NoteHead.Y-extent \revert NoteHead.stencil #}) music = { c4 d e f g a b c' \bar "||" \harmonicByFret #12 g, \harmonicByFret #7 g, \harmonicByFret #5 g, } << \new TabStaff { \set TabStaff.stringTunings = \stringTuning \music } \new Staff { \clef bass \music } >> signature.asc Description: This is a digitally signed message part.