merge and forward
[alioth/musescore.git] / debian / patches / experiments / statusline-pitch-onofftime.diff
1 Description: indicate pitch and on/off time in the status line
2  - indicate sounding pitch if the global concert pitch toggle
3    is off and the current instrument has an actual pitch,
4    i.e. not beat/rhythm slashes or drums; this will show the
5    identical pitch for nōn-transposing instruments by design
6    (to show we’re currently in transposing pitch mode, but the
7    current instrument is not transposing) which helps debugging
8  - indicate tuning (if any) after the sounding pitch (either mode)
9  - show on/off times if at least one of them is nōn-standard
10  .
11  The first change partially addresses node #283120.
12  The on/off time was requested in node #290900#comment-927933
13  (velocity is too hard, sorry about that).
14 Author: mirabilos <m@mirbsd.org>
15 Forwarded: https://github.com/musescore/MuseScore/pull/6750
16
17 --- a/libmscore/note.cpp
18 +++ b/libmscore/note.cpp
19 @@ -2749,14 +2749,31 @@ QString Note::accessibleInfo() const
20        QString duration = chord()->durationUserName();
21        QString voice = QObject::tr("Voice: %1").arg(QString::number(track() % VOICES + 1));
22        QString pitchName;
23 +      QString pitchOffset;
24 +      QString onofftime;
25 +      if (!_playEvents.empty()) {
26 +            int on = _playEvents[0].ontime();
27 +            int off = _playEvents[0].offtime();
28 +            if (on != 0 || off != NoteEvent::NOTE_LENGTH)
29 +                  onofftime = QObject::tr(" (on %1‰ off %2‰)").arg(on).arg(off);
30 +            }
31        const Drumset* drumset = part()->instrument()->drumset();
32        if (fixed() && headGroup() == NoteHead::Group::HEAD_SLASH)
33              pitchName = chord()->noStem() ? QObject::tr("Beat slash") : QObject::tr("Rhythm slash");
34        else if (staff()->isDrumStaff(tick()) && drumset)
35              pitchName = qApp->translate("drumset", drumset->name(pitch()).toUtf8().constData());
36 -      else
37 +      else {
38              pitchName = tpcUserName(false);
39 -      return QObject::tr("%1; Pitch: %2; Duration: %3%4").arg(noteTypeUserName()).arg(pitchName).arg(duration).arg((chord()->isGrace() ? "" : QString("; %1").arg(voice)));
40 +            if (tuning() != 0)
41 +                  pitchOffset = QString::asprintf("%+.3f", tuning());
42 +            if (!concertPitch()) {
43 +                  // tpcUserName equivalent for getting the sounding pitch
44 +                  QString soundingPitch = propertyUserValue(Pid::TPC1) + QString::number(((_pitch + ottaveCapoFret() - int(tpc2alter(tpc()))) / 12) - 1);
45 +                  // almost the same string as below
46 +                  return QObject::tr("%1; Pitch: %2 (sounding as %3%4); Duration: %5%6%7").arg(noteTypeUserName()).arg(pitchName).arg(soundingPitch).arg(pitchOffset).arg(duration).arg(onofftime).arg((chord()->isGrace() ? "" : QString("; %1").arg(voice)));
47 +                  }
48 +            }
49 +      return QObject::tr("%1; Pitch: %2%3; Duration: %4%5%6").arg(noteTypeUserName()).arg(pitchName).arg(pitchOffset).arg(duration).arg(onofftime).arg((chord()->isGrace() ? "" : QString("; %1").arg(voice)));
50        }
51  
52  //---------------------------------------------------------