void View::DrawMensuralNote(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure) { assert(dc); assert(element); assert(layer); assert(staff); assert(measure); Note *note = dynamic_cast<Note *>(element); assert(note); int noteY = element->GetDrawingY(); int xNote, xStem; int drawingDur; int staffY = staff->GetDrawingY(); wchar_t charCode; int verticalCenter = 0; bool mensural_black = (staff->m_drawingNotationType == NOTATIONTYPE_mensural_black); xStem = element->GetDrawingX(); drawingDur = note->GetDrawingDur(); int radius = m_doc->GetGlyphWidth(SMUFL_E93C_mensuralNoteheadMinimaWhite, staff->m_drawingStaffSize, false) / 2; if (drawingDur > DUR_1) { if (mensural_black) radius *= TEMP_MINIMA_WIDTH_FACTOR; } else { radius += radius / 3; } /************** Stem/notehead direction: **************/ data_STEMDIRECTION stemDir = STEMDIRECTION_NONE; verticalCenter = staffY - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 2; if (note->HasStemDir()) { stemDir = note->GetStemDir(); } else if (layer->GetDrawingStemDir() != STEMDIRECTION_NONE) { stemDir = layer->GetDrawingStemDir(); } else { if (drawingDur < DUR_1) stemDir = STEMDIRECTION_down; else stemDir = (noteY > verticalCenter) ? STEMDIRECTION_down : STEMDIRECTION_up; } xNote = xStem - radius; /************** Noteheads: **************/ // Ligature, maxima,longa, and brevis if ((note->GetLig() != noteLogMensural_LIG_NONE) && (drawingDur <= DUR_1)) { DrawLigatureNote(dc, element, layer, staff); } else if (drawingDur < DUR_1) { DrawMaximaToBrevis(dc, noteY, element, layer, staff); } // Semibrevis else if (drawingDur == DUR_1) { if (mensural_black) { int sbStaffSize = 0.8 * staff->m_drawingStaffSize; DrawDiamond(dc, xNote, noteY, 2 * sbStaffSize, (int)(1.2 * sbStaffSize), !note->GetColored(), 20); } else { // Maybe we can add this to Note::GetMensuralSmuflNoteHead? if (note->GetColored()) charCode = SMUFL_E938_mensuralNoteheadSemibrevisBlack; else charCode = SMUFL_E939_mensuralNoteheadSemibrevisVoid; DrawSmuflCode(dc, xNote, noteY, charCode, staff->m_drawingStaffSize, false); } } // Shorter values else { if (mensural_black) { // SMuFL 1.20 doesn't have a codepoint for the "colored" semibrevis and minima head in black // mensural notation. But an unfilled (void) narrow diamond is fine, so we draw one. int sbStaffSize = 0.8 * staff->m_drawingStaffSize; DrawDiamond(dc, xNote, noteY, 2 * sbStaffSize, (int)(TEMP_MINIMA_WIDTH_FACTOR * 2 * sbStaffSize), !note->GetColored(), 20); } else { DrawSmuflCode(dc, xNote, noteY, note->GetMensuralSmuflNoteHead(), staff->m_drawingStaffSize, false); } DrawMensuralStem(dc, note, staff, stemDir, radius, xStem, noteY); } /************ Draw children (verse / syl) ************/ DrawLayerChildren(dc, note, layer, staff, measure); }
void PatternView::mousePressEvent( QMouseEvent * _me ) { if( _me->button() == Qt::LeftButton && m_pat->m_patternType == Pattern::BeatPattern && ( fixedTCOs() || pixelsPerTact() >= 96 || m_pat->m_steps != MidiTime::stepsPerTact() ) && _me->y() > height() - s_stepBtnOff->height() ) // when mouse button is pressed in beat/bassline -mode { // get the step number that was clicked on and // do calculations in floats to prevent rounding errors... float tmp = ( ( float(_me->x()) - TCO_BORDER_WIDTH ) * float( m_pat -> m_steps ) ) / float(width() - TCO_BORDER_WIDTH*2); int step = int( tmp ); // debugging to ensure we get the correct step... // qDebug( "Step (%f) %d", tmp, step ); if( step >= m_pat->m_steps ) { qDebug( "Something went wrong in pattern.cpp: step %d doesn't exist in pattern!", step ); return; } Note * n = m_pat->noteAtStep( step ); // if note at step not found, ensureBeatNotes and try again if( n == NULL ) { m_pat -> ensureBeatNotes(); n = m_pat->noteAtStep( step ); if( n == NULL ) // still can't find a note? bail! { qDebug( "Something went wrong in pattern.cpp: couldn't add note at step %d!", step ); return; } } else // note at step found { if( n->length() < 0 ) { n->setLength( 0 ); // set note as enabled beat note } else { n->setLength( -DefaultTicksPerTact ); // set note as disabled beat note } } Engine::getSong()->setModified(); update(); if( gui->pianoRoll()->currentPattern() == m_pat ) { gui->pianoRoll()->update(); } } else // if not in beat/bassline -mode, let parent class handle the event { TrackContentObjectView::mousePressEvent( _me ); } }
void View::DrawSlurInitial(FloatingCurvePositioner *curve, Slur *slur, int x1, int x2, Staff *staff, char spanningType) { Beam *parentBeam = NULL; Chord *startParentChord = NULL; Chord *endParentChord = NULL; Note *startNote = NULL; Note *endNote = NULL; Chord *startChord = NULL; Chord *endChord = NULL; curvature_CURVEDIR drawingCurveDir = curvature_CURVEDIR_above; data_STEMDIRECTION startStemDir = STEMDIRECTION_NONE; data_STEMDIRECTION endStemDir = STEMDIRECTION_NONE; data_STEMDIRECTION stemDir = STEMDIRECTION_NONE; bool isGraceToNoteSlur = false; int y1 = staff->GetDrawingY(); int y2 = staff->GetDrawingY(); /************** parent layers **************/ LayerElement *start = dynamic_cast<LayerElement *>(slur->GetStart()); LayerElement *end = dynamic_cast<LayerElement *>(slur->GetEnd()); if (!start || !end) { // no start and end, obviously nothing to do... return; } if (start->Is(TIMESTAMP_ATTR) && end->Is(TIMESTAMP_ATTR)) { // for now ignore slur using 2 tstamps return; } if (start->Is(NOTE)) { startNote = dynamic_cast<Note *>(start); assert(startNote); startParentChord = startNote->IsChordTone(); startStemDir = startNote->GetDrawingStemDir(); } else if (start->Is(CHORD)) { startChord = dynamic_cast<Chord *>(start); assert(startChord); startStemDir = startChord->GetDrawingStemDir(); } if (end->Is(NOTE)) { endNote = dynamic_cast<Note *>(end); assert(endNote); endParentChord = endNote->IsChordTone(); endStemDir = endNote->GetDrawingStemDir(); } else if (end->Is(CHORD)) { endChord = dynamic_cast<Chord *>(end); assert(endChord); endStemDir = endChord->GetDrawingStemDir(); } if (startNote && endNote && startNote->IsGraceNote() && !endNote->IsGraceNote()) { isGraceToNoteSlur = true; } Layer *layer = NULL; LayerElement *layerElement = NULL; // For now, with timestamps, get the first layer. We should eventually look at the @layerident (not implemented) if (!start->Is(TIMESTAMP_ATTR)) { layer = dynamic_cast<Layer *>(start->GetFirstParent(LAYER)); layerElement = start; } else { layer = dynamic_cast<Layer *>(end->GetFirstParent(LAYER)); layerElement = end; } assert(layer); if (!start->Is(TIMESTAMP_ATTR) && !end->Is(TIMESTAMP_ATTR) && (spanningType == SPANNING_START_END)) { System *system = dynamic_cast<System *>(staff->GetFirstParent(SYSTEM)); assert(system); // If we have a start to end situation, then store the curvedir in the slur for mixed drawing stem dir // situations if (system->HasMixedDrawingStemDir(start, end)) { slur->SetDrawingCurvedir(curvature_CURVEDIR_above); } } /************** calculate the radius for adjusting the x position **************/ int startRadius = 0; if (!start->Is(TIMESTAMP_ATTR)) { startRadius = start->GetDrawingRadius(m_doc); } int endRadius = 0; if (!end->Is(TIMESTAMP_ATTR)) { endRadius = end->GetDrawingRadius(m_doc); } /************** note stem dir **************/ if (spanningType == SPANNING_START_END) { stemDir = startStemDir; } // This is the case when the tie is split over two system of two pages. // In this case, we are now drawing its beginning to the end of the measure (i.e., the last aligner) else if (spanningType == SPANNING_START) { stemDir = startStemDir; } // Now this is the case when the tie is split but we are drawing the end of it else if (spanningType == SPANNING_END) { stemDir = endStemDir; } // Finally, slur accross an entire system; use the staff position and up (see below) else { stemDir = STEMDIRECTION_down; } /************** direction **************/ data_STEMDIRECTION layerStemDir; // first should be the tie @curvedir if (slur->HasCurvedir()) { drawingCurveDir = (slur->GetCurvedir() == curvature_CURVEDIR_above) ? curvature_CURVEDIR_above : curvature_CURVEDIR_below; } // grace notes - always below unless we have a drawing stem direction on the layer else if (isGraceToNoteSlur && (layer->GetDrawingStemDir(layerElement) == STEMDIRECTION_NONE)) { drawingCurveDir = curvature_CURVEDIR_below; } // the normal case else if (slur->HasDrawingCurvedir()) { drawingCurveDir = slur->GetDrawingCurvedir(); } // then layer direction trumps note direction else if (layer && ((layerStemDir = layer->GetDrawingStemDir(layerElement)) != STEMDIRECTION_NONE)) { drawingCurveDir = (layerStemDir == STEMDIRECTION_up) ? curvature_CURVEDIR_above : curvature_CURVEDIR_below; } // look if in a chord else if (startParentChord) { if (startParentChord->PositionInChord(startNote) < 0) { drawingCurveDir = curvature_CURVEDIR_below; } else if (startParentChord->PositionInChord(startNote) > 0) { drawingCurveDir = curvature_CURVEDIR_above; } // away from the stem if odd number (center note) else { drawingCurveDir = (stemDir != STEMDIRECTION_up) ? curvature_CURVEDIR_above : curvature_CURVEDIR_below; } } else if (stemDir == STEMDIRECTION_up) { drawingCurveDir = curvature_CURVEDIR_below; } else if (stemDir == STEMDIRECTION_NONE) { // no information from the note stem directions, look at the position in the notes int center = staff->GetDrawingY() - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 2; drawingCurveDir = (start->GetDrawingY() > center) ? curvature_CURVEDIR_above : curvature_CURVEDIR_below; } /************** adjusting y position **************/ bool isShortSlur = false; if (x2 - x1 < 1 * m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)) isShortSlur = true; int yChordMax, yChordMin; if ((spanningType == SPANNING_START_END) || (spanningType == SPANNING_START)) { // first get the min max of the chord (if any) if (startParentChord) { startParentChord->GetYExtremes(yChordMax, yChordMin); } else if (startChord) { startChord->GetYExtremes(yChordMax, yChordMin); } // slur is up if (drawingCurveDir == curvature_CURVEDIR_above) { // P(^) if (startStemDir == STEMDIRECTION_down) y1 = start->GetDrawingTop(m_doc, staff->m_drawingStaffSize); // d(^)d else if (isShortSlur) { y1 = start->GetDrawingTop(m_doc, staff->m_drawingStaffSize); } // same but in beam - adjust the x too else if ((parentBeam = start->IsInBeam()) && !parentBeam->IsLastInBeam(start)) { y1 = start->GetDrawingTop(m_doc, staff->m_drawingStaffSize); x1 += startRadius - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize); } // d(^) else { // put it on the side, move it left, but not if we have a @stamp if (!start->Is(TIMESTAMP_ATTR)) x1 += m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 4 / 2; if (startChord || startParentChord) y1 = yChordMin + m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 3; else y1 = start->GetDrawingY() + m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 3; } } // slur is down else { // d(_) if (startStemDir == STEMDIRECTION_up) y1 = start->GetDrawingBottom(m_doc, staff->m_drawingStaffSize); // P(_)P else if (isShortSlur) { y1 = start->GetDrawingBottom(m_doc, staff->m_drawingStaffSize); } // same but in beam else if ((parentBeam = start->IsInBeam()) && !parentBeam->IsLastInBeam(start)) { y1 = start->GetDrawingBottom(m_doc, staff->m_drawingStaffSize); x1 -= startRadius - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize); } // P(_) else { // put it on the side, but no need to move it left if (startChord || startParentChord) y1 = yChordMin - m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 3; else y1 = start->GetDrawingY() - m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 3; } } } if ((spanningType == SPANNING_START_END) || (spanningType == SPANNING_END)) { // get the min max of the chord if any if (endParentChord) { endParentChord->GetYExtremes(yChordMax, yChordMin); } else if (endChord) { endChord->GetYExtremes(yChordMax, yChordMin); } // get the stem direction of the end // slur is up if (drawingCurveDir == curvature_CURVEDIR_above) { // (^)P if (endStemDir == STEMDIRECTION_down) y2 = end->GetDrawingTop(m_doc, staff->m_drawingStaffSize); // d(^)d else if (isShortSlur) { y2 = end->GetDrawingTop(m_doc, staff->m_drawingStaffSize); } // same but in beam - adjust the x too else if ((parentBeam = end->IsInBeam()) && !parentBeam->IsFirstInBeam(end)) { y2 = end->GetDrawingTop(m_doc, staff->m_drawingStaffSize); x2 += endRadius - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize); } // (^)d else { // put it on the side, no need to move it right if (endChord || endParentChord) y2 = yChordMin + m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 3; else y2 = end->GetDrawingY() + m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 3; } } else { if (isGraceToNoteSlur) { if (endNote) { y2 = endNote->GetDrawingY(); x2 -= m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 2; isShortSlur = true; } else { y2 = y1; } } // (_)d else if (endStemDir == STEMDIRECTION_up) y2 = end->GetDrawingBottom(m_doc, staff->m_drawingStaffSize); // P(_)P else if (isShortSlur) { y2 = end->GetDrawingBottom(m_doc, staff->m_drawingStaffSize); } // same but in beam else if ((parentBeam = end->IsInBeam()) && !parentBeam->IsFirstInBeam(end)) { y2 = end->GetDrawingBottom(m_doc, staff->m_drawingStaffSize); // x2 -= endRadius - m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize); } // (_)P else { // put it on the side, move it right, but not if we have a @stamp2 if (!end->Is(TIMESTAMP_ATTR)) x2 -= m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 2; if (endChord || endParentChord) y2 = yChordMin - m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 3; else y2 = end->GetDrawingY() - m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 3; } } } // Positions not attached to a note if (spanningType == SPANNING_START) { if (drawingCurveDir == curvature_CURVEDIR_above) y2 = std::max(staff->GetDrawingY(), y1); else y2 = std::min(staff->GetDrawingY() - m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize), y1); } if (end->Is(TIMESTAMP_ATTR)) { if (drawingCurveDir == curvature_CURVEDIR_above) y2 = std::max(staff->GetDrawingY(), y1); else y2 = std::min(staff->GetDrawingY() - m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize), y1); } if (spanningType == SPANNING_END) { if (drawingCurveDir == curvature_CURVEDIR_above) y1 = std::max(staff->GetDrawingY(), y2); else y1 = std::min(staff->GetDrawingY() - m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize), y2); } if (start->Is(TIMESTAMP_ATTR)) { if (drawingCurveDir == curvature_CURVEDIR_above) y1 = std::max(staff->GetDrawingY(), y2); else y1 = std::min(staff->GetDrawingY() - m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize), y2); } // slur accross an entire system; use the staff position else if (spanningType == SPANNING_MIDDLE) { // To be adjusted if (drawingCurveDir == curvature_CURVEDIR_above) y1 = staff->GetDrawingY(); else y1 = staff->GetDrawingY() - m_doc->GetDrawingStaffSize(staff->m_drawingStaffSize); y2 = y1; } /************** y position **************/ if (drawingCurveDir == curvature_CURVEDIR_above) { y1 += 1 * m_doc->GetDrawingUnit(staff->m_drawingStaffSize); y2 += 1 * m_doc->GetDrawingUnit(staff->m_drawingStaffSize); } else { y1 -= 1 * m_doc->GetDrawingUnit(staff->m_drawingStaffSize); y2 -= 1 * m_doc->GetDrawingUnit(staff->m_drawingStaffSize); } Point points[4]; points[0] = Point(x1, y1); points[3] = Point(x2, y2); float angle = CalcInitialSlur(curve, slur, staff, layer->GetN(), drawingCurveDir, points); int thickness = m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * m_options->m_slurThickness.GetValue(); curve->UpdateCurveParams(points, angle, thickness, drawingCurveDir); /************** articulation **************/ // First get all artic children ClassIdComparison matchType(ARTIC); ArrayOfObjects artics; ArrayOfObjects::iterator articIter; // the normal case or start if ((spanningType == SPANNING_START_END) || (spanningType == SPANNING_START)) { start->FindAllChildByComparison(&artics, &matchType); // Then the @n of each first staffDef for (articIter = artics.begin(); articIter != artics.end(); ++articIter) { Artic *artic = dynamic_cast<Artic *>(*articIter); assert(artic); ArticPart *outsidePart = artic->GetOutsidePart(); if (outsidePart) { if ((outsidePart->GetPlace().GetBasic() == STAFFREL_basic_above) && (drawingCurveDir == curvature_CURVEDIR_above)) { outsidePart->AddSlurPositioner(curve, true); } else if ((outsidePart->GetPlace().GetBasic() == STAFFREL_basic_below) && (drawingCurveDir == curvature_CURVEDIR_below)) { outsidePart->AddSlurPositioner(curve, true); } } } } // normal case or end if ((spanningType == SPANNING_START_END) || (spanningType == SPANNING_END)) { end->FindAllChildByComparison(&artics, &matchType); // Then the @n of each first staffDef for (articIter = artics.begin(); articIter != artics.end(); ++articIter) { Artic *artic = dynamic_cast<Artic *>(*articIter); assert(artic); ArticPart *outsidePart = artic->GetOutsidePart(); if (outsidePart) { if ((outsidePart->GetPlace().GetBasic() == STAFFREL_basic_above) && (drawingCurveDir == curvature_CURVEDIR_above)) { outsidePart->AddSlurPositioner(curve, false); } else if ((outsidePart->GetPlace().GetBasic() == STAFFREL_basic_below) && (drawingCurveDir == curvature_CURVEDIR_below)) { outsidePart->AddSlurPositioner(curve, false); } } } } return; }
int GuitarPro5::readBeat(int tick, int voice, Measure* measure, int staffIdx, Tuplet** tuplets, bool /*mixChange*/) { uchar beatBits = readUChar(); bool dotted = beatBits & BEAT_DOTTED; slide = -1; int track = staffIdx * VOICES + voice; if (slides.contains(track)) slide = slides.take(track); int pause = -1; if (beatBits & BEAT_PAUSE) pause = readUChar(); // readDuration int len = readChar(); int tuple = 0; if (beatBits & BEAT_TUPLET) tuple = readInt(); Segment* segment = measure->getSegment(Segment::Type::ChordRest, tick); if (beatBits & BEAT_CHORD) { int numStrings = score->staff(staffIdx)->part()->instr()->stringData()->strings(); skip(17); QString name = readPascalString(21); skip(4); // no header to be read in the GP5 format - default to true. readChord(segment, staffIdx * VOICES, numStrings, name, true); skip(32); } Lyrics* lyrics = 0; if (beatBits & BEAT_LYRICS) { QString txt = readDelphiString(); lyrics = new Lyrics(score); lyrics->setText(txt); } gpLyrics.beatCounter++; if (gpLyrics.beatCounter >= gpLyrics.fromBeat && gpLyrics.lyricTrack == staffIdx+1) { int index = gpLyrics.beatCounter - gpLyrics.fromBeat; if (index < gpLyrics.lyrics.size()) { lyrics = new Lyrics(score); lyrics->setText(gpLyrics.lyrics[index]); } } int beatEffects = 0; if (beatBits & BEAT_EFFECTS) beatEffects = readBeatEffects(track, segment); if (beatBits & BEAT_MIX_CHANGE) readMixChange(measure); int strings = readUChar(); // used strings mask Fraction l = len2fraction(len); // Some beat effects could add a Chord before this ChordRest* cr = segment->cr(track); if (voice != 0 && pause == 0 && strings == 0) cr = 0; else { if (strings == 0) { if (cr) { segment->remove(cr); delete cr; cr = 0; } cr = new Rest(score); } else { if (!cr) cr = new Chord(score); } cr->setTrack(track); TDuration d(l); d.setDots(dotted ? 1 : 0); if (dotted) l = l + (l/2); if (tuple) { Tuplet* tuplet = tuplets[staffIdx * 2 + voice]; if ((tuplet == 0) || (tuplet->elementsDuration() == tuplet->baseLen().fraction() * tuplet->ratio().numerator())) { tuplet = new Tuplet(score); // int track = staffIdx * 2 + voice; tuplets[staffIdx * 2 + voice] = tuplet; tuplet->setTrack(cr->track()); setTuplet(tuplet, tuple); tuplet->setParent(measure); } tuplet->setTrack(cr->track()); tuplet->setBaseLen(l); tuplet->setDuration(l * tuplet->ratio().denominator()); cr->setTuplet(tuplet); tuplet->add(cr); } cr->setDuration(l); if (cr->type() == Element::Type::REST && (pause == 0 || l == measure->len())) cr->setDurationType(TDuration::DurationType::V_MEASURE); else cr->setDurationType(d); if(!segment->cr(track)) segment->add(cr); Staff* staff = cr->staff(); int numStrings = staff->part()->instr()->stringData()->strings(); bool hasSlur = false; for (int i = 6; i >= 0; --i) { if (strings & (1 << i) && ((6-i) < numStrings)) { Note* note = new Note(score); if (dotted) { // there is at most one dotted note in this guitar pro version NoteDot* dot = new NoteDot(score); dot->setIdx(0); dot->setParent(note); dot->setTrack(track); // needed to know the staff it belongs to (and detect tablature) dot->setVisible(true); note->add(dot); } static_cast<Chord*>(cr)->add(note); hasSlur = readNote(6-i, note); note->setTpcFromPitch(); } } createSlur(hasSlur, staffIdx, cr); if (lyrics) cr->add(lyrics); } int rr = readChar(); if (cr && (cr->type() == Element::Type::CHORD)) { Chord* chord = static_cast<Chord*>(cr); applyBeatEffects(chord, beatEffects); if (rr == ARPEGGIO_DOWN) chord->setStemDirection(MScore::Direction::DOWN); else if (rr == ARPEGGIO_UP) chord->setStemDirection(MScore::Direction::UP); } int r = readChar(); if (r & 0x8) { int rrr = readChar(); qDebug(" 3beat read 0x%02x", rrr); } if (cr && (cr->type() == Element::Type::CHORD) && slide > 0) createSlide(slide, cr, staffIdx); restsForEmptyBeats(segment, measure, cr, l, track, tick); return cr ? cr->actualTicks() : measure->ticks(); }
bool NoteHistoryItem::isNoteValid() { Note note = getNote(); return note.exists(); }
void Bend::layout() { // during mtest, there may be no score. If so, exit. if (!score()) return; qreal _spatium = spatium(); if (staff() && !staff()->isTabStaff(tick())) { if (!parent()) { noteWidth = -_spatium*2; notePos = QPointF(0.0, _spatium*3); } } qreal _lw = _lineWidth; Note* note = toNote(parent()); if (note == 0) { noteWidth = 0.0; notePos = QPointF(); } else { notePos = note->pos(); noteWidth = note->width(); } QRectF bb; QFontMetricsF fm(font(_spatium), MScore::paintDevice()); int n = _points.size(); qreal x = noteWidth; qreal y = -_spatium * .8; qreal x2, y2; qreal aw = _spatium * .5; QPolygonF arrowUp; arrowUp << QPointF(0, 0) << QPointF(aw*.5, aw) << QPointF(-aw*.5, aw); QPolygonF arrowDown; arrowDown << QPointF(0, 0) << QPointF(aw*.5, -aw) << QPointF(-aw*.5, -aw); for (int pt = 0; pt < n; ++pt) { if (pt == (n-1)) break; int pitch = _points[pt].pitch; if (pt == 0 && pitch) { y2 = -notePos.y() -_spatium * 2; x2 = x; bb |= QRectF(x, y, x2-x, y2-y); bb |= arrowUp.translated(x2, y2 + _spatium * .2).boundingRect(); int idx = (pitch + 12)/25; const char* l = label[idx]; bb |= fm.boundingRect(QRectF(x2, y2, 0, 0), Qt::AlignHCenter | Qt::AlignBottom | Qt::TextDontClip, QString(l)); y = y2; } if (pitch == _points[pt+1].pitch) { if (pt == (n-2)) break; x2 = x + _spatium; y2 = y; bb |= QRectF(x, y, x2-x, y2-y); } else if (pitch < _points[pt+1].pitch) { // up x2 = x + _spatium*.5; y2 = -notePos.y() -_spatium * 2; qreal dx = x2 - x; qreal dy = y2 - y; QPainterPath path; path.moveTo(x, y); path.cubicTo(x+dx/2, y, x2, y+dy/4, x2, y2); bb |= path.boundingRect(); bb |= arrowUp.translated(x2, y2 + _spatium * .2).boundingRect(); int idx = (_points[pt+1].pitch + 12)/25; const char* l = label[idx]; QRectF r; bb |= fm.boundingRect(QRectF(x2, y2, 0, 0), Qt::AlignHCenter | Qt::AlignBottom | Qt::TextDontClip, QString(l)); } else { // down x2 = x + _spatium*.5; y2 = y + _spatium * 3; qreal dx = x2 - x; qreal dy = y2 - y; QPainterPath path; path.moveTo(x, y); path.cubicTo(x+dx/2, y, x2, y+dy/4, x2, y2); bb |= path.boundingRect(); bb |= arrowDown.translated(x2, y2 - _spatium * .2).boundingRect(); } x = x2; y = y2; } bb.adjust(-_lw, -_lw, _lw, _lw); setbbox(bb); setPos(0.0, 0.0); }
static void writeChord(KoXmlWriter& w, Chord* chord, Voice* voice, Part* part, int bar) { if (!chord->noteCount()) { w.startElement("music:note"); w.startElement("music:rest"); w.endElement(); // music:rest w.startElement("music:duration"); w.addTextNode(QString::number(chord->length())); w.endElement(); // music:duration w.startElement("music:voice"); w.addTextNode(QString::number(part->indexOfVoice(voice) + 1)); w.endElement(); // music:voice w.startElement("music:type"); w.addTextNode(durationToString(chord->duration())); w.endElement(); // music:type for (int i = 0; i < chord->dots(); i++) { w.startElement("music:dot"); w.endElement(); // music:dot } if (part->staffCount() > 1) { // only write staff info when more than one staff exists Staff* s = chord->staff(); w.startElement("music:staff"); w.addTextNode(QString::number(part->indexOfStaff(s) + 1)); w.endElement(); //music:staff } w.endElement(); // music:note } else for (int n = 0; n < chord->noteCount(); n++) { Staff* staff = chord->note(n)->staff(); w.startElement("music:note"); if (n > 0) { w.startElement("music:chord"); w.endElement(); // music:chord } w.startElement("music:pitch"); w.startElement("music:step"); int pitch = chord->note(n)->pitch(); char note = 'A' + ((((pitch + 2) % 7) + 7) % 7); w.addTextNode(QString(note)); w.endElement(); // music:step if (chord->note(n)->accidentals()) { w.startElement("music:alter"); w.addTextNode(QString::number(chord->note(n)->accidentals())); w.endElement(); // music:alter } w.startElement("music:octave"); w.addTextNode(QString::number((pitch + 4*7) / 7)); // first add, than divide to get proper rounding w.endElement(); // music:octave w.endElement(); // music:pitch w.startElement("music:duration"); w.addTextNode(QString::number(chord->length())); w.endElement(); // music:duration w.startElement("music:voice"); w.addTextNode(QString::number(part->indexOfVoice(voice) + 1)); w.endElement(); // music:voice w.startElement("music:type"); w.addTextNode(durationToString(chord->duration())); w.endElement(); // music:type for (int i = 0; i < chord->dots(); i++) { w.startElement("music:dot"); w.endElement(); // music:dot } int activeAccidentals = 0; KeySignature* ks = staff->lastKeySignatureChange(bar); if (ks) activeAccidentals = ks->accidentals(chord->note(n)->pitch()); VoiceBar* vb = chord->voiceBar(); // next check the bar for the last previous note in the same voice with the same pitch for (int e = 0; e < vb->elementCount(); e++) { Chord* c = dynamic_cast<Chord*>(vb->element(e)); if (!c) continue; if (c == chord) break; for (int nid = 0; nid < c->noteCount(); nid++) { Note* note = c->note(nid); if (note->staff() != staff) continue; if (note->pitch() == chord->note(n)->pitch()) { activeAccidentals = note->accidentals(); } } } if (chord->note(n)->accidentals() != activeAccidentals) { w.startElement("music:accidental"); switch (chord->note(n)->accidentals()) { case -2: w.addTextNode("flat-flat"); break; case -1: w.addTextNode("flat"); break; case 0: w.addTextNode("natural"); break; case 1: w.addTextNode("sharp"); break; case 2: w.addTextNode("double-sharp"); break; } w.endElement(); // music:accidental } if (part->staffCount() > 1) { // only write staff info when more than one staff exists Staff* s = chord->note(n)->staff(); w.startElement("music:staff"); w.addTextNode(QString::number(part->indexOfStaff(s) + 1)); w.endElement(); //music:staff } w.endElement(); // music:note } }
void View::DrawLigature ( DeviceContext *dc, int y, LayerElement *element, Layer *layer, Staff *staff ) { assert( dc ); assert( element ); assert( layer ); assert( staff ); Note *note = dynamic_cast<Note*>(element); assert( note ); int xn, x1, x2, y1, y2, y3, y4; // int yy2, y5; // unused int verticalCenter, up, epaisseur; epaisseur = std::max (2, m_doc->GetDrawingBeamWidth(staff->m_drawingStaffSize, false) / 2); xn = element->GetDrawingX(); /* if ((note->m_lig==LIG_MEDIAL) || (note->m_lig==LIG_TERMINAL)) { CalculateLigaturePosX ( element, layer, staff ); } else */{ xn = element->GetDrawingX(); } // calcul des dimensions du rectangle x1 = xn - m_doc->GetDrawingBrevisWidth(staff->m_drawingStaffSize); x2 = xn + m_doc->GetDrawingBrevisWidth(staff->m_drawingStaffSize); y1 = y + m_doc->GetDrawingUnit(staff->m_drawingStaffSize); y2 = y - m_doc->GetDrawingUnit(staff->m_drawingStaffSize); y3 = (int)(y1 + m_doc->GetDrawingUnit(staff->m_drawingStaffSize)/2); // partie d'encadrement qui depasse y4 = (int)(y2 - m_doc->GetDrawingUnit(staff->m_drawingStaffSize)/2); //if (!note->m_ligObliqua && (!View::s_drawingLigObliqua)) // notes rectangulaires, y c. en ligature { if (note->GetColored()!=BOOLEAN_true) { // double base des carrees DrawObliquePolygon ( dc, x1, y1, x2, y1, -epaisseur ); DrawObliquePolygon ( dc, x1, y2, x2, y2, epaisseur ); } else DrawFullRectangle( dc,x1,y1,x2,y2); // dessine val carree pleine // ENZ correction de x2 DrawVerticalLine ( dc, y3, y4, x1, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) ); // corset lateral DrawVerticalLine ( dc, y3, y4, x2, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) ); } /* else // traitement des obliques { if (!View::s_drawingLigObliqua) // 1e passage: ligne flagStemHeighte initiale { DrawVerticalLine (dc,y3,y4,x1, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) ); View::s_drawingLigObliqua = true; //oblique = OFF; // if (val == DUR_1) // queue gauche haut si DUR_1 // queue_lig = ON; } else // 2e passage: lignes obl. et flagStemHeighte finale { x1 -= m_doc->m_drawingBrevisWidth[staff->m_drawingStaffSize]*2; // avance auto y1 = *View::s_drawingLigY - m_doc->GetDrawingUnit(staff->m_drawingStaffSize); // ligat_y contient y original yy2 = y2; y5 = y1+ m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); y2 += m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); // on monte d'un INTERL if (note->GetColored()==BOOLEAN_true) DrawObliquePolygon ( dc, x1, y1, x2, yy2, m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)); else { DrawObliquePolygon ( dc, x1, y1, x2, yy2, 5); DrawObliquePolygon ( dc, x1, y5, x2, y2, -5); } DrawVerticalLine ( dc,y3,y4,x2,m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); //cloture flagStemHeighte View::s_drawingLigObliqua = false; // queue_lig = OFF; //desamorce alg.queue DUR_BR } } if (note->m_lig) // memoriser positions d'une note a l'autre; relier notes par barres { *(View::s_drawingLigX+1) = x2; *(View::s_drawingLigY+1) = y; // relie notes ligaturees par barres flagStemHeightes //if (in(x1,(*View::s_drawingLigX)-2,(*View::s_drawingLigX)+2) || (this->fligat && this->lat && !Note1::marq_obl)) // les dernieres conditions pour permettre ligature flagStemHeighte ancienne // DrawVerticalLine (dc, *ligat_y, y1, (this->fligat && this->lat) ? x2: x1, m_doc->m_parameters.m_stemWidth); // ax2 - drawing flagStemHeight lines missing *View::s_drawingLigX = *(View::s_drawingLigX + 1); *View::s_drawingLigY = *(View::s_drawingLigY + 1); } y3 = y2 - m_doc->GetDrawingUnit(staff->m_drawingStaffSize)*6; if (note->m_lig) { if (note->m_dur == DUR_BR) // && this->queue_lig) // queue gauche bas: DUR_BR initiale descendante // ax2 - no support of queue_lig (see WG corrigeLigature) { DrawVerticalLine ( dc, y2, y3, x1, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) ); } else if (note->m_dur == DUR_LG) // && !this->queue_lig) // DUR_LG en ligature, queue droite bas // ax2 - no support of queue_lig { DrawVerticalLine (dc, y2, y3, x2, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) ); } else if (note->m_dur == DUR_1) // && this->queue_lig ) // queue gauche haut // ax2 - no support of queue_lig { y2 = y1 + m_doc->GetDrawingUnit(staff->m_drawingStaffSize)*6; DrawVerticalLine ( dc, y1, y2, x1, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) ); } } else if (note->m_dur == DUR_LG) // DUR_LG isolee: queue comme notes normales */ if (note->GetActualDur() == DUR_LG) { verticalCenter = staff->GetDrawingY() - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)*2; // ENZ up = (y < verticalCenter) ? ON : OFF; // ENZ if ( note->GetDrawingStemDir() != STEMDIRECTION_NONE ) { if ( note->GetDrawingStemDir() == STEMDIRECTION_up) { up = ON; } else { up = OFF; } } if (!up) { y3 = y1 - m_doc->GetDrawingUnit(staff->m_drawingStaffSize)*8; y2 = y1; } else { y3 = y1 + m_doc->GetDrawingUnit(staff->m_drawingStaffSize)*6; y2 = y1; } DrawVerticalLine ( dc, y2,y3,x2, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) ); } return; }
NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, const f_cnt_t _offset, const f_cnt_t _frames, const Note& n, NotePlayHandle *parent, int midiEventChannel, Origin origin ) : PlayHandle( TypeNotePlayHandle, _offset ), Note( n.length(), n.pos(), n.key(), n.getVolume(), n.getPanning(), n.detuning() ), m_pluginData( NULL ), m_filter( NULL ), m_instrumentTrack( instrumentTrack ), m_frames( 0 ), m_totalFramesPlayed( 0 ), m_framesBeforeRelease( 0 ), m_releaseFramesToDo( 0 ), m_releaseFramesDone( 0 ), m_subNotes(), m_released( false ), m_hasParent( parent != NULL ), m_parent( parent ), m_hadChildren( false ), m_muted( false ), m_bbTrack( NULL ), m_origTempo( Engine::getSong()->getTempo() ), m_origBaseNote( instrumentTrack->baseNote() ), m_frequency( 0 ), m_unpitchedFrequency( 0 ), m_baseDetuning( NULL ), m_songGlobalParentOffset( 0 ), m_midiChannel( midiEventChannel >= 0 ? midiEventChannel : instrumentTrack->midiPort()->realOutputChannel() ), m_origin( origin ), m_frequencyNeedsUpdate( false ) { lock(); if( hasParent() == false ) { m_baseDetuning = new BaseDetuning( detuning() ); m_instrumentTrack->m_processHandles.push_back( this ); } else { m_baseDetuning = parent->m_baseDetuning; parent->m_subNotes.push_back( this ); parent->m_hadChildren = true; m_bbTrack = parent->m_bbTrack; parent->setUsesBuffer( false ); } updateFrequency(); setFrames( _frames ); // inform attached components about new MIDI note (used for recording in Piano Roll) if( m_origin == OriginMidiInput ) { m_instrumentTrack->midiNoteOn( *this ); } if( hasParent() || ! m_instrumentTrack->isArpeggioEnabled() ) { const int baseVelocity = m_instrumentTrack->midiPort()->baseVelocity(); // send MidiNoteOn event m_instrumentTrack->processOutEvent( MidiEvent( MidiNoteOn, midiChannel(), midiKey(), midiVelocity( baseVelocity ) ), MidiTime::fromFrames( offset(), Engine::framesPerTick() ), offset() ); } if( m_instrumentTrack->instrument()->flags() & Instrument::IsSingleStreamed ) { setUsesBuffer( false ); } setAudioPort( instrumentTrack->audioPort() ); unlock(); }
void View::DrawMensuralNote ( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert( dc ); assert( element ); assert( layer ); assert( staff ); assert( measure ); Note *note = dynamic_cast<Note*>(element); assert( note ); int staffSize = staff->m_drawingStaffSize; int noteY = element->GetDrawingY(); int xLedger, xNote, xStem; int drawingDur; bool drawingCueSize; int staffY = staff->GetDrawingY(); wchar_t fontNo; int ledge; int verticalCenter = 0; xStem = element->GetDrawingX(); xLedger = xStem; drawingDur = note->GetDrawingDur(); drawingCueSize = note->HasGrace(); int radius = m_doc->GetGlyphWidth(SMUFL_E0A3_noteheadHalf, staffSize, drawingCueSize); if (drawingDur > DUR_1 || (drawingDur == DUR_1 && staff->notAnc)) { // annuler provisoirement la modif. des lignes addit. ledge = m_doc->GetDrawingLedgerLineLength(staffSize, drawingCueSize); } else { ledge = m_doc->GetDrawingLedgerLineLength(staffSize, drawingCueSize); radius += radius/3; } /************** Stem/notehead direction: **************/ verticalCenter = staffY - m_doc->GetDrawingDoubleUnit(staffSize)*2; data_STEMDIRECTION noteStemDir = note->CalcDrawingStemDir(); if ( noteStemDir != STEMDIRECTION_NONE ) { note->SetDrawingStemDir( noteStemDir ); } else if ( layer->GetDrawingStemDir() != STEMDIRECTION_NONE) { note->SetDrawingStemDir( layer->GetDrawingStemDir() ); } else { note->SetDrawingStemDir((noteY >= verticalCenter) ? STEMDIRECTION_down : STEMDIRECTION_up); } xNote = xStem - radius; /************** Noteheads: **************/ // Long, breve and ligatures if ((note->GetLig()!=LIGATURE_NONE) && (drawingDur <= DUR_1)) { DrawLigature ( dc, noteY, element, layer, staff); } else if (drawingDur < DUR_1) { DrawMaximaToBrevis( dc, noteY, element, layer, staff); } else if (drawingDur == DUR_1) { if (note->GetColored()) fontNo = SMUFL_E938_mensuralNoteheadSemibrevisBlack; else fontNo = SMUFL_E939_mensuralNoteheadSemibrevisVoid; DrawSmuflCode( dc, xNote, noteY, fontNo, staff->m_drawingStaffSize, drawingCueSize ); } // Other values ??WE WANT MENSURAL NOTEHEADS, NOT CMN!!!!!!!! else { if (note->GetColored()) { if (drawingDur == DUR_2) fontNo = SMUFL_E0A4_noteheadBlack; else fontNo = SMUFL_E0A3_noteheadHalf; } else { if (drawingDur > DUR_2) fontNo = SMUFL_E0A4_noteheadBlack; else fontNo = SMUFL_E0A3_noteheadHalf; } DrawSmuflCode( dc, xNote, noteY, fontNo, staff->m_drawingStaffSize, drawingCueSize ); DrawStem(dc, note, staff, note->GetDrawingStemDir(), radius, xStem, noteY); } /************** Ledger lines: **************/ int staffTop = staffY + m_doc->GetDrawingUnit(staffSize); int staffBot = staffY - m_doc->GetDrawingStaffSize(staffSize) - m_doc->GetDrawingUnit(staffSize); //if the note is not in the staff if (!is_in(noteY,staffTop,staffBot)) { int distance, highestNewLine, numLines; bool aboveStaff = (noteY > staffTop); distance = (aboveStaff ? (noteY - staffY) : staffY - m_doc->GetDrawingStaffSize(staffSize) - noteY); highestNewLine = ((distance % m_doc->GetDrawingDoubleUnit(staffSize) > 0) ? (distance - m_doc->GetDrawingUnit(staffSize)) : distance); numLines = highestNewLine / m_doc->GetDrawingDoubleUnit(staffSize); DrawLedgerLines(dc, note, staff, aboveStaff, false, 0, numLines); } /************** dots **************/ if (note->GetDots()) { int xDot; if (note->GetDur() < DUR_2 || (note->GetDur() > DUR_8 && (note->GetDrawingStemDir() == STEMDIRECTION_up))) xDot = xStem + m_doc->GetDrawingUnit(staffSize)*7/2; else xDot = xStem + m_doc->GetDrawingUnit(staffSize)*5/2; DrawDots( dc, xDot, noteY, note->GetDots(), staff ); } }
void View::DrawMaximaToBrevis( DeviceContext *dc, int y, LayerElement *element, Layer *layer, Staff *staff ) { assert( dc ); assert( element ); assert( layer ); assert( staff ); Note *note = dynamic_cast<Note*>(element); assert( note ); int xn, x1, x2, y1, y2, y3, y4; // int yy2, y5; // unused int verticalCenter, up, height; height = m_doc->GetDrawingBeamWidth(staff->m_drawingStaffSize, false) / 2 ; xn = element->GetDrawingX(); // calcul des dimensions du rectangle x1 = xn - m_doc->GetDrawingBrevisWidth( staff->m_drawingStaffSize ); x2 = xn + m_doc->GetDrawingBrevisWidth( staff->m_drawingStaffSize ); if (note->GetActualDur() == DUR_MX) { x1 -= m_doc->GetDrawingBrevisWidth( staff->m_drawingStaffSize ); x2 += m_doc->GetDrawingBrevisWidth( staff->m_drawingStaffSize ); } y1 = y + m_doc->GetDrawingUnit(staff->m_drawingStaffSize); y2 = y - m_doc->GetDrawingUnit(staff->m_drawingStaffSize); y3 = (int)(y1 + m_doc->GetDrawingUnit(staff->m_drawingStaffSize)/2); // partie d'encadrement qui depasse y4 = (int)(y2 - m_doc->GetDrawingUnit(staff->m_drawingStaffSize)/2); if (note->GetColored()!=BOOLEAN_true) { // double base des carrees DrawObliquePolygon ( dc, x1, y1, x2, y1, -height ); DrawObliquePolygon ( dc, x1, y2, x2, y2, height ); } else { DrawFullRectangle( dc,x1,y1,x2,y2); } DrawVerticalLine ( dc, y3, y4, x1, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) ); // corset lateral DrawVerticalLine ( dc, y3, y4, x2, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) ); // stem if (note->GetActualDur() < DUR_BR) { verticalCenter = staff->GetDrawingY() - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)*2; up = (y < verticalCenter) ? true : false; if ( note->GetDrawingStemDir() != STEMDIRECTION_NONE ) { if ( note->GetDrawingStemDir() == STEMDIRECTION_up) { up = true; } else { up = false; } } if (!up) { y3 = y1 - m_doc->GetDrawingUnit(staff->m_drawingStaffSize)*8; y2 = y1; } else { y3 = y1 + m_doc->GetDrawingUnit(staff->m_drawingStaffSize)*6; y2 = y1; } DrawVerticalLine ( dc, y2,y3,x2, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize) ); } return; }
void Sampler::setPlayingNotelength( Instrument* instrument, unsigned long ticks, unsigned long noteOnTick ) { if ( instrument ) { // stop all notes using this instrument Hydrogen *pEngine = Hydrogen::get_instance(); Song* mSong = pEngine->getSong(); int selectedpattern = pEngine->__get_selected_PatterNumber(); Pattern* currentPattern = NULL; if ( mSong->get_mode() == Song::PATTERN_MODE || ( pEngine->getState() != STATE_PLAYING )){ PatternList *pPatternList = mSong->get_pattern_list(); if ( ( selectedpattern != -1 ) && ( selectedpattern < ( int )pPatternList->size() ) ) { currentPattern = pPatternList->get( selectedpattern ); } }else { std::vector<PatternList*> *pColumns = mSong->get_pattern_group_vector(); // Pattern *pPattern = NULL; int pos = pEngine->getPatternPos() +1; for ( int i = 0; i < pos; ++i ) { PatternList *pColumn = ( *pColumns )[i]; currentPattern = pColumn->get( 0 ); } } if ( currentPattern ) { int patternsize = currentPattern->get_length(); for ( unsigned nNote = 0; nNote < currentPattern->get_length(); nNote++ ) { const Pattern::notes_t* notes = currentPattern->get_notes(); FOREACH_NOTE_CST_IT_BOUND(notes,it,nNote) { Note *pNote = it->second; if ( pNote!=NULL ) { if( !Preferences::get_instance()->__playselectedinstrument ){ if ( pNote->get_instrument() == instrument && pNote->get_position() == noteOnTick ) { AudioEngine::get_instance()->lock( RIGHT_HERE ); if ( ticks > patternsize ) ticks = patternsize - noteOnTick; pNote->set_length( ticks ); Hydrogen::get_instance()->getSong()->__is_modified = true; AudioEngine::get_instance()->unlock(); // unlock the audio engine } }else { if ( pNote->get_instrument() == pEngine->getSong()->get_instrument_list()->get( pEngine->getSelectedInstrumentNumber()) && pNote->get_position() == noteOnTick ) { AudioEngine::get_instance()->lock( RIGHT_HERE ); if ( ticks > patternsize ) ticks = patternsize - noteOnTick; pNote->set_length( ticks ); Hydrogen::get_instance()->getSong()->__is_modified = true; AudioEngine::get_instance()->unlock(); // unlock the audio engine } } } } } } }
void Tremolo::layout() { qreal _spatium = spatium(); qreal w2 = _spatium * score()->styleS(ST_tremoloWidth).val() * .5; qreal h2 = _spatium * score()->styleS(ST_tremoloBoxHeight).val() * .5; qreal lw = _spatium * score()->styleS(ST_tremoloStrokeWidth).val(); qreal td = _spatium * score()->styleS(ST_tremoloDistance).val(); path = QPainterPath(); qreal ty = 0.0; for (int i = 0; i < _lines; ++i) { path.moveTo(-w2, ty + h2 - lw); path.lineTo( w2, ty - h2); path.lineTo( w2, ty - h2 + lw); path.lineTo(-w2, ty + h2); path.closeSubpath(); ty += td; } setbbox(path.boundingRect()); _chord1 = static_cast<Chord*>(parent()); if (_chord1 == 0) return; Note* anchor1 = _chord1->upNote(); Stem* stem = _chord1->stem(); qreal x, y, h; if (stem) { x = stem->pos().x(); y = stem->pos().y(); h = stem->stemLen(); } else { // center tremolo above note x = anchor1->x() + anchor1->headWidth() * .5; y = anchor1->y(); h = 2.0 * _spatium + bbox().height(); if (anchor1->line() > 4) h *= -1; } if (!twoNotes()) { // // single note tremolos // bool up = _chord1->up(); int line = up ? _chord1->upLine() : _chord1->downLine(); static const qreal t[3][2][4][2] = { // normal stem { // DOWN { // even line odd line { 6, 5 }, // line 1 { 6 - 2 * .8, 5 - 2 * .8 }, // line 2 { 6 - 4 * .8, 3 }, // line 3 { 2 , 3 } // line 4 }, // UP { // even line odd line { -6, -5 }, // line 1 { -6, -5 }, // line 2 { -6, -3 - 4 * .8 }, // line 3 { -2 - 6 * .8, -3 - 6 * .8 } // line 4 } }, // stem with hook { // DOWN { // even line odd line { 3, 3 }, // line 1 { 2, 2 }, // line 2 { 2, 2 }, // line 3 { 2, 2 } // line 4 }, // UP { // even line odd line { -3, -3 }, // line 1 { -2 - 2 * .8, -2 - 2 * .8 }, // line 2 { -2 - 4 * .8, -2 - 4 * .8 }, // line 3 { -2 - 6 * .8, -2 - 6 * .8 } // line 4 } }, // stem with beam { // DOWN { // even line odd line { 3, 3 }, // line 1 { 2, 2 }, // line 2 { 2, 2 }, // line 3 { 2, 2 } // line 4 }, // UP { // even line odd line { -3, -3 }, // line 1 { -2 - 2 * .8, -2 - 2 * .8 }, // line 2 { -2 - 4 * .8, -2 - 4 * .8 }, // line 3 { -2 - 6 * .8, -2 - 6 * .8 } // line 4 } }, }; int idx = _chord1->hook() ? 1 : (_chord1->beam() ? 2 : 0); y = (line + t[idx][up][_lines-1][line & 1]) * _spatium * .5; setPos(x, y); _chord1->setTremoloChordType(TremoloSingle); return; } y += (h - bbox().height()) * .5; // // two chord tremolo // Segment* s = _chord1->segment()->next(); while (s) { if (s->element(track()) && (s->element(track())->type() == CHORD)) break; s = s->next(); } if (s == 0) { qDebug("no second note of tremolo found\n"); return; } _chord1->setTremoloChordType(TremoloFirstNote); _chord2 = static_cast<Chord*>(s->element(track())); _chord2->setTremolo(this); _chord2->setTremoloChordType(TremoloSecondNote); Note* note = _chord2->up() ? _chord2->upNote() : _chord2->downNote(); int x2 = note->stemPos(_chord2->up()).x(); note = _chord1->up() ? _chord1->upNote() : _chord1->downNote(); int x1 = note->stemPos(_chord1->up()).x(); // qreal x2 = _chord2->_chord2->up()stemPos(_chord2->up(), true).x(); // qreal x1 = _chord1->stemPos(_chord1->up(), true).x(); x = x1 - _chord1->pagePos().x() + (x2 - x1 + note->headWidth()) * .5; setPos(x, y); }
void PatternView::paintEvent( QPaintEvent * ) { if( m_needsUpdate == false ) { QPainter p( this ); p.drawPixmap( 0, 0, m_paintPixmap ); return; } QPainter _p( this ); const QColor styleColor = _p.pen().brush().color(); m_pat->changeLength( m_pat->length() ); m_needsUpdate = false; if( m_paintPixmap.isNull() == true || m_paintPixmap.size() != size() ) { m_paintPixmap = QPixmap( size() ); } QPainter p( &m_paintPixmap ); QLinearGradient lingrad( 0, 0, 0, height() ); QColor c; if(( m_pat->m_patternType != Pattern::BeatPattern ) && !( m_pat->getTrack()->isMuted() || m_pat->isMuted() )) { c = styleColor; } else { c = QColor( 80, 80, 80 ); } if( isSelected() == true ) { c.setRgb( qMax( c.red() - 128, 0 ), qMax( c.green() - 128, 0 ), 255 ); } if( m_pat->m_patternType != Pattern::BeatPattern ) { lingrad.setColorAt( 1, c.darker( 300 ) ); lingrad.setColorAt( 0, c ); } else { lingrad.setColorAt( 0, c.darker( 300 ) ); lingrad.setColorAt( 1, c ); } p.setBrush( lingrad ); if( gui->pianoRoll()->currentPattern() == m_pat && m_pat->m_patternType != Pattern::BeatPattern ) p.setPen( c.lighter( 130 ) ); else p.setPen( c.darker( 300 ) ); p.drawRect( QRect( 0, 0, width() - 1, height() - 1 ) ); p.setBrush( QBrush() ); if( m_pat->m_patternType != Pattern::BeatPattern ) { if( gui->pianoRoll()->currentPattern() == m_pat ) p.setPen( c.lighter( 160 ) ); else p.setPen( c.lighter( 130 ) ); p.drawRect( QRect( 1, 1, width() - 3, height() - 3 ) ); } const float ppt = fixedTCOs() ? ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH ) / (float) m_pat->length().getTact() : ( width() - 2 * TCO_BORDER_WIDTH ) / (float) m_pat->length().getTact(); const int x_base = TCO_BORDER_WIDTH; p.setPen( c.darker( 300 ) ); for( tact_t t = 1; t < m_pat->length().getTact(); ++t ) { p.drawLine( x_base + static_cast<int>( ppt * t ) - 1, TCO_BORDER_WIDTH, x_base + static_cast<int>( ppt * t ) - 1, 5 ); p.drawLine( x_base + static_cast<int>( ppt * t ) - 1, height() - ( 4 + 2 * TCO_BORDER_WIDTH ), x_base + static_cast<int>( ppt * t ) - 1, height() - 2 * TCO_BORDER_WIDTH ); } // melody pattern paint event if( m_pat->m_patternType == Pattern::MelodyPattern ) { if( m_pat->m_notes.size() > 0 ) { // first determine the central tone so that we can // display the area where most of the m_notes are // also calculate min/max tones so the tonal range can be // properly stretched accross the pattern vertically int central_key = 0; int max_key = 0; int min_key = 9999999; int total_notes = 0; for( NoteVector::Iterator it = m_pat->m_notes.begin(); it != m_pat->m_notes.end(); ++it ) { if( ( *it )->length() > 0 ) { max_key = qMax( max_key, ( *it )->key() ); min_key = qMin( min_key, ( *it )->key() ); central_key += ( *it )->key(); ++total_notes; } } if( total_notes > 0 ) { central_key = central_key / total_notes; const int keyrange = qMax( qMax( max_key - central_key, central_key - min_key ), 1 ); // debug code // qDebug( "keyrange: %d", keyrange ); // determine height of the pattern view, sans borders const int ht = (height() - 1 - TCO_BORDER_WIDTH * 2) -1; // determine maximum height value for drawing bounds checking const int max_ht = height() - 1 - TCO_BORDER_WIDTH; // set colour based on mute status if( m_pat->getTrack()->isMuted() || m_pat->isMuted() ) { p.setPen( QColor( 160, 160, 160 ) ); } else { p.setPen( fgColor() ); } // scan through all the notes and draw them on the pattern for( NoteVector::Iterator it = m_pat->m_notes.begin(); it != m_pat->m_notes.end(); ++it ) { // calculate relative y-position const float y_key = ( float( central_key - ( *it )->key() ) / keyrange + 1.0f ) / 2; // multiply that by pattern height const int y_pos = static_cast<int>( TCO_BORDER_WIDTH + y_key * ht ) + 1; // debug code // if( ( *it )->length() > 0 ) qDebug( "key %d, central_key %d, y_key %f, y_pos %d", ( *it )->key(), central_key, y_key, y_pos ); // check that note isn't out of bounds, and has a length if( ( *it )->length() > 0 && y_pos >= TCO_BORDER_WIDTH && y_pos <= max_ht ) { // calculate start and end x-coords of the line to be drawn const int x1 = x_base + static_cast<int> ( ( *it )->pos() * ( ppt / MidiTime::ticksPerTact() ) ); const int x2 = x_base + static_cast<int> ( ( ( *it )->pos() + ( *it )->length() ) * ( ppt / MidiTime::ticksPerTact() ) ); // check bounds, draw line if( x1 < width() - TCO_BORDER_WIDTH ) p.drawLine( x1, y_pos, qMin( x2, width() - TCO_BORDER_WIDTH ), y_pos ); } } } } } // beat pattern paint event else if( m_pat->m_patternType == Pattern::BeatPattern && ( fixedTCOs() || ppt >= 96 || m_pat->m_steps != MidiTime::stepsPerTact() ) ) { QPixmap stepon; QPixmap stepoverlay; QPixmap stepoff; QPixmap stepoffl; const int steps = qMax( 1, m_pat->m_steps ); const int w = width() - 2 * TCO_BORDER_WIDTH; // scale step graphics to fit the beat pattern length stepon = s_stepBtnOn->scaled( w / steps, s_stepBtnOn->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); stepoverlay = s_stepBtnOverlay->scaled( w / steps, s_stepBtnOn->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); stepoff = s_stepBtnOff->scaled( w / steps, s_stepBtnOff->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); stepoffl = s_stepBtnOffLight->scaled( w / steps, s_stepBtnOffLight->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); for( int it = 0; it < steps; it++ ) // go through all the steps in the beat pattern { Note * n = m_pat->noteAtStep( it ); // figure out x and y coordinates for step graphic const int x = TCO_BORDER_WIDTH + static_cast<int>( it * w / steps ); const int y = height() - s_stepBtnOff->height() - 1; // get volume and length of note, if noteAtStep returned null // (meaning, note at step doesn't exist for some reason) // then set both at zero, ie. treat as an off step const int vol = ( n != NULL ? n->getVolume() : 0 ); const int len = ( n != NULL ? int( n->length() ) : 0 ); if( len < 0 ) { p.drawPixmap( x, y, stepoff ); for( int i = 0; i < vol / 5 + 1; ++i ) { p.drawPixmap( x, y, stepon ); } for( int i = 0; i < ( 25 + ( vol - 75 ) ) / 5; ++i ) { p.drawPixmap( x, y, stepoverlay ); } } else if( ( it / 4 ) % 2 ) { p.drawPixmap( x, y, stepoffl ); } else { p.drawPixmap( x, y, stepoff ); } } // end for loop } p.setFont( pointSize<8>( p.font() ) ); QColor text_color = ( m_pat->isMuted() || m_pat->getTrack()->isMuted() ) ? QColor( 30, 30, 30 ) : textColor(); if( m_pat->name() != m_pat->instrumentTrack()->name() ) { p.setPen( QColor( 0, 0, 0 ) ); p.drawText( 4, p.fontMetrics().height()+1, m_pat->name() ); p.setPen( text_color ); p.drawText( 3, p.fontMetrics().height(), m_pat->name() ); } if( m_pat->isMuted() ) { p.drawPixmap( 3, p.fontMetrics().height() + 1, embed::getIconPixmap( "muted", 16, 16 ) ); } p.end(); _p.drawPixmap( 0, 0, m_paintPixmap ); }
void View::DrawMaximaToBrevis(DeviceContext *dc, int y, LayerElement *element, Layer *layer, Staff *staff) { assert(dc); assert(element); assert(layer); assert(staff); Note *note = dynamic_cast<Note *>(element); assert(note); int xn, xLeft, xRight, yTop, yBottom, y3, y4; // int yy2, y5; // unused int verticalCenter, up, height; bool mensural_black = (staff->m_drawingNotationType == NOTATIONTYPE_mensural_black); bool fillNotehead = (mensural_black || note->GetColored()) && !(mensural_black && note->GetColored()); height = m_doc->GetDrawingBeamWidth(staff->m_drawingStaffSize, false) / 2; xn = element->GetDrawingX(); // Calculate size of the rectangle xLeft = xn - m_doc->GetDrawingBrevisWidth(staff->m_drawingStaffSize); xRight = xn + m_doc->GetDrawingBrevisWidth(staff->m_drawingStaffSize); if (note->GetActualDur() == DUR_MX) { // Maxima is twice the width of brevis xLeft -= m_doc->GetDrawingBrevisWidth(staff->m_drawingStaffSize); xRight += m_doc->GetDrawingBrevisWidth(staff->m_drawingStaffSize); } yTop = y + m_doc->GetDrawingUnit(staff->m_drawingStaffSize); yBottom = y - m_doc->GetDrawingUnit(staff->m_drawingStaffSize); y3 = yTop; y4 = yBottom; if (!mensural_black) { y3 += (int)m_doc->GetDrawingUnit(staff->m_drawingStaffSize) / 2; // partie d'encadrement qui depasse y4 -= (int)m_doc->GetDrawingUnit(staff->m_drawingStaffSize) / 2; } if (!fillNotehead) { // double the bases of rectangles DrawObliquePolygon(dc, xLeft, yTop, xRight, yTop, -height); DrawObliquePolygon(dc, xLeft, yBottom, xRight, yBottom, height); } else { DrawFilledRectangle(dc, xLeft, yTop, xRight, yBottom); } DrawVerticalLine(dc, y3, y4, xLeft, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); // corset lateral DrawVerticalLine(dc, y3, y4, xRight, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); // stem if (note->GetActualDur() < DUR_BR) { verticalCenter = staff->GetDrawingY() - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 2; up = (y < verticalCenter) ? true : false; if (note->GetDrawingStemDir() != STEMDIRECTION_NONE) { if (note->GetDrawingStemDir() == STEMDIRECTION_up) { up = true; } else { up = false; } } if (!up) { y3 = yTop - m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 8; yBottom = yTop; } else { y3 = yTop + m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 6; yBottom = yTop; } DrawVerticalLine(dc, yBottom, y3, xRight, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); } return; }
/// Command Events ///< This code demonstrates how to parse a loaded Power Tab document ///< You could also load a document directly using Load void PowerTabView::OnTestParseFile(wxCommandEvent& event) { // Menu Test -> Parse File //------Last Checked------// // - Jan 25, 2005 WXUNUSED(event); // Get the active document PowerTabDocument* document = (PowerTabDocument*)GetDocument(); wxCHECK2(document != NULL, return); wxLongLong startTime = ::wxGetLocalTimeMillis(); // Get the header PowerTabFileHeader& header = document->GetHeaderRef(); // File version that the file was saved as; the document automatically // converts to the latest version during deserialization wxWord version = header.GetVersion(); // In Power Tab Editor v1.7, most of the header data is accessable via the Song Property Sheet: // Menu View -> File Information // Menu View -> Performance Notes // Menu View -> Lyrics // File is a song if (header.IsSong()) { wxByte contentType = header.GetSongContentType(); wxString title = header.GetSongTitle(); wxString artist = header.GetSongArtist(); wxByte releaseType = header.GetSongReleaseType(); // Audio release if (releaseType == PowerTabFileHeader::RELEASETYPE_PUBLIC_AUDIO) { wxByte releaseType = header.GetSongAudioReleaseType(); wxString releaseTitle = header.GetSongAudioReleaseTitle(); wxWord year = header.GetSongAudioReleaseYear(); bool live = header.IsSongAudioReleaseLive(); } // Video release else if (releaseType == PowerTabFileHeader::RELEASETYPE_PUBLIC_VIDEO) { wxString releaseTitle = header.GetSongVideoReleaseTitle(); bool live = header.IsSongVideoReleaseLive(); } // Bootleg else if (releaseType == PowerTabFileHeader::RELEASETYPE_BOOTLEG) { wxString releaseTitle = header.GetSongBootlegTitle(); wxDateTime bootlegDate = header.GetSongBootlegDate(); } // Not released else if (releaseType == PowerTabFileHeader::RELEASETYPE_NOTRELEASED) { // no extra data for this data } // If author is known, get the composer and lyricist; otherwise, song is traditional if (header.GetSongAuthorType() == PowerTabFileHeader::AUTHORTYPE_AUTHORKNOWN) { wxString composer = header.GetSongComposer(); wxString lyricist = header.GetSongLyricist(); } wxString arranger = header.GetSongArranger(); wxString guitarScoreTranscriber = header.GetSongGuitarScoreTranscriber(); wxString bassScoreTranscriber = header.GetSongBassScoreTranscriber(); wxString copyright = header.GetSongCopyright(); wxString lyrics = header.GetSongLyrics(); wxString guitarScoreNotes = header.GetSongGuitarScoreNotes(); wxString bassScoreNotes = header.GetSongBassScoreNotes(); } // File is a lesson else if (header.IsLesson()) { wxString title = header.GetLessonTitle(); wxString subtitle = header.GetLessonSubtitle(); wxWord musicStyle = header.GetLessonMusicStyle(); wxByte level = header.GetLessonLevel(); wxString author = header.GetLessonAuthor(); wxString notes = header.GetLessonNotes(); wxString copyright = header.GetLessonCopyright(); } wxUint8 scoreIndex = 0; // There are two scores in each document: // 1) Guitar score // 2) Bass score for (; scoreIndex < 2; scoreIndex++) { // Get the score Score* score = NULL; if (scoreIndex == 0) score = document->GetGuitarScore(); else score = document->GetBassScore(); wxCHECK2(score != NULL, continue); // Parse the guitars in the score // In Power Tab Editor v1.7, the guitar data can be accessed via the Guitar Property Sheet: // Menu Guitar -> Setup wxUint32 guitarIndex = 0; wxUint32 guitarCount = score->GetGuitarCount(); for (; guitarIndex < guitarCount; guitarIndex++) { Guitar* guitar = score->GetGuitar(guitarIndex); wxCHECK2(guitar != NULL, continue); wxByte number = guitar->GetNumber(); wxString description = guitar->GetDescription(); wxByte preset = guitar->GetPreset(); wxByte initialVolume = guitar->GetInitialVolume(); wxByte pan = guitar->GetPan(); wxByte reverb = guitar->GetReverb(); wxByte chorus = guitar->GetChorus(); wxByte tremolo = guitar->GetTremolo(); wxByte phaser = guitar->GetPhaser(); wxByte capo = guitar->GetCapo(); const Tuning& tuning = guitar->GetTuning(); wxString name = tuning.GetName(); wxInt8 musicNotationOffset = tuning.GetMusicNotationOffset(); bool usesSharps = tuning.UsesSharps(); // Get the MIDI note pitch for each string, starting with the highest string // Highest string = High E on standard guitar tuning size_t string = 0; size_t stringCount = tuning.GetStringCount(); for (; string < stringCount; string++) { // MIDI note pitch (see MIDI_NOTE_xx constants in generalmidi.h) wxByte note = tuning.GetNote(string); } } // Parse the chord diagrams in the score // In Power Tab Editor v1.7, chord diagrams can be accessed via the Guitar Property Sheet: // Menu Guitar -> Chord Diagram List // The chord diagrams appear in the Chord Diagram List in the order they are stored in the chord diagram // array in the score wxUint32 chordDiagramIndex = 0; wxUint32 chordDiagramCount = score->GetChordDiagramCount(); for (; chordDiagramIndex < chordDiagramCount; chordDiagramIndex++) { ChordDiagram* chordDiagram = score->GetChordDiagram(chordDiagramIndex); wxCHECK2(chordDiagram != NULL, continue); // In Power Tab Editor v1.7, chord name data can be accessed via the Chord Name dialog: // Menu Text -> Chord Name const ChordName& chordName = chordDiagram->GetChordNameConstRef(); wxByte tonicKey = 0; wxByte tonicKeyVariation = 0; chordName.GetTonic(tonicKey, tonicKeyVariation); wxByte bassNoteKey = 0; wxByte bassNoteKeyVariation = 0; chordName.GetBassNote(bassNoteKey, bassNoteKeyVariation); wxByte formula = chordName.GetFormula(); bool brackets = chordName.HasBrackets(); bool noChord = chordName.IsNoChord(); wxWord formulaModificationFlag = ChordName::extended9th; for (; formulaModificationFlag <= ChordName::suspended4th; formulaModificationFlag *= 2) { if (chordName.IsFormulaModificationFlagSet(formulaModificationFlag)) { } // Block overflow if (formulaModificationFlag == ChordName::suspended4th) break; } if (chordName.IsFretPositionUsed()) { wxByte fretPosition = chordName.GetFretPosition(); } if (chordName.IsTypeUsed()) { wxByte type = chordName.GetType(); } wxByte topFret = chordDiagram->GetTopFret(); size_t string = 0; size_t stringCount = chordDiagram->GetStringCount(); for (; string < stringCount; string++) { wxByte fretNumber = chordDiagram->GetFretNumber(string); } } // Parse the floating text items in the score // In Power Tab Editor v1.7, floating text items are created using: // Menu Text -> Insert // Floating text items are stored in the array by order of their rect.top and // rect.left values // i.e. An item at left = 40, top = 100 is stored prior to left = 10, top = 120 wxUint32 floatingTextIndex = 0; wxUint32 floatingTextCount = score->GetFloatingTextCount(); for (; floatingTextIndex < floatingTextCount; floatingTextIndex++) { FloatingText* floatingText = score->GetFloatingText(floatingTextIndex); wxCHECK2(floatingText != NULL, continue); wxString text = floatingText->GetText(); wxRect rect = floatingText->GetRect(); wxByte alignment = floatingText->GetAlignment(); bool border = floatingText->HasBorder(); // Font setting for the text const FontSetting& fontSetting = floatingText->GetFontSettingConstRef(); wxString faceName = fontSetting.GetFaceName(); wxInt32 pointSize = fontSetting.GetPointSize(); wxInt32 weight = fontSetting.GetWeight(); bool italic = fontSetting.IsItalic(); bool underline = fontSetting.IsUnderline(); bool strikeOut = fontSetting.IsStrikeOut(); wxColor color = fontSetting.GetColor(); } // Parse the guitar ins in the score // In Power Tab Editor v1.7, guitar ins can be accessed via the Guitar In dialog: // Menu Guitar -> Guitar In // Guitar Ins are stored in the array by order of their system, position and // staff values wxUint32 guitarInIndex = 0; wxUint32 guitarInCount = score->GetGuitarInCount(); for (; guitarInIndex < guitarInCount; guitarInIndex++) { GuitarIn* guitarIn = score->GetGuitarIn(guitarInIndex); wxCHECK2(guitarIn != NULL, continue); wxWord system = guitarIn->GetSystem(); wxByte staff = guitarIn->GetStaff(); wxByte position = guitarIn->GetPosition(); if (guitarIn->HasStaffGuitarsSet()) { wxByte staffGuitars = guitarIn->GetStaffGuitars(); } if (guitarIn->HasRhythmSlashGuitarsSet()) { wxByte rhythmSlashGuitars = guitarIn->GetRhythmSlashGuitars(); } } // Parse the tempo markers in the score // In Power Tab Editor v1.7, tempo markers can be accessed via the Tempo Marker dialog: // Menu Music Symbols -> Tempo Marker // and the Alteration of Pace dialog: // Menu Music Symbols -> Alteration of Pace // Tempo Markers are stored in the array by order of their system, position and // staff values wxUint32 tempoMarkerIndex = 0; wxUint32 tempoMarkerCount = score->GetTempoMarkerCount(); for (; tempoMarkerIndex < tempoMarkerCount; tempoMarkerIndex++) { TempoMarker* tempoMarker = score->GetTempoMarker(tempoMarkerIndex); wxCHECK2(tempoMarker != NULL, continue); if (tempoMarker->IsStandardMarker()) { wxByte beatType = tempoMarker->GetBeatType(); wxUint32 beatsPerMinute = tempoMarker->GetBeatsPerMinute(); } else if (tempoMarker->IsListesso()) { wxByte beatType = tempoMarker->GetBeatType(); wxByte listessoBeatType = tempoMarker->GetBeatType(); } else if (tempoMarker->IsAlterationOfPace()) { if (tempoMarker->IsAccelerando()) { } else if (tempoMarker->IsRitardando()) { } } if (tempoMarker->HasTripletFeel()) { wxByte tripletFeelType = tempoMarker->GetTripletFeelType(); } wxString description = tempoMarker->GetDescription(); } // Parse the dynamics in the score // In Power Tab Editor v1.7, dynamics can be accessed via the Dynamic dialog: // Menu Music Symbols -> Dynamic // Dynamics are stored in the array by order of their system, position and // staff values wxUint32 dynamicIndex = 0; wxUint32 dynamicCount = score->GetDynamicCount(); for (; dynamicIndex < dynamicCount; dynamicIndex++) { Dynamic* dynamic = score->GetDynamic(dynamicIndex); wxCHECK2(dynamic != NULL, continue); wxWord system = dynamic->GetSystem(); wxByte staff = dynamic->GetStaff(); wxByte position = dynamic->GetPosition(); // Staff volume is set if (dynamic->IsStaffVolumeSet()) { wxByte staffVolume = dynamic->GetStaffVolume(); } // Rhythm slash volume is set if (dynamic->IsRhythmSlashVolumeSet()) { wxByte rhythmSlashVolume = dynamic->GetRhythmSlashVolume(); } } // Parse the alternate endings in the score // In Power Tab Editor v1.7, alternate endings can be accessed via the Repeat Ending dialog: // Menu Music Symbols -> Repeat Ending // Alternate endings are stored in the array by order of their system and // position values wxUint32 alternateEndingIndex = 0; wxUint32 alternateEndingCount = score->GetAlternateEndingCount(); for (; alternateEndingIndex < alternateEndingCount; alternateEndingIndex++) { AlternateEnding* alternateEnding = score->GetAlternateEnding(alternateEndingIndex); wxCHECK2(alternateEnding != NULL, continue); wxWord system = alternateEnding->GetSystem(); wxByte position = alternateEnding->GetPosition(); // Determine which numbers are set wxWord number = 1; for (; number <= AlternateEnding::dalSegnoSegno; number++) { if (alternateEnding->IsNumberSet(number)) { // Number is set } } } // Parse the systems in the score // In Power Tab Editor v1.7, systems can be accessed via the Section menu: // Menu Section -> New Section // Systems are stored in the array by order they are drawn in the score wxUint32 systemIndex = 0; wxUint32 systemCount = score->GetSystemCount(); for (; systemIndex < systemCount; systemIndex++) { System* system = score->GetSystem(systemIndex); wxCHECK2(system != NULL, continue); wxRect rect = system->GetRect(); wxByte positionSpacing = system->GetPositionSpacing(); // Parse the directions in the system // In Power Tab Editor v1.7, directions can be accessed via the Musical Direction dialog: // Menu Music Symbols -> Musical Direction wxUint32 directionIndex = 0; wxUint32 directionCount = system->GetDirectionCount(); for (; directionIndex < directionCount; directionIndex++) { Direction* direction = system->GetDirection(directionIndex); wxCHECK2(direction != NULL, continue); wxUint32 position = direction->GetPosition(); // There may be up to 3 symbols per object size_t symbolIndex = 0; size_t symbolCount = direction->GetSymbolCount(); for (; symbolIndex < symbolCount; symbolIndex++) { wxByte symbolType = 0; wxByte activeSymbol = 0; wxByte repeatNumber = 0; direction->GetSymbol(symbolIndex, symbolType, activeSymbol, repeatNumber); } } // Parse the chord text items in the system // In Power Tab Editor v1.7, chord text/chord name data can be accessed via the Chord Name dialog: // Menu Text -> Chord Name wxUint32 chordTextIndex = 0; wxUint32 chordTextCount = system->GetChordTextCount(); for (; chordTextIndex < chordTextCount; chordTextIndex++) { ChordText* chordText = system->GetChordText(chordTextIndex); wxCHECK2(chordText != NULL, continue); wxUint32 positon = chordText->GetPosition(); const ChordName& chordName = chordText->GetChordNameConstRef(); wxByte tonicKey = 0; wxByte tonicKeyVariation = 0; chordName.GetTonic(tonicKey, tonicKeyVariation); wxByte bassNoteKey = 0; wxByte bassNoteKeyVariation = 0; chordName.GetBassNote(bassNoteKey, bassNoteKeyVariation); wxByte formula = chordName.GetFormula(); bool brackets = chordName.HasBrackets(); bool noChord = chordName.IsNoChord(); wxWord formulaModificationFlag = ChordName::extended9th; for (; formulaModificationFlag <= ChordName::suspended4th; formulaModificationFlag *= 2) { if (chordName.IsFormulaModificationFlagSet(formulaModificationFlag)) { } // Block overflow if (formulaModificationFlag == ChordName::suspended4th) break; } if (chordName.IsFretPositionUsed()) { wxByte fretPosition = chordName.GetFretPosition(); } if (chordName.IsTypeUsed()) { wxByte type = chordName.GetType(); } } // Parse the rhythm slashes in the system // In Power Tab Editor v1.7, rhythm slash data can be accessed via the Rhy. Slashes menu wxUint32 rhythmSlashIndex = 0; wxUint32 rhythmSlashCount = system->GetRhythmSlashCount(); for (; rhythmSlashIndex < rhythmSlashCount; rhythmSlashIndex++) { RhythmSlash* rhythmSlash = system->GetRhythmSlash(rhythmSlashIndex); wxCHECK2(rhythmSlash != NULL, continue); wxUint32 position = rhythmSlash->GetPosition(); wxByte durationType = rhythmSlash->GetDurationType(); wxByte previousDurationType = rhythmSlash->GetPreviousBeamDurationType(); bool beamStart = rhythmSlash->IsBeamStart(); bool fractionalBeam = rhythmSlash->HasFractionalBeam(); bool beamEnd = rhythmSlash->IsBeamEnd(); bool tripletStart = rhythmSlash->IsTripletStart(); bool tripletMiddle = rhythmSlash->IsTripletMiddle(); bool tripletEnd = rhythmSlash->IsTripletEnd(); bool dotted = rhythmSlash->IsDotted(); bool doubleDotted = rhythmSlash->IsDoubleDotted(); bool rest = rhythmSlash->IsRest(); bool tied = rhythmSlash->IsTied(); bool muted = rhythmSlash->IsMuted(); bool staccato = rhythmSlash->IsStaccato(); bool pickstrokeUp = rhythmSlash->HasPickStrokeUp(); bool pickstrokeDown = rhythmSlash->HasPickStrokeDown(); bool arpeggioUp = rhythmSlash->HasArpeggioUp(); bool arpeggioDown = rhythmSlash->HasArpeggioDown(); bool tripletFeel1st = rhythmSlash->IsTripletFeel1st(); bool tripletFeel2nd = rhythmSlash->IsTripletFeel2nd(); bool marcato = rhythmSlash->HasMarcato(); bool sforzando = rhythmSlash->HasSforzando(); bool slideIntoFromAbove = rhythmSlash->HasSlideIntoFromAbove(); bool slideIntoFromBelow = rhythmSlash->HasSlideIntoFromBelow(); bool slideOutOfDownwards = rhythmSlash->HasSlideOutOfDownwards(); bool slideOutOfUpwards = rhythmSlash->HasSlideOutOfUpwards(); // TODO: If has single note { wxByte stringNumber = 0; wxByte fretNumber = 0; rhythmSlash->GetSingleNoteData(stringNumber, fretNumber); } } // Parse the barline at the start of the system { const Barline& startBar = system->GetStartBarConstRef(); wxByte type = startBar.GetType(); if (startBar.IsRepeatEnd()) { wxUint32 repeatCount = startBar.GetRepeatCount(); } const KeySignature& keySignature = startBar.GetKeySignatureConstRef(); wxByte keyType = 0; wxByte keyAccidentals = 0; keySignature.GetKey(keyType, keyAccidentals); if (keySignature.IsShown()) { } if (keySignature.IsCancellation()) { } const TimeSignature& timeSignature = startBar.GetTimeSignatureConstRef(); wxByte beatsPerMeasure = 0; wxByte beatAmount = 0; timeSignature.GetMeter(beatsPerMeasure, beatAmount); if (timeSignature.IsCutTime()) { } if (timeSignature.IsCommonTime()) { } wxByte beat1 = 0; wxByte beat2 = 0; wxByte beat3 = 0; wxByte beat4 = 0; timeSignature.GetBeamingPattern(beat1, beat2, beat3, beat4); if (timeSignature.IsShown()) { } wxByte pulses = timeSignature.GetPulses(); const RehearsalSign& rehearsalSign = startBar.GetRehearsalSignConstRef(); if (rehearsalSign.IsSet()) { wxInt8 letter = rehearsalSign.GetLetter(); wxString description = rehearsalSign.GetDescription(); } } // Parse the barlines within the system wxUint32 barlineIndex = 0; wxUint32 barlineCount = system->GetBarlineCount(); for (; barlineIndex < barlineCount; barlineIndex++) { Barline* barline = system->GetBarline(barlineIndex); wxCHECK2(barline != NULL, continue); wxUint32 position = barline->GetPosition(); const KeySignature& keySignature = barline->GetKeySignatureConstRef(); wxByte keyType = 0; wxByte keyAccidentals = 0; keySignature.GetKey(keyType, keyAccidentals); if (keySignature.IsShown()) { } if (keySignature.IsCancellation()) { } const TimeSignature& timeSignature = barline->GetTimeSignatureConstRef(); wxByte beatsPerMeasure = 0; wxByte beatAmount = 0; timeSignature.GetMeter(beatsPerMeasure, beatAmount); if (timeSignature.IsCutTime()) { } if (timeSignature.IsCommonTime()) { } wxByte beat1 = 0; wxByte beat2 = 0; wxByte beat3 = 0; wxByte beat4 = 0; timeSignature.GetBeamingPattern(beat1, beat2, beat3, beat4); if (timeSignature.IsShown()) { } wxByte pulses = timeSignature.GetPulses(); const RehearsalSign& rehearsalSign = barline->GetRehearsalSignConstRef(); if (rehearsalSign.IsSet()) { wxInt8 letter = rehearsalSign.GetLetter(); wxString description = rehearsalSign.GetDescription(); } } // Parse the barline at the end of the system { const Barline& endBar = system->GetEndBarConstRef(); wxByte type = endBar.GetType(); if (endBar.IsRepeatEnd()) { wxUint32 repeatCount = endBar.GetRepeatCount(); } const KeySignature& keySignature = endBar.GetKeySignatureConstRef(); wxByte keyType = 0; wxByte keyAccidentals = 0; keySignature.GetKey(keyType, keyAccidentals); if (keySignature.IsShown()) { } if (keySignature.IsCancellation()) { } const TimeSignature& timeSignature = endBar.GetTimeSignatureConstRef(); wxByte beatsPerMeasure = 0; wxByte beatAmount = 0; timeSignature.GetMeter(beatsPerMeasure, beatAmount); if (timeSignature.IsCutTime()) { } if (timeSignature.IsCommonTime()) { } wxByte beat1 = 0; wxByte beat2 = 0; wxByte beat3 = 0; wxByte beat4 = 0; timeSignature.GetBeamingPattern(beat1, beat2, beat3, beat4); if (timeSignature.IsShown()) { } wxByte pulses = timeSignature.GetPulses(); const RehearsalSign& rehearsalSign = endBar.GetRehearsalSignConstRef(); if (rehearsalSign.IsSet()) { wxInt8 letter = rehearsalSign.GetLetter(); wxString description = rehearsalSign.GetDescription(); } } // Parse the staves in the system // In Power Tab Editor v1.7, staves can be accessed via the Section menu: // Menu Section -> Attach Staff // and by clicking the clef on the standard notation standard staff and // by clicking the "TAB" clef on the tablature staff wxUint32 staffIndex = 0; wxUint32 staffCount = system->GetStaffCount(); for (; staffIndex < staffCount; staffIndex++) { Staff* staff = system->GetStaff(staffIndex); wxCHECK2(staff != NULL, continue); wxByte clef = staff->GetClef(); wxByte tablatureStaffType = staff->GetTablatureStaffType(); // Parse the positions in each voice wxUint32 voice = 0; for (; voice < NUM_STAFF_VOICES; voice++) { wxUint32 positionIndex = 0; wxUint32 positionCount = staff->GetPositionCount(voice); for (; positionIndex < positionCount; positionIndex++) { Position* position = staff->GetPosition(voice, positionIndex); wxCHECK2(position != NULL, continue); wxUint32 positionIndex = 0; wxUint32 positionCount = staff->GetPositionCount(voice); for (; positionIndex < positionCount; positionIndex++) { Position* position = staff->GetPosition(voice, positionIndex); wxCHECK2(position != NULL, continue); wxUint32 position2 = position->GetPosition(); wxByte durationType = position->GetDurationType(); if (position->HasIrregularGroupingTiming()) { wxByte notesPlayed = 0; wxByte notesPlayedOver = 0; position->GetIrregularGroupingTiming(notesPlayed, notesPlayedOver); } wxByte previousBeamDurationType = position->GetPreviousBeamDurationType(); bool beamStart = position->IsBeamStart(); bool fractionalLeftBeam = position->HasFractionalLeftBeam(); bool fractionalRightBeam = position->HasFractionalRightBeam(); bool beamEnd = position->IsBeamEnd(); bool dotted = position->IsDotted(); bool doubleDotted = position->IsDoubleDotted(); bool rest = position->IsRest(); bool vibrato = position->HasVibrato(); bool wideVibrato = position->HasWideVibrato(); bool arpeggioUp = position->HasArpeggioUp(); bool arpeggioDown = position->HasArpeggioDown(); bool pickstrokeUp = position->HasPickStrokeUp(); bool pickstrokeDown = position->HasPickStrokeDown(); bool staccato = position->IsStaccato(); bool marcato = position->HasMarcato(); bool sforzando = position->HasSforzando(); bool tremoloPicking = position->HasTremoloPicking(); bool palmMuting = position->HasPalmMuting(); bool tap = position->HasTap(); bool acciaccatura = position->IsAcciaccatura(); bool tripletFeel1st = position->IsTripletFeel1st(); bool tripletFeel2nd = position->IsTripletFeel2nd(); bool letRing = position->HasLetRing(); bool fermata = position->HasFermata(); bool irregularGroupingStart = position->IsIrregularGroupingStart(); bool irregularGroupingMiddle = position->IsIrregularGroupingMiddle(); bool irregularGroupingEnd = position->IsIrregularGroupingEnd(); if (position->HasVolumeSwell()) { wxByte startVolume = 0; wxByte endVolume = 0; wxByte duration = 0; position->GetVolumeSwell(startVolume, endVolume, duration); } if (position->HasTremoloBar()) { wxByte type = 0; wxByte duration = 0; wxByte pitch = 0; position->GetTremoloBar(type, duration, pitch); } // Parse the notes // In Power Tab Editor v1.7, note data can be accessed via the Notes menu, as well as // the Tab Symbols menu wxUint32 noteIndex = 0; wxUint32 noteCount = position->GetNoteCount(); for (; noteIndex < noteCount; noteIndex++) { Note* note = position->GetNote(noteIndex); wxCHECK2(note != NULL, continue); wxUint32 string = note->GetString(); wxUint32 fretNumber = note->GetFretNumber(); bool tied = note->IsTied(); bool muted = note->IsMuted(); bool tieWrap = note->HasTieWrap(); bool hammerOn = note->HasHammerOn(); bool hammerOnFromNowhere = note->HasHammerOnFromNowhere(); bool pullOff = note->HasPullOff(); bool pullOffToNowhere = note->HasPullOffToNowhere(); bool naturalHarmonic = note->IsNaturalHarmonic(); bool ghostNote = note->IsGhostNote(); bool octave8va = note->IsOctave8va(); bool octave15ma = note->IsOctave15ma(); bool octave8vb = note->IsOctave8vb(); bool octave15mb = note->IsOctave15mb(); if (note->HasSlideInto()) { wxByte type = 0; note->GetSlideInto(type); } if (note->HasSlideOutOf()) { wxByte type = 0; wxInt8 steps = 0; note->GetSlideOutOf(type, steps); } if (note->HasBend()) { wxByte type = 0; wxByte bentPitch = 0; wxByte releasePitch = 0; wxByte duration = 0; wxByte drawStartPoint = 0; wxByte drawEndPoint = 0; note->GetBend(type, bentPitch, releasePitch, duration, drawStartPoint, drawEndPoint); } if (note->HasTappedHarmonic()) { wxByte tappedFretNumber = 0; note->GetTappedHarmonic(tappedFretNumber); } if (note->HasTrill()) { wxByte trilledFretNumber = 0; note->GetTrill(trilledFretNumber); } if (note->HasArtificialHarmonic()) { wxByte key = 0; wxByte keyVariation = 0; wxByte octave = 0; note->GetArtificialHarmonic(key, keyVariation, octave); } } } } } } } } // In Power Tab Editor v1.7, font settings can be accessed via the Song Property Sheet: // Menu View -> Fonts { const FontSetting& chordNameFontSetting = document->GetChordNameFontSettingConstRef(); wxString faceName = chordNameFontSetting.GetFaceName(); wxInt32 pointSize = chordNameFontSetting.GetPointSize(); wxInt32 weight = chordNameFontSetting.GetWeight(); bool italic = chordNameFontSetting.IsItalic(); bool underline = chordNameFontSetting.IsUnderline(); bool strikeOut = chordNameFontSetting.IsStrikeOut(); wxColor color = chordNameFontSetting.GetColor(); } { const FontSetting& tablatureNumbersFontSetting = document->GetTablatureNumbersFontSettingConstRef(); wxString faceName = tablatureNumbersFontSetting.GetFaceName(); wxInt32 pointSize = tablatureNumbersFontSetting.GetPointSize(); wxInt32 weight = tablatureNumbersFontSetting.GetWeight(); bool italic = tablatureNumbersFontSetting.IsItalic(); bool underline = tablatureNumbersFontSetting.IsUnderline(); bool strikeOut = tablatureNumbersFontSetting.IsStrikeOut(); wxColor color = tablatureNumbersFontSetting.GetColor(); } // In Power Tab Editor v1.7, tablature line spacing values can be accessed via the Line Height submenu // on the Section menu wxUint32 tablatureStaffLineSpacing = document->GetTablatureStaffLineSpacing(); // In Power Tab Editor v1.7, fade values can be accessed via the Fade dialog: // Menu Music Symbols -> Fade wxUint32 fadeIn = document->GetFadeIn(); wxUint32 fadeOut = document->GetFadeOut(); wxLongLong totalTime = ::wxGetLocalTimeMillis() - startTime; double milliseconds = ((double)totalTime.ToLong()) / 1000.0; wxMessageBox(wxString::Format(wxT("File parsed in %.3f seconds."), milliseconds), wxTheApp->GetAppName(), wxICON_INFORMATION); }
void View::DrawLigatureNote(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff) { assert(dc); assert(element); assert(layer); assert(staff); LogDebug("DrawLigatureNote"); Note *note = dynamic_cast<Note *>(element); assert(note); int xn, x1, x2, y, y1, y2, y3, y4; // int yy2, y5; // unused int verticalCenter, up, epaisseur; epaisseur = std::max(2, m_doc->GetDrawingBeamWidth(staff->m_drawingStaffSize, false) / 2); xn = element->GetDrawingX(); y = 99; // LogDebug("DrawLigatureNote: _ligObliqua=%d drawingX=%d y=%d", note->m_ligObliqua, xn, y); LogDebug("DrawLigatureNote: drawingX=%d y=%d", xn, y); /* if ((note->m_lig==LIG_MEDIAL) || (note->m_lig==LIG_TERMINAL)) { CalculateLigaturePosX(element, layer, staff); } else */ { xn = element->GetDrawingX(); } // Compute the dimensions of the rectangle x1 = xn - m_doc->GetDrawingBrevisWidth(staff->m_drawingStaffSize); x2 = xn + m_doc->GetDrawingBrevisWidth(staff->m_drawingStaffSize); y1 = y + m_doc->GetDrawingUnit(staff->m_drawingStaffSize); y2 = y - m_doc->GetDrawingUnit(staff->m_drawingStaffSize); y3 = (int)(y1 + m_doc->GetDrawingUnit(staff->m_drawingStaffSize) / 2); // part of the frame that overflows y4 = (int)(y2 - m_doc->GetDrawingUnit(staff->m_drawingStaffSize) / 2); // if (!note->m_ligObliqua && (!View::s_drawingLigObliqua)) // rectangular notes, incl. ligature { if (note->GetColored() != BOOLEAN_true) { // double the bases of rectangles DrawObliquePolygon(dc, x1, y1, x2, y1, -epaisseur); DrawObliquePolygon(dc, x1, y2, x2, y2, epaisseur); } else DrawFilledRectangle(dc, x1, y1, x2, y2); // // ENZ correction of x2 DrawVerticalLine(dc, y3, y4, x1, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); // lateral brace DrawVerticalLine(dc, y3, y4, x2, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); } /* else // handle obliques { if (!View::s_drawingLigObliqua) // 1st pass: Initial flagStemHeight { DrawVerticalLine (dc,y3,y4,x1, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); View::s_drawingLigObliqua = true; //oblique = false; // if (val == DUR_1) // left tail up if DUR_1 // queue_lig = true; } else // 2nd pass: oblique lines and final flagStemHeighte { x1 -= m_doc->m_drawingBrevisWidth[staff->m_drawingStaffSize] * 2; // auto advance y1 = *View::s_drawingLigY - m_doc->GetDrawingUnit(staff->m_drawingStaffSize); // ligat_y contains original y yy2 = y2; y5 = y1+ m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); y2 += m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize); // go up a INTERL if (note->GetColored()==BOOLEAN_true) DrawObliquePolygon (dc, x1, y1, x2, yy2, m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize)); else { DrawObliquePolygon (dc, x1, y1, x2, yy2, 5); DrawObliquePolygon (dc, x1, y5, x2, y2, -5); } DrawVerticalLine (dc,y3,y4,x2,m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); // enclosure flagStemHeighte View::s_drawingLigObliqua = false; // queue_lig = false; // ??defuses alg.queue DUR_BR?? } } if (note->m_lig) // remember positions from one note to another; connect notes by bars { *(View::s_drawingLigX+1) = x2; *(View::s_drawingLigY+1) = y; // connect ligature beamed notes by bar flagStemHeightes //if (in(x1,(*View::s_drawingLigX)-2,(*View::s_drawingLigX)+2) || (this->fligat && this->lat && !Note1::marq_obl)) // the latest conditions to allow previous ligature flagStemHeighte // DrawVerticalLine (dc, *ligat_y, y1, (this->fligat && this->lat) ? x2: x1, m_doc->m_parameters.m_stemWidth); // ax2 - drawing flagStemHeight lines missing *View::s_drawingLigX = *(View::s_drawingLigX + 1); *View::s_drawingLigY = *(View::s_drawingLigY + 1); } y3 = y2 - m_doc->GetDrawingUnit(staff->m_drawingStaffSize)*6; if (note->m_lig) { if (note->m_dur == DUR_BR) // && this->queue_lig) // tail left bottom: initial downward DUR_BR // ax2 - no support for queue_lig (see WG corrigeLigature) { DrawVerticalLine (dc, y2, y3, x1, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); } else if (note->m_dur == DUR_LG) // && !this->queue_lig) // DUR_LG ligature, tail right down // ax2 - no support for queue_lig { DrawVerticalLine (dc, y2, y3, x2, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); } else if (note->m_dur == DUR_1) // && this->queue_lig) // queue gauche haut // ax2 - no support for queue_lig { y2 = y1 + m_doc->GetDrawingUnit(staff->m_drawingStaffSize)*6; DrawVerticalLine (dc, y1, y2, x1, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); } } else if (note->m_dur == DUR_LG) // isolated DUR_LG: tail like normal notes */ if (note->GetActualDur() == DUR_LG) { verticalCenter = staff->GetDrawingY() - m_doc->GetDrawingDoubleUnit(staff->m_drawingStaffSize) * 2; // ENZ up = (y < verticalCenter) ? true : false; // ENZ if (note->GetDrawingStemDir() != STEMDIRECTION_NONE) { if (note->GetDrawingStemDir() == STEMDIRECTION_up) { up = true; } else { up = false; } } if (!up) { y3 = y1 - m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 8; y2 = y1; } else { y3 = y1 + m_doc->GetDrawingUnit(staff->m_drawingStaffSize) * 6; y2 = y1; } DrawVerticalLine(dc, y2, y3, x2, m_doc->GetDrawingStemWidth(staff->m_drawingStaffSize)); } return; }
bool operator>(const Note n1, const Note n2) { return n1.getRang()>n2.getRang(); }
void PlayBack::process() { for(unsigned int i=0; i<staff.getNumOfNotes(); i++){ Note note = staff.getNoteByNum(i+1); switch (staff.getNoteByNum(i+1).getPitch()) { case -24: if(accents.at(i)->getAccent() == Accent::flat){ note--; } break; case -20: if(accents.at(i)->getAccent() == Accent::sharp){ note++; } break; case -19: if(accents.at(i)->getAccent() == Accent::flat){ note--; } break; case -13: if(accents.at(i)->getAccent() == Accent::sharp){ note++; } break; case -12: if(accents.at(i)->getAccent() == Accent::flat){ note--; } break; case -8: if(accents.at(i)->getAccent() == Accent::sharp){ note++; } break; case -7: if(accents.at(i)->getAccent() == Accent::flat){ note--; } break; case -1: if(accents.at(i)->getAccent() == Accent::sharp){ note++; } break; case 0: if(accents.at(i)->getAccent() == Accent::flat){ note--; } break; case 4: if(accents.at(i)->getAccent() == Accent::sharp){ note++; } break; case 5: if(accents.at(i)->getAccent() == Accent::flat){ note--; } break; case 11: if(accents.at(i)->getAccent() == Accent::sharp){ note++; } break; case 12: if(accents.at(i)->getAccent() == Accent::flat){ note--; } break; case 16: if(accents.at(i)->getAccent() == Accent::sharp){ note++; } break; case 17: if(accents.at(i)->getAccent() == Accent::flat){ note--; } break; case 23: if(accents.at(i)->getAccent() == Accent::sharp){ note++; } break; case 24: if(accents.at(i)->getAccent() == Accent::flat){ note--; } break; default: break; } if(!midi->isConnected()){ emit finished(); return; }else{ midi->noteOn(/* note */ note.getPitch()+60, /* voice */ voice , velocity /*velocity */); } // midi.noteOn(/* note */ svm->getNoteByNum(2,i+1).getPitch()+60, /* voice */ 1 /* , velocity */); //qDebug() << "noteon\n"; switch (note.getDuration()) { case 1: QThread::msleep(tempo*8); break; case 2: QThread::msleep(tempo*4); break; case 4: QThread::msleep(tempo*2); break; case 8: QThread::msleep(tempo); break; default: break; } if(!midi->isConnected()){ emit finished(); return; }else{ midi->noteOff(/* note */ note.getPitch()+60, /* voice */ voice); } //qDebug() << "noteoff"; // midi.noteOff(/* note */ svm->getNoteByNum(2,i+1).getPitch()+60, /* voice */ 1 /* , velocity */); } emit finished(); //this->exit(); }
bool operator==(const Note n1, const Note n2) { return (n1.getRang()==n2.getRang()); }
bool ribi::Music::operator<(const Note& lhs, const Note& rhs) noexcept { return lhs.ToInt() < rhs.ToInt(); }
Note Note::noteFromQuery(QSqlQuery query) { Note note; note.fillFromQuery(query); return note; }
void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) { if (e->type() == BAR_LINE) { genPropertyMenu1(e, popup); } else if (e->type() == ARTICULATION) { genPropertyMenu1(e, popup); popup->addAction(tr("Articulation Properties..."))->setData("a-props"); } else if (e->type() == BEAM) { popup->addAction(getAction("flip")); } else if (e->type() == STEM) { popup->addAction(getAction("flip")); } else if (e->type() == HOOK) { popup->addAction(getAction("flip")); } else if (e->type() == BEND) { genPropertyMenu1(e, popup); popup->addAction(tr("Bend Properties..."))->setData("b-props"); } else if (e->type() == TREMOLOBAR) { genPropertyMenu1(e, popup); popup->addAction(tr("TremoloBar Properties..."))->setData("tr-props"); } else if (e->type() == HBOX) { QMenu* textMenu = popup->addMenu(tr("Add")); textMenu->addAction(getAction("frame-text")); textMenu->addAction(getAction("picture")); popup->addAction(tr("Frame Properties..."))->setData("f-props"); } else if (e->type() == VBOX) { QMenu* textMenu = popup->addMenu(tr("Add")); textMenu->addAction(getAction("frame-text")); textMenu->addAction(getAction("title-text")); textMenu->addAction(getAction("subtitle-text")); textMenu->addAction(getAction("composer-text")); textMenu->addAction(getAction("poet-text")); textMenu->addAction(getAction("insert-hbox")); textMenu->addAction(getAction("picture")); popup->addAction(tr("Frame Properties..."))->setData("f-props"); } else if (e->type() == TBOX) { popup->addAction(tr("Frame Properties..."))->setData("f-props"); } else if (e->type() == TUPLET) { genPropertyMenu1(e, popup); popup->addAction(tr("Tuplet Properties..."))->setData("tuplet-props"); } else if (e->type() == VOLTA_SEGMENT) { genPropertyMenu1(e, popup); popup->addAction(tr("Volta Properties..."))->setData("v-props"); } else if (e->type() == TIMESIG) { genPropertyMenu1(e, popup); TimeSig* ts = static_cast<TimeSig*>(e); int _track = ts->track(); // if the time sig. is not generated (= not courtesy) and is in track 0 // add the specific menu item QAction* a; if (!ts->generated() && !_track) { a = popup->addAction(ts->showCourtesySig() ? QT_TRANSLATE_NOOP("TimeSig", "Hide Courtesy Time Signature") : QT_TRANSLATE_NOOP("TimeSig", "Show Courtesy Time Signature") ); a->setData("ts-courtesy"); } popup->addSeparator(); popup->addAction(tr("Time Signature Properties..."))->setData("ts-props"); } else if (e->type() == ACCIDENTAL) { Accidental* acc = static_cast<Accidental*>(e); genPropertyMenu1(e, popup); QAction* a = popup->addAction(QT_TRANSLATE_NOOP("Properties", "small")); a->setCheckable(true); a->setChecked(acc->small()); a->setData("smallAcc"); } else if (e->type() == CLEF) { genPropertyMenu1(e, popup); // if the clef is not generated (= not courtesy) add the specific menu item if (!e->generated()) { QAction* a = popup->addAction(static_cast<Clef*>(e)->showCourtesy() ? QT_TRANSLATE_NOOP("Clef", "Hide courtesy clef") : QT_TRANSLATE_NOOP("Clef", "Show courtesy clef") ); a->setData("clef-courtesy"); } } else if (e->type() == DYNAMIC) { popup->addSeparator(); if (e->visible()) popup->addAction(tr("Set Invisible"))->setData("invisible"); else popup->addAction(tr("Set Visible"))->setData("invisible"); popup->addAction(tr("MIDI Properties..."))->setData("d-dynamics"); popup->addAction(tr("Text Properties..."))->setData("d-props"); } else if (e->type() == TEXTLINE_SEGMENT || e->type() == OTTAVA_SEGMENT) { if (e->visible()) popup->addAction(tr("Set Invisible"))->setData("invisible"); else popup->addAction(tr("Set Visible"))->setData("invisible"); popup->addAction(tr("Line Properties..."))->setData("l-props"); } else if (e->type() == STAFF_TEXT) { genPropertyMenuText(e, popup); popup->addAction(tr("Staff Text Properties..."))->setData("st-props"); } else if (e->type() == TEXT || e->type() == FINGERING || e->type() == LYRICS) { genPropertyMenuText(e, popup); } else if (e->type() == TEMPO_TEXT) { genPropertyMenu1(e, popup); popup->addAction(tr("Tempo Properties..."))->setData("tempo-props"); popup->addAction(tr("Text Properties..."))->setData("text-props"); } else if (e->type() == KEYSIG) { genPropertyMenu1(e, popup); KeySig* ks = static_cast<KeySig*>(e); if (!e->generated()) { QAction* a = popup->addAction(ks->showCourtesy() ? QT_TRANSLATE_NOOP("KeySig", "Hide Courtesy Key Signature") : QT_TRANSLATE_NOOP("KeySig", "Show Courtesy Key Signature") ); a->setData("key-courtesy"); a = popup->addAction(ks->showNaturals() ? QT_TRANSLATE_NOOP("KeySig", "Hide Naturals") : QT_TRANSLATE_NOOP("KeySig", "Show Naturals") ); a->setData("key-naturals"); } } else if (e->type() == STAFF_STATE && static_cast<StaffState*>(e)->subtype() == STAFF_STATE_INSTRUMENT) { popup->addAction(tr("Change Instrument Properties..."))->setData("ss-props"); } else if (e->type() == SLUR_SEGMENT) { genPropertyMenu1(e, popup); popup->addAction(tr("Edit Mode"))->setData("edit"); popup->addAction(tr("Slur Properties..."))->setData("slur-props"); } else if (e->type() == REST) { Rest* rest = static_cast<Rest*>(e); genPropertyMenu1(e, popup); if (rest->tuplet()) { popup->addSeparator(); QMenu* menuTuplet = popup->addMenu(tr("Tuplet...")); menuTuplet->addAction(tr("Tuplet Properties..."))->setData("tuplet-props"); menuTuplet->addAction(tr("Delete Tuplet"))->setData("tupletDelete"); } } else if (e->type() == NOTE) { Note* note = static_cast<Note*>(e); QAction* b = popup->actions()[0]; QAction* a = popup->insertSeparator(b); a->setText(tr("Staff")); a = new QAction(tr("Staff Properties..."), 0); a->setData("staff-props"); popup->insertAction(b, a); a = popup->insertSeparator(b); a->setText(tr("Measure")); a = new QAction(tr("Measure Properties..."), 0); a->setData("measure-props"); popup->insertAction(b, a); genPropertyMenu1(e, popup); popup->addSeparator(); popup->addAction(tr("Style..."))->setData("style"); if (note->chord()->tuplet()) { QMenu* menuTuplet = popup->addMenu(tr("Tuplet...")); menuTuplet->addAction(tr("Tuplet Properties..."))->setData("tuplet-props"); menuTuplet->addAction(tr("Delete Tuplet"))->setData("tupletDelete"); } popup->addAction(tr("Chord Articulation..."))->setData("articulation"); } else if (e->type() == MARKER) { genPropertyMenu1(e, popup); popup->addAction(tr("Marker Properties..."))->setData("marker-props"); } else if (e->type() == JUMP) { genPropertyMenu1(e, popup); popup->addAction(tr("Jump Properties..."))->setData("jump-props"); } else if (e->type() == LAYOUT_BREAK && static_cast<LayoutBreak*>(e)->subtype() == LAYOUT_BREAK_SECTION) { popup->addAction(tr("Section Break Properties..."))->setData("break-props"); } else if (e->type() == INSTRUMENT_CHANGE) { genPropertyMenu1(e, popup); popup->addAction(tr("Change Instrument..."))->setData("ch-instr"); } else if (e->type() == FRET_DIAGRAM) { if (e->visible()) popup->addAction(tr("Set Invisible"))->setData("invisible"); else popup->addAction(tr("Set Visible"))->setData("invisible"); popup->addAction(tr("Color..."))->setData("color"); popup->addAction(tr("Fret Diagram Properties..."))->setData("fret-props"); } else if (e->type() == GLISSANDO) { genPropertyMenu1(e, popup); popup->addAction(tr("Glissando Properties..."))->setData("gliss-props"); } else if (e->type() == HAIRPIN_SEGMENT) { QAction* a = popup->addSeparator(); a->setText(tr("Dynamics")); if (e->visible()) a = popup->addAction(tr("Set Invisible")); else a = popup->addAction(tr("Set Visible")); a->setData("invisible"); popup->addAction(tr("Hairpin Properties..."))->setData("hp-props"); } else if (e->type() == HARMONY) { genPropertyMenu1(e, popup); popup->addSeparator(); popup->addAction(tr("Harmony Properties..."))->setData("ha-props"); popup->addAction(tr("Text Properties..."))->setData("text-props"); } else if (e->type() == INSTRUMENT_NAME) { popup->addAction(tr("Staff Properties..."))->setData("staff-props"); } else genPropertyMenu1(e, popup); }
Note Note::fetchByFileName(QString fileName) { Note note; note.fillByFileName(fileName); return note; }
bool Note::operator>(Note rechts){ return frequency > rechts.getFrequency(); }
/** * Checks if the notes are the same (by file) * * @param note * @return */ bool Note::isSameFile(Note note) { return (id == note.getId()) && (noteSubFolderId == note.getNoteSubFolderId()); }