CoderLine / alphaTab

alphaTab is a cross platform music notation and guitar tablature rendering library.
http://www.alphatab.net
Mozilla Public License 2.0
1.27k stars 202 forks source link

Concert Pitch vs Written Pitch #139

Closed gburlet closed 7 years ago

gburlet commented 7 years ago

Feature request

Hi Daniel, hope all is well with you.

I'm in the position where I'm using AlphaTab for rendering monophonic vocal sheet music from AlphaTex. I understand that the main mission of AlphaTab is for guitar sheet music, however I believe that with a couple small changes we can adapt AlphaTab to also engrave vocal sheet music while at the same time adding additional functionality for guitarists: so it's a win-win situation in my eyes.

Basically, guitar sheet music is notated an octave higher than played for ease of reading while other instruments, such as vocals, are not. Currently I am subtracting an octave from each note so that it's displayed properly, but then I run into issues where notes lie outside of the guitar pitch range and when using AlphaSynth they also sound an octave lower even though they're notated correctly.

Your environment

n/a

Expected Results

When specifying a boolean concert_pitch flag to AlphaTab when setting up, the notes on the score are rendered as they sound rather than an octave higher.

Observed Results

AlphaTab doesn't currently handle this functionality.

Possible Solution 1

We could add a concert pitch/written pitch boolean option when setting up AlphaTab. The value of this setup parameter would influence how the score is engraved and how AlphaSynth interprets the score for synthesis. Internally, I don't suspect this to be a complex change because it involves minor changes to AlphaTab and AlphaSynth to either perform or not perform octave subtractions.

Possible Solution 2

We add possibility for an 8vb symbol to indicate the music is to be played as written rather than transposed an octave.

Danielku15 commented 7 years ago

Hi. Thanks for the comprehensive feature request, really appreciate how properly it 😄 In theory both solutions make sense in long term. A pitch offset would allow a quite flexible adjustment of the music notation if required. The octave offset symbols are anyhow part of standard music notation and is a missing feature yet. GuitarPro also has support for them. But I guess you don't want a 8vb--------| indicator spread across all notes.

To directly address your direct use case I'd think I need some more info how you exactly need alphaTab to behave. So far I have following suggestion:

  1. Since you use alphaTex and only display monophonic vocal music, I assume you do not even need the guitar tablature so rendering the standard music notation is sufficient for you: https://jsfiddle.net/danielku15/jctjgz7o/

  2. Entering vocal music with guitar tabs might be quite inconvenient. I think adding support for non-stringed inputs in alphaTex would be nice:

alphaTex:

\tuning none
. 
c4 c#4 d4 d#4 | c4 db4 d4 eb4

Result: image

  1. If then still required, I could add also add the pitch offset functionality.

  2. Guitar Pro 6 has support for octave offsets on the clef which affect the rendering of the standard music notation (note the numbers on the clef):

image

But this does neither affect the guitar notation nor the playback since it only indicates that the standard music notation is displayed with a certain offset . Not sure if this is really useful for you.

Danielku15 commented 7 years ago

I prepared a small sample for you which covers all the new features: https://jsfiddle.net/danielku15/p047gsnh/

  1. You can write alphaTex now with note names instead of strings when using \tuning none This will automatically hide the tabs.
  2. Lyrics can now be specified via the \lyrics metadata and the Guitar Pro lyrics format.
  3. You can now specify pitches for all tracks of a song (either on initializing or via data attribute).

Does this cover all your needs?

gburlet commented 7 years ago

Hi Daniel,

Thanks for your quick response. I donated you a few beers to say thanks!

To answer your questions:

  1. Yes, for vocals I'm just interested in showing the common music notation rather than tabs.
  2. Currently I was getting around this by picking a guitar tuning and generating any string/fret location that would produce the note I was looking for. The method of input you implemented is much cleaner!
  3. I think the pitch offset option could be helpful to everyone.
  4. I had no idea GuitarPro had that functionality. Not interesting for me, but perhaps others.

Okay, so with your small example above:

\tuning none
. 
c4 c#4 d4 d#4 | c4 db4 d4 eb4

I need to specify data-pitches="[-12]" to bring everything down an octave on the staff (see this jsfiddle. I think with AlphaSynth it still sounds an octave lower than notated though? Not a huge deal. As it stands, this satisfies my use case.

Cheers, Greg

Danielku15 commented 7 years ago

Yes data-pitches="[-12]" reduces all notes by 12 semitones (=1 octave). The pitch will be applied to both music notation and playback. Is it common for vocal music notation to show them as lower keys but keep the high pitch during playback/singing?

I think in this case the correct clefs with octave shifts should be used, otherwise the shown notes do not follow the rules of a standard music sheet. Let me know if you have a demand for this feature.

gburlet commented 7 years ago

In general, guitar music is notated an octave higher than what is played. Vocals and most other instruments are usually notated exactly as they should be performed. So the vocal example you gave in the first post is correct:

\tuning none
. 
c4 c#4 d4 d#4 | c4 db4 d4 eb4

should engrave this sheet music 0ff148f4-49ee-11e7-9714-39a060bfef1f

and a C4 note should sound like a C4 note.

However, the way it's currently implemented, the above AlphaTex engraves this sheet music screen shot 2017-06-05 at 12 59 53

which is correct for guitar: a note that sounds like C4 is notated as C5 but every guitar player would know to just play C4. However, a vocalist would sing this exactly as notated. For vocals and most other instruments a C4 is notated and should be played as a C4. I got around this by shifting the notation down by an octave using data-pitches="[-12]", which then makes alphaSynth synthesize it an octave lower as well.

Hopefully that makes sense. Again, I realize this is a guitar engraving library, so I'll leave it up to you about what features you care to implement. For my use case, I can now use the data-pitches="[-12]" to make things look correct although the notes sound a little lower, so I'm happy even if it's not quite correct.

gburlet commented 7 years ago

**Important** Also as a heads up, I think the latest changes here have broken regular AlphaTex guitar rendering: see this fiddle as an example.

Error: [AlphaTab][AlphaTex] - MalFormed AlphaTex: @39: Error on block note-string, expected a 2 found a 2

I've tried several of my existing AlphaTex files and they throw similar errors on the latest master build.

Danielku15 commented 7 years ago

Interesting, I never realized that the standard music notation for guitars are shown 1 octave higher. I will double check the behavior of different instruments and ensure the correct display and playback for all instruments.

It is true that alphaTab started as a guitar music engraver but since a while internally everything is prepared for fret-less instruments. It's just the rendering which is wrong by 1 octave.

I also fixed the newly introduced parsing error already. Just update ;)

gburlet commented 7 years ago

If you're interested in why guitar is notated like that it's because the pitch range of a guitar can be quite high and it's hard to read notes with lots of ledger lines so the octave modification makes it easier for guitarists to read (See this answer ... I know, I know ... it's a Yahoo answer so not the most reputable or comprehensive, but the first answer explains it quite well). In big symphonies they also do this with some other instruments so that musicians can sight read easily.

Thanks for the fast fix! I'll update.

gburlet commented 7 years ago

For your reference, here's a good chart I just found regarding what we were talking about above: instrument transposition chart

Danielku15 commented 7 years ago

Thanks for the transposition table, I will do a comparison with Guitar Pro to find out whether they also apply the same pitches.

I just did a small rework of the initial feature to match better the Guitar Pro 6 behavior (which seems to be correct for real world cases).

To support both requirements of transposition I added also 2 separate settings which can be set via data-display-transposition-pitches and data-transposition-pitches. (see updated https://jsfiddle.net/danielku15/p047gsnh/)

gburlet commented 7 years ago

This is great!

Thanks, Daniel. Cheers.