Exemplo n.º 1
0
static void addInt(int len) {
	int i = integers.indexOf(len);
	// TODO: test this change and refactor it
	IntVector::Iterator it = i == -1 ? integers.end() : (integers.begin()+i);
	if (it == integers.end()) {
		integers.append(len);
	}
}
Exemplo n.º 2
0
/**
 * append() tests
 */
void testAppend() {
  IntVector v;
  v.push(0);
  v.append(5);
  
  assert(v.size() == 2);
  assert(v[0] == 0);
  assert(v[1] == 5);
}
Exemplo n.º 3
0
void ConvertXml::calcDivisions() {
//	cout << "ConvertXml::calcDivisions()" << endl;

	// init
	integers.clear();
	primes.clear();
	integers.append(120);		// quarter note length
	primes.append(2);
	primes.append(3);
	primes.append(5);
	primes.append(7);		// initialize with required prime numbers

// need to use note and rest duration as exported to MusicXML
// thus match ConvertXml::write's main loop

	// loop over all tracks
	for (auto row = 0; row < song->rowCount(); row++) {
		TabTrack* trk = song->index(row, 0).data(TabSong::TrackPtrRole).value<TabTrack*>();
		trk->calcVoices();	// LVIFIX: is this necessary ?
//		cout << "part id=P" << it+1 << endl;

		// loop over all bars
		for (int ib = 0; ib < trk->bars().size(); ib++) {
//			cout << "measure number=" << ib + 1 << endl;

			// loop over all voices in this bar
			for (int i = 0; i < 2; i++) {
				// write only voice 1 in single voice tracks,
				// write all voices in multi voice tracks
				if ((i == 1) || trk->hasMultiVoices()) {
//					cout << "voice number=" << i + 1 << endl;
					// loop over all columns in this bar
					for (int x = trk->bars()[ib].start; x <= trk->lastColumn(ib); /* nothing */) {
/*
						int tp;
						int dt;
						bool tr;
						bool res;
						res = trk->getNoteTypeAndDots(x, i, tp, dt, tr);
							// LVIFIX: error handling ?
							// false means no note in this column/voice
							// LVIFIX: add rest handling (see writecol)
						cout
							<< "x=" << x
							<< " res=" << res
							<< " tp=" << tp
							<< " dt=" << dt
							<< " tr=" << tr
							<< endl;
*/
						QTextStream dummy;
						x += writeCol(dummy, trk, x, i, false);
					} // end for (uint x = 0; ....
				} // end if ((i == 1) || ...
			} // end for (int i = 0; ...

		} // end for (uint ib = 0; ...

	} // end for (unsigned int it = 0; ...

	// do it: divide by all primes as often as possible
	for (auto& u : primes) {
		while (canDivideBy(u)) {
			divideBy(u);
		}
	}

//	cout << "res=" << integers[0] << endl;
	divisions = integers[0];
}