Yes, setTpcFromPitch() does not work if called on a note that has not yet
been added to the score, because there is no way to find the current key
signature. It might not always work completely correctly even if the note
*has* already been added - I think that might be what is going on in your
grace note example (see below).
I've recently replaced a couple of calls to Note::setTpcFromPitch with
Note::setNval instead, which takes a tick as an additional parameter in
case the tick can't be determined from the note itself. See my recent
changes to importmidi.cpp and importove.cpp. I assume the same fix would
work for Capella; I didn't do it because I know *nothing* of that file
format and don't have any sample scores; even if I donwloaded one, I'd have
no way of knowing what the expected results were.
As for the meaning of tpc1 & tpc2, it's for transposing instruments (eg, Bb
clarinet, horn in F). tpc1 refers to the tpc to be used when in concert
pitch mode, tpc2 is the tpc to be used when in tranposed mode. This was
separated out a year or so ago to enable you to have different enharmonic
spellings if desired between the two modes (at least I assume that was the
original reason; it's a good one, anyhow).
The grace note behavior you describe does seem like a bug to me. Probably
we shouldn't be trying to guess the tpc from the pitch anyhow; we should be
copying both tpc1 & tpc2 from the parent note. Maybe there is a reason we
don't, though. But this does illustrate the feture of tpc1 & tpc2 to allow
you to have different enharmonic spellings according to concert pitch mode
:-). From what I can, there is nothing "wrong" here exactly - I mean, Fb
is a valid spelling for the note, and you can change it with arrow keys or
"J". Arrow keys normally change both tpc's, keeping them synchronized
according to transposition. "J" normally alters just the "current" tpc,
which is how you'd go about getting different spellings for concert pitch
on versus off if you wanted it (as I sometimes do).
But the bug is that the initial spelling of the grace note was different
for concert pitch on versus off in the first place, and I think you have
already identified the cause - the key is not being transposed in
setTpcFromPitch. I made that change recently to setNval but didn't touch
setTpcFromPitch because, well, as far as I knew, there was nothing broken,
and "if it ain't broke...". But I think you have probably just
demonstrated it *is* broke :-)
Hope that made sense and answered your questions!
Marc
On Wed, Jan 14, 2015 at 10:20 AM, ABL <[email protected]> wrote:
> I am trying to implement transposing instrument import of capella files.
> I think I almost finished with that (I will soon submit a PR), but I found
> something strange in the tpc implementation.
> The capella import is using function "setTpcFromPitch" to set tpc1 and
> tpc2,
> but I found that this function in some corner cases gives a "wrong" value
> for tpc2.
> This can be seen also when inserting a grace note, which uses the same
> function to evaluate tpcs.
> Example:
> - score for F Horn with written key signature Db major (actual key
> signature
> Gb major)
> - create a natural E in the fourth space [i.e. type E (possible
> ctrl+up/down
> to correct the octave) and then up arrow]. Its parameters, as shown in the
> debugger are:
> pitch: 69 epitch: 76 tpc1: 17 tpc2: 18 line: 1
> - Exit note-edit mode, select the natural E and double-click
> "acciaccatura".
> Here is the strange behavior: we would expect a natural E acciaccatura, but
> we obtain a flat F acciaccatura. Its parameters, from the debugger, are:
> pitch: 69 epitch: 76 tpc1: 17 tpc2: 6 line: 0
> Now, if you play with up and down arrow a few times, you obtain natural E
> with parameters:
> pitch: 69 epitch: 76 tpc1: 17 tpc2: 18 line: 1
> and flat F with parameters:
> pitch: 69 epitch: 76 tpc1: 5 tpc2: 6 line: 0
> As you can see, the result from "setTpcFromPitch" is different. Is it a bug
> of that fuction or am I missing the behavior of tpcs?
> Moreover, should the "key" be transposed in one of the call to "pitch2tpc"
> inside the "setTpcFromPitch" function (the first one, with " -
> transposition()" probably)?
> By the way, what do these parameters (tpc1 and tpc2) represent? I
> understood
> that they are related to transposition and note spelling, but I can't
> understand the fine details.
>
> Thank you very much for your help.
>
> Ciao,
> ABL
>
>
>
>
> --
> View this message in context:
> http://dev-list.musescore.org/TPC1-TPC2-tp7579075.html
> Sent from the MuseScore Developer mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
> GigeNET is offering a free month of service with a new server in Ashburn.
> Choose from 2 high performing configs, both with 100TB of bandwidth.
> Higher redundancy.Lower latency.Increased capacity.Completely compliant.
> http://p.sf.net/sfu/gigenet
> _______________________________________________
> Mscore-developer mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mscore-developer
>
--
Marc Sabatella
[email protected]
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Mscore-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mscore-developer