void DrumTools::setDrumset(Score* s, Staff* st, Drumset* ds) { if (s == _score && staff == st && drumset == ds) return; _score = s; staff = st; drumset = ds; 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 (!ds->isValid(pitch)) continue; bool up; int line = ds->line(pitch); int noteHead = ds->noteHead(pitch); int voice = ds->voice(pitch); Direction dir = ds->stemDirection(pitch); if (dir == UP) up = true; else if (dir == DOWN) up = false; else up = line > 4; Chord* chord = new Chord(gscore); chord->setDurationType(Duration::V_QUARTER); chord->setStemDirection(dir); 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(note->stemPos(up)); 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); Note::NoteHeadGroup noteHead = nDrumset.noteHead(pitch); int voice = nDrumset.voice(pitch); MScore::Direction dir = nDrumset.stemDirection(pitch); bool up; if (dir == MScore::UP) up = true; else if (dir == MScore::DOWN) up = false; else up = line > 4; Chord* chord = new Chord(gscore); chord->setDurationType(TDuration::V_QUARTER); chord->setStemDirection(dir); 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, 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->setStem(stem); stem->setPos(note->stemPos(up)); drumNote->add(0, chord, qApp->translate("drumset", qPrintable(nDrumset.name(pitch)))); }