//______________________________________________________________________________ // control all of the tree browsing is in charge of the S_part visit // it assumes that the score is a partwise score but the strategy could // equalli work on a timewise score, provided that the jump information // is consistent across the different parts. // // Jumps are under control of fNextIterator which could be modified by the // measure visit. Anchor points for future jumps (like segno) are stored // at S_part level using fStoreIterator pointer. // // visit methods can use the fStoreIterator pointer to store the current iterator // to any ctree<xmlelement>::literator. Using fStoreDelay allows for delayed stores. // void unrolled_xml_tree_browser::visitStart( S_part& elt) { // first initializes the iterators used to broswe the tree // segno and coda are initialized to the end of the measures list fEndIterator = elt->elements().end(); fSegnoIterator= fCodaIterator = fEndIterator; // stores the first measures and makes a provision for the forward repeat location ctree<xmlelement>::literator iter = elt->elements().begin(); fFirstMeasure = fForwardRepeat = iter; fStoreIterator = 0; fStoreDelay = 0; reset(); enter(*elt); // normal visit of the part (pass thru) fForward = false; // while we're not at the end location (elements().end() is checked for safety reasons only) while ((iter != fEndIterator) && (iter != elt->elements().end())) { fNextIterator = iter; fNextIterator++; // default value for next iterator is the next measure browse(**iter); // browse the measure if (fStoreIterator) { // check if we need to store the current iterator if (fStoreDelay == 0) { *fStoreIterator = iter; fStoreIterator = 0; } else fStoreDelay--; // this is actually a delayed store } iter = fNextIterator; // switch to next iterator (which may be changed by the measure visit) } leave(*elt); // normal visit of the part (pass thru) }
//______________________________________________________________________________ void xml2guidovisitor::visitStart ( S_part& elt ) { partsummary ps; xml_tree_browser browser(&ps); browser.browse(*elt); smartlist<int>::ptr voices = ps.getVoices (); int targetStaff = 0xffff; // initialized to a value we'll unlikely encounter bool notesOnly = false; rational currentTimeSign (0,1); // browse the parts voice by voice: allows to describe voices that spans over several staves for (unsigned int i = 0; i < voices->size(); i++) { int targetVoice = (*voices)[i]; int mainstaff = ps.getMainStaff(targetVoice); if (targetStaff == mainstaff) { notesOnly = true; } else { notesOnly = false; targetStaff = mainstaff; fCurrentStaffIndex++; } Sguidoelement seq = guidoseq::create(); push (seq); Sguidoelement tag = guidotag::create("staff"); tag->add (guidoparam::create(fCurrentStaffIndex, false)); add (tag); flushHeader (fHeader); flushPartHeader (fPartHeaders[elt->getAttributeValue("id")]); xmlpart2guido pv(fGenerateComments, fGenerateStem, fGenerateBars); pv.generatePositions (fGeneratePositions); xml_tree_browser browser(&pv); pv.initialize(seq, targetStaff, fCurrentStaffIndex, targetVoice, notesOnly, currentTimeSign); browser.browse(*elt); pop(); currentTimeSign = pv.getTimeSign(); } }
//________________________________________________________________________ void midicontextvisitor::visitStart(S_part& elt) { fCurrentDate = fLastPosition = fPendingDuration = 0; fEndMeasureDate = fEndPartDate = 0; fTranspose = 0; fDivisions = 1; fCurrentPartID = elt->getAttributeValue("id"); int instrCount = fScoreInstruments.count(fCurrentPartID); if (fMidiWriter) { fMidiWriter->startPart(instrCount); multimap<string, scoreInstrument>::iterator start = fScoreInstruments.lower_bound(fCurrentPartID); multimap<string, scoreInstrument>::iterator end = fScoreInstruments.upper_bound(fCurrentPartID); while (start != end) { playScoreInstrument(start->second); start++; } } }