Esempio n. 1
0
gint gint_compare_by_tte(gconstpointer ptr_a, gconstpointer ptr_b) {
	Account *a, *b;
	a = (Account *) ptr_a;
	b = (Account *) ptr_b;
	int tte_a = getTimeToEnd(a);
	int tte_b = getTimeToEnd(b);
	if (tte_a > tte_b) {
		return (-1);
	}
	if (tte_a == tte_b) {
		return 0;
	}
	return (1);
}
Esempio n. 2
0
void print_account_screen1(Account * ac) {
	int x, y;
	char buf[1024];
	char stringBuf[1024];

	memset( buf, 0, sizeof( buf ) ); memset( stringBuf, 0, sizeof( stringBuf ) );
	snprintf(stringBuf, 1024, "%s", print_formatted_user_name(ac->id, buf));
	printf("%-18s ", stringBuf);
	printString(buf, A_BOLD, 17, NONEWLINE);

	memset( buf, 0, sizeof( buf ) ); memset( stringBuf, 0, sizeof( stringBuf ) );
	sprintf(buf, "%d/%d/%d ", (int) ceil(fabs(ac->current.cpu * 100.0)),
			(int) ceil(fabs(ac->mid_average.cpu * 100.0)), (int) ceil(fabs(
					ac->long_average.cpu * 100.0)));
	printString(buf, A_NORMAL, 20, NONEWLINE);

	memset( buf, 0, sizeof( buf ) ); memset( stringBuf, 0, sizeof( stringBuf ) );
	formatIntString(stringBuf, 3, "/", ac->current.read, ac->mid_average.read,
			ac->long_average.read);
	sprintf(buf, "%-19s ", stringBuf);
	printString(buf, A_NORMAL, 19, NONEWLINE);

	memset( buf, 0, sizeof( buf ) ); memset( stringBuf, 0, sizeof( stringBuf ) );
	formatIntString(stringBuf, 3, "/", ac->current.write,
			ac->mid_average.write, ac->long_average.write);
	sprintf(buf, "%-17s ", stringBuf);
	printString(buf, A_NORMAL, 17, NONEWLINE);

	memset( buf, 0, sizeof( buf ) ); memset( stringBuf, 0, sizeof( stringBuf ) );
	getRestrictInfo(ac, stringBuf);
	if (ac->info.field_restrict != NO_PERIOD) {
		sprintf(buf, "%c/%s%d", getRestrictChar(ac->restricted), stringBuf,
				getTimeToEnd(ac));
	} else {
		strcpy(buf, "-");
	}
	printString(buf, A_NORMAL, 24, NEWLINE);
}
Esempio n. 3
0
void print_account_screen1_no_curses(Account * ac) {
	char buf[1024];
	char stringBuf[1024];
	snprintf(stringBuf, 1024, "%s", print_formatted_user_name(ac->id, buf));
	printf("%-18s ", stringBuf);
	sprintf(stringBuf, "%d/%d/%d ", (int) ceil(fabs(ac->current.cpu * 100.0)),
			(int) ceil(fabs(ac->mid_average.cpu * 100.0)), (int) ceil(fabs(
					ac->long_average.cpu * 100.0)));
	printf("%-20s ", stringBuf);
	formatIntString(stringBuf, 3, "/", ac->current.read, ac->mid_average.read,
			ac->long_average.read);
	printf("%-21s ", stringBuf);
	formatIntString(stringBuf, 3, "/", ac->current.write,
			ac->mid_average.write, ac->long_average.write);
	printf("%-18s ", stringBuf);
	getRestrictInfo(ac, stringBuf);
	if (ac->info.field_restrict != NO_PERIOD) {
		sprintf(buf, "%c/%s%d", getRestrictChar(ac->restricted), stringBuf,
				getTimeToEnd(ac));
	} else {
		strcpy(buf, "-");
	}
	printf("%s\n", buf);
}
Esempio n. 4
0
void printOutput(HumdrumFile& hfile) {
   Array<double> tempo;
   hfile.analyzeTempoMarkings(tempo, tdefault);

   double currentmillisecond = 0.0;
   double lastduration = 0.0;

   double linestarttime = 0.0;
   double lineendtime = 0.0;

   int founddata = 0;

   int metlev;
   int i, j, k;
   char buffer1[1024] = {0};
   char buffer2[1024] = {0};
   double duration;
   for (i=0; i<hfile.getNumLines(); i++) {
      currentmillisecond = currentmillisecond + 
            lastduration * 60000.0 / tempo[i];
      lastduration = hfile[i].getDuration();

      if (hfile[i].getType() == E_humrec_global_comment) {
         cout << "%% " << &(hfile[i].getLine()[3]) << endl;
      }

      if (hfile[i].getType() == E_humrec_bibliography) {
         cout << "%%%" << &(hfile[i].getLine()[3]) << endl;
      }


      if (hfile[i].getType() != E_humrec_data) {
         continue;
      }

      if (debugQ) {
         cout << "RECORD: " << hfile[i] << endl;
      }

      if (founddata == 0) {
         founddata = 1;

         comment(cout, 2, humdrumQ);
         cout << " Data column information:\n";
         comment(cout, 3, humdrumQ);
         cout << "col01: abstime\t" << 
                 "(average absolute time in milliseconds of human "
              << "beats)\n";
         comment(cout, 3, humdrumQ);
         cout << "col02: duration\t" <<
                 "(expected duration in ms based "
              << "on score duration)\n";
         comment(cout, 3, humdrumQ);
         cout << "col03: note\t\t" << 
                 "(MIDI note number of pitch)\n";
         comment(cout, 3, humdrumQ);
         cout << "col04: metlev\t" << 
                 "(metric level: 1 = downbeat; "
              <<  "0 = beat; -1 = offbeat)\n";
         comment(cout, 3, humdrumQ);
         cout << "col05: measure\t" <<
                  "(measure number in which note occurs)\n";
         comment(cout, 3, humdrumQ);
         cout << "col06: absbeat\t" <<
                 "(absolute beat from starting beat at 0)\n";
         comment(cout, 3, humdrumQ);
         cout << "col07: trackno\t" << 
                 "(hand which plays the note: 1 = left; 2=right)\n";
	 if (!auxdataQ) {
            comment(cout, 3, humdrumQ);
            cout << "col08: mintime\t" << 
                    "(minimum absolute time of human beat for this note)\n";
            comment(cout, 3, humdrumQ);
            cout << "col09: maxtime\t" << 
                    "(maximum absolute time of human beat for this note)\n";
            comment(cout, 3, humdrumQ);
            cout << "col10: sd\t\t" << 
                    "(standard deviation of human beat time in ms.)\n";
	 } else {
            //comment(cout, 3, humdrumQ);
            //cout << "col08: paccid\t" <<
	    //	    "(printed accidental 0=none, -1=flat, +1=sharp, 10=nat)\n";
            comment(cout, 3, humdrumQ);
            cout << "col08: saccid\t" <<
		    "(sounding accidental 0=natural, -1=flat, +1=sharp)\n";
         }
		   
         if (humdrumQ) {
            cout << "**start\t**dur\t**key\t**metr\t**meas\t**absb\t**track\t**saccid\n";
         }
      }
	        

      linestarttime = -1.0;
      // find current time value and save 
      for (j=0; j<hfile[i].getFieldCount(); j++) {
         if (strcmp(hfile[i].getExInterp(j), "**time") == 0) {
            sscanf(hfile[i][j], "%lf", &linestarttime);
            break;
         }
      }

      for (j=0; j<hfile[i].getFieldCount(); j++) {
         if (hfile[i].getExInterpNum(j) != E_KERN_EXINT) {
            continue;
         }

         for (k=0; k<hfile[i].getTokenCount(j); k++) {
            if (strcmp(hfile[i][j], ".") == 0) {
               continue;
            }
            hfile[i].getToken(buffer1, j, k);
            if (strchr(buffer1, '_') != NULL) {
               // ignore notes which are tied
               continue;
            }
            if (strchr(buffer1, ']') != NULL) {
               // ignore notes which are tied
               continue;
            }

            preparePitch(buffer2, buffer1);
            duration = hfile.getTiedDuration(i, j, k);
            lineendtime = getEndTime(hfile, i, duration);

            int note = Convert::kernToMidiNoteNumber(buffer2);
            if (classQ) {
               note = note % 12;
            }
            if (note < 0) {
               // don't display rests.
               continue;
            }
            if (note < 0 || note > 127) {
               cerr << "Error reading MIDI pitch number from string: " 
                    << buffer2 << endl;
               exit(1);
            }

            //cout << "Note\t";
            // cout << hfile.getAbsBeat(i) << "\t";
            // cout << (int)(currentmillisecond+0.5) << "\t";
            cout << linestarttime << "\t";

            if (debugQ && (lineendtime - linestarttime < 0)) {
               cerr << "Error duration of note on line: " << hfile[i] << endl;
               cerr << "Starttime: " << linestarttime << endl;
               cerr << "Endtime:   " << lineendtime << endl;
               cerr << "Line Index:     " << i << endl;
               exit(1);
            } 
            if (lineendtime != -1) {
               cout << lineendtime - linestarttime << "\t";
            } else {
               cout << (int)(getTimeToEnd(hfile, linestarttime, i) + 0.5) 
                    << "\t";
            }

            cout << note;

            cout << "\t";
            
            metlev = getMetricLevel(hfile, i);
            cout << metlev;

            cout << "\t" << getMeasureNum(hfile, i);

            cout << "\t" << hfile[i].getAbsBeat();

            // you must make sure that the spine order is
            // correct or this data will be bad
            cout << "\t" << hfile[i].getPrimaryTrack(j)-1;
   
            cout << "\t"; 
	    printSaccid(cout, buffer2);
 
            cout << "\n";
         }
      }
   }

   if (humdrumQ) {
      cout << "*-\t*-\t*-\t*-\t*-\t*-\t*-\t*-\n";
   }
}