void DrumTools::updateDrumset() { drumPalette->clear(); if (drumset == 0) return; int drumInstruments = 0; for (int pitch = 0; pitch < 128; ++pitch) { if (drumset->isValid(pitch)) ++drumInstruments; } int i = 0; double _spatium = gscore->spatium(); for (int pitch = 0; pitch < 128; ++pitch) { if (!drumset->isValid(pitch)) continue; bool up; int line = drumset->line(pitch); NoteHeadGroup noteHead = drumset->noteHead(pitch); int voice = drumset->voice(pitch); Direction dir = drumset->stemDirection(pitch); if (dir == Direction::UP) up = true; else if (dir == Direction::DOWN) up = false; else up = line > 4; Chord* chord = new Chord(gscore); chord->setDurationType(TDuration::DurationType::V_QUARTER); chord->setStemDirection(dir); chord->setUp(up); chord->setTrack(voice); Note* note = new Note(gscore); note->setParent(chord); note->setTrack(voice); note->setPitch(pitch); note->setTpcFromPitch(); note->setLine(line); note->setPos(0.0, _spatium * .5 * line); note->setHeadGroup(noteHead); chord->add(note); Stem* stem = new Stem(gscore); stem->setLen((up ? -3.0 : 3.0) * _spatium); chord->setStem(stem); stem->setPos(chord->stemPos()); int sc = drumset->shortcut(pitch); QString shortcut; if (sc) shortcut = QChar(sc); drumPalette->append(chord, qApp->translate("drumset", qPrintable(drumset->name(pitch))), shortcut); ++i; } }
void EditDrumset::updateExample() { int pitch = pitchList->currentItem()->data(0, Qt::UserRole).toInt(); if (!nDrumset.isValid(pitch)) { drumNote->add(0, 0, ""); return; } int line = nDrumset.line(pitch); NoteHead::Group noteHead = nDrumset.noteHead(pitch); int voice = nDrumset.voice(pitch); MScore::Direction dir = nDrumset.stemDirection(pitch); bool up; if (dir == MScore::Direction::UP) up = true; else if (dir == MScore::Direction::DOWN) up = false; else up = line > 4; Chord* chord = new Chord(gscore); chord->setDurationType(TDuration::DurationType::V_QUARTER); chord->setStemDirection(dir); chord->setTrack(voice); chord->setUp(up); Note* note = new Note(gscore); note->setParent(chord); note->setTrack(voice); note->setPitch(pitch); note->setTpcFromPitch(); note->setLine(line); note->setPos(0.0, gscore->spatium() * .5 * line); note->setHeadGroup(noteHead); chord->add(note); Stem* stem = new Stem(gscore); stem->setLen((up ? -3.0 : 3.0) * gscore->spatium()); chord->add(stem); stem->setPos(chord->stemPos()); drumNote->add(0, chord, qApp->translate("drumset", nDrumset.name(pitch).toUtf8().constData())); }