Esempio n. 1
0
void AccidentalState::init(Key key)
      {
      memset(state, 2, MAX_ACC_STATE);
      if (key > 0) {
            for (int i = 0; i < int(key); ++i) {
                  int idx = tpc2step(20 + i);
                  for (int octave = 0; octave < (11 * 7); octave += 7) {
                        int i = idx + octave;
                        if (i >= MAX_ACC_STATE)
                              break;
                        state[i] = 1 + 2;
                        }
                  }
            }
      else {
            for (int i = 0; i > int(key); --i) {
                  int idx = tpc2step(12 + i);
                  for (int octave = 0; octave < (11 * 7); octave += 7) {
                        int i = idx + octave ;
                        if (i >= MAX_ACC_STATE)
                              break;
                        state[i] = -1 + 2;
                        }
                  }
            }
      }
Esempio n. 2
0
int absStep(int tpc, int pitch)
      {
      int line     = tpc2step(tpc) + (pitch / 12) * 7;
      int tpcPitch = tpc2pitch(tpc);
      if (tpcPitch < 0)
            line += 7;
      else
            line -= (tpcPitch / 12) * 7;
      return line;
      }
Esempio n. 3
0
void AccidentalState::init(int key)
      {
      memset(state, 2, 74);
      for (int octave = 0; octave < 11; ++octave) {
            if (key > 0) {
                  for (int i = 0; i < key; ++i) {
                        int idx = tpc2step(20 + i) + octave * 7;
                        if (idx < 74)
                              state[idx] = 1 + 2;
                        }
                  }
            else {
                  for (int i = 0; i > key; --i) {
                        int idx = tpc2step(12 + i) + octave * 7;
                        if (idx < 74)
                              state[idx] = -1 + 2;
                        }
                  }
            }
      }
Esempio n. 4
0
void AccidentalState::init(const KeySigEvent& ks)
      {
      int type = ks.accidentalType();
      memset(state, 0, 74);
      for (int octave = 0; octave < 11; ++octave) {
            if (type > 0) {
                  for (int i = 0; i < type; ++i) {
                        int idx = tpc2step(20 + i) + octave * 7;
                        if (idx < 74)
                              state[idx] = 1;
                        }
                  }
            else {
                  for (int i = 0; i > type; --i) {
                        int idx = tpc2step(12 + i) + octave * 7;
                        if (idx < 74)
                              state[idx] = -1;
                        }
                  }
            }
      }
Esempio n. 5
0
void ChordEdit::setRoot(int val)
      {
//      qDebug("ChordEdit::setRoot(val=%d) tpc2step=%d tpc2stepname=%s tpc2alter=%d\n",
//             val, tpc2step(val), qPrintable(tpc2stepName(val)), tpc2alter(val));

      QAbstractButton* button = NULL;
      int id = 0;

      // catch INVALID_TPC
      if (val == INVALID_TPC) {
            qDebug("ChordEdit::setRoot(val=INVALID_TPC)\n");
            // default to C, no accidentals
            button = rootGroup->button(0);
            button->setChecked(true);
            button = accidentalsGroup->button(0 + 3);
            button->setChecked(true);
            return;
            }

      // translate tpc to button nr
      id = tpc2step(val);
      button = rootGroup->button(id);
      if (button)
            button->setChecked(true);
      else
            qDebug("root button %d not found\n", val);

      id = tpc2alter(val);
      button = accidentalsGroup->button(id + 3);
      if (button)
            button->setChecked(true);
      else
            qDebug("root button %d not found\n", id);

      chordChanged();
      }