示例#1
0
文件: main.c 项目: somanydots/dotme
static void writeArray(char* to_write) {
  uint8_t i = 0;
  writeCol(0xFF);    writeCol(0xFF);
  while (i<12 && to_write[i] >= 0x20) {
    writeChar(to_write[i]);
    i++;
  }
  for(i*=6; i<98; i++){
    writeCol(0xFF);
  }
  PORTD &=~RESETPIN;
  _delay_ms(1);
  PORTD |= RESETPIN;
  memset(to_write, 0x00, 12);
}
示例#2
0
文件: main.c 项目: somanydots/dotme
static void writeChar(uint8_t ch) {
    uint8_t chars[6]={0, 0, 0, 0, 0, 0};
    memcpy(chars, &font[ch-0x20], 5);
    for (int i = 0; i<6;i++) {
        writeCol(~(chars[i]));
    }
}
示例#3
0
文件: blinky.c 项目: somanydots/dotme
int main(void)
{
    initLED();
    initDOTS();
    /* insert your hardware initialization here */
    PORTD |= RESETPIN;
    for(;;){
      for (uint8_t i=0; i<100; i++) {
        writeCol(i);
      }
      _delay_ms(1);
      for (uint8_t i=0; i<100; i++) {
        writeCol(0xFF-i);
      }
      _delay_ms(1);
    }
    return 0;   /* never reached */
}
示例#4
0
文件: main.c 项目: somanydots/dotme
int main(void)
{
    initLED();
    initDOTS();
    uart_init(UART_BAUD_SELECT(38400, F_CPU));
    sei();
    uart_flush();
    _delay_ms(100);


    uint8_t i=0;

    char c;
    memset(to_write, 0x00, sizeof(to_write));

    PORTD &=~RESETPIN;
    _delay_ms(1);
    PORTD |= RESETPIN;

    for (uint8_t i=0; i<200; i++) {
      writeCol(0xFF);
    }

    for (;;) {
      while(uart_available() == 0) {
        PORTB|=(1<<PB5);
        _delay_ms(100);
        PORTB&=~(1<<PB5);
        _delay_ms(100);
      }
      c = uart_getc();
      char c_lo = c;
      uart_putc(c);
      if (c_lo >= 0x20) {
        to_write[i++] = c_lo;
      }
      if ((c_lo < 0x20) || (i >= 12)) {
        writeArray(to_write);
        i=0;
      }
    }
    return 0;   /* never reached */
}
示例#5
0
void ConvertXml::write(QTextStream& os)
{
	calcDivisions();
	os << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>"
	   << endl;
	os << "<!DOCTYPE score-partwise PUBLIC" << endl;
	os << "    \"-//Recordare//DTD MusicXML 1.0 Partwise//EN\"" << endl;
	os << "    \"http://www.musicxml.org/dtds/partwise.dtd\">" << endl;
	os << endl;
	os << "<score-partwise>\n";
	os << "\t<work>\n";
	os << "\t\t<work-title>" << song->info["TITLE"] << "</work-title>\n";
	os << "\t</work>\n";

// identification
	os << "\n";
	os << "\t<identification>\n";
	os << "\t\t<creator type=\"composer\">" << song->info["ARTIST"] << "</creator>\n";
	os << "\t\t<encoding>\n";
	os << "\t\t\t<encoder>" << song->info["TRANSCRIBER"] << "</encoder>\n";
	os << "\t\t\t<software>KGuitar</software>\n";
	os << "\t\t</encoding>\n";
	os << "\t</identification>\n";

// part list
	os << "\n";
	os << "\t<part-list>\n";
	// loop over all tracks
	for (unsigned int it = 0; it < song->rowCount(); it++) {
		    TabTrack* trk = song->index(it, 0).data(TabSong::TrackPtrRole).value<TabTrack*>();
		os << "\t\t<score-part id=\"P" << it+1 << "\">\n";
		os << "\t\t\t<part-name>" << trk->name << "</part-name>\n";
		// LVIFIX: fill-in real instrument-name instead of "Guitar"
		// note: in DTD 0.6 score-instrument may appear zero or more times
		//       within a score-part
		// note: in DTD 0.7a score-instrument apparently is required
		os << "\t\t\t<score-instrument id=\"P" << it+1
		   << "-I" << it+1 << "\">\n";
		os << "\t\t\t\t<instrument-name>" << "Guitar"
		   << "</instrument-name>\n";
		os << "\t\t\t</score-instrument>\n";
		os << "\t\t\t<midi-instrument id=\"P" << it+1
		   << "-I" << it+1 << "\">\n";
		os << "\t\t\t\t<midi-channel>" << trk->channel
		   << "</midi-channel>\n";
		os << "\t\t\t\t<midi-bank>" << trk->bank
		   << "</midi-bank>\n";
		os << "\t\t\t\t<midi-program>" << trk->patch
		   << "</midi-program>\n";
		os << "\t\t\t</midi-instrument>\n";
		os << "\t\t</score-part>\n";
	} // end for (unsigned int it = 0; ...
	os << "\t</part-list>\n";

// parts
	//TabTrack *trk;
	// loop over all tracks
	for (unsigned int it = 0; it < song->rowCount(); it++) {
		TabTrack* trk = song->index(it, 0).data(TabSong::TrackPtrRole).value<TabTrack*>();
		trk->calcVoices();
		trk->calcStepAltOct();
		trk->calcBeams();
		os << "\n";
		os << "\t<part id=\"P" << it+1 << "\">\n";

		// loop over all bars
		for (uint ib = 0; ib < trk->bars().size(); ib++) {
			os << "\t\t<measure number=\"" << ib + 1 << "\">\n";
			if (ib == 0) {
				// First bar: write all attributes
				os << "\t\t\t<attributes>\n";
				os << "\t\t\t\t<divisions>" << divisions << "</divisions>\n";
				os << "\t\t\t\t<key>\n";
				os << "\t\t\t\t\t<fifths>" << trk->bars()[0].keysig << "</fifths>\n";
				// LVIFX: re-enable when KGuitar supports major/minor modes
				// os << "\t\t\t\t\t<mode>major</mode>\n";
				os << "\t\t\t\t</key>\n";
				writeTime(os, trk->bars()[0].time1, trk->bars()[0].time2);
				os << "\t\t\t\t<staves>2</staves>\n";
				os << "\t\t\t\t<clef number=\"1\">\n";
				os << "\t\t\t\t\t<sign>G</sign>\n";
				os << "\t\t\t\t\t<line>2</line>\n";
				os << "\t\t\t\t\t<clef-octave-change>-1</clef-octave-change>\n";
				os << "\t\t\t\t</clef>\n";
				os << "\t\t\t\t<clef number=\"2\">\n";
				os << "\t\t\t\t\t<sign>TAB</sign>\n";
				os << "\t\t\t\t\t<line>5</line>\n";
				os << "\t\t\t\t</clef>\n";
				writeStaffDetails(os, trk);
				os << "\t\t\t</attributes>\n";
				os << "\t\t\t<sound tempo=\"" << song->tempo << "\"/>\n";
			} else {
				// LVIFIX write time sig if changed
			}

			// 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()) {
					// 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;
						if (!trk->getNoteTypeAndDots(x, i, tp, dt, tr)) {
							// LVIFIX: error handling ?
						}
*/
						x += writeCol(os, trk, x, i, true);
					} // end for ((i == 1) || ....
				} // end if (trk->hasMulti ...
			} // end for (int i = 0; ...

			os << "\t\t</measure>\n";
			os << "\n";
		} // end for (uint ib = 0; ...

		os << "\t</part>\n";
	} // end for (unsigned int it = 0; ...
	os << "\n";
	os << "</score-partwise>\n";
}
示例#6
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];
}