void print_breaks(Cd *cd, int gaps)
{
	int i;
	long b;
	long pg;
	Track *track;

	for (i = 1; i <= cd_get_ntrack(cd); i++) {
		track = cd_get_track(cd, i);
		/*
		 * When breakpoint is at:
		 * index 0: gap is prepended to track
		 * index 1: gap is appended to previous track
		 */
		b = track_get_start(track);
		pg = track_get_index(track, 1) - track_get_zero_pre(track);

		if (gaps == PREPEND || gaps == SPLIT) {
			print_breakpoint(b);
		/*
		 * There is no previous track to append the first track's
		 * pregap to.
		 */
		} else if (gaps == APPEND && 1 < i) {
			print_breakpoint(b + pg);
		}

		/* If pregap exists, print breakpoints (in split mode). */
		if (gaps == SPLIT && 0 < pg) {
			print_breakpoint(b + pg);
		}
	}
}
Пример #2
0
static char* cue_test()
{
   Cd *cd = cue_parse_string (cue);
   mu_assert ("error parsing CUE", cd != NULL);

   Rem *rem = cd_get_rem (cd);
   mu_assert ("error getting REM", rem != NULL);

   Cdtext *cdtext = cd_get_cdtext (cd);
   mu_assert ("error getting CDTEXT", cdtext != NULL);

   const char *val;
   val = cdtext_get (PTI_PERFORMER, cdtext);
   mu_assert ("error getting CD performer", val != NULL);
   mu_assert ("error validating CD performer", strcmp (val, "Bloc Party") == 0);

   val = cdtext_get (PTI_TITLE, cdtext);
   mu_assert ("error getting CD title", val != NULL);
   mu_assert ("error validating CD title", strcmp (val, "Silent Alarm") == 0);

   int ival = cd_get_ntrack (cd);
   mu_assert ("invalid number of tracks", ival == 2);

   Track *track;
   /* Track 1 */
   track = cd_get_track (cd, 1);
   mu_assert ("error getting track", track != NULL);

   val = track_get_filename (track);
   mu_assert ("error getting track filename", val != NULL);
   mu_assert ("error validating track filename", strcmp (val, "Bloc Party - Silent Alarm.flac") == 0);

   cdtext = track_get_cdtext (track);
   mu_assert ("error getting track CDTEXT", cdtext != NULL);

   val = cdtext_get (PTI_PERFORMER, cdtext);
   mu_assert ("error getting track performer", val != NULL);
   mu_assert ("error validating track performer", strcmp (val, "Bloc Party") == 0);

   val = cdtext_get (PTI_TITLE, cdtext);
   mu_assert ("error getting track title", val != NULL);
   mu_assert ("error validating track title", strcmp (val, "Like Eating Glass") == 0);

   ival = track_get_zero_pre (track);
   mu_assert ("invalid track pre-gap", ival == MSF_TO_F(3,22,70));
   ival = track_get_start (track);
   mu_assert ("invalid track start", ival == MSF_TO_F(3,22,70));
   ival = track_get_length (track);
   mu_assert ("invalid track length", ival == MSF_TO_F(4,19,74));

   ival = track_get_index (track, 0);
   mu_assert ("invalid index", ival == 0);
   ival = track_get_index (track, 1);
   mu_assert ("invalid index", ival == MSF_TO_F(3,22,70));

   /* Track 2 */
   track = cd_get_track (cd, 2);
   mu_assert ("error getting track", track != NULL);

   val = track_get_filename (track);
   mu_assert ("error getting track filename", val != NULL);
   mu_assert ("error validating track filename", strcmp (val, "Bloc Party - Silent Alarm.flac") == 0);

   cdtext = track_get_cdtext (track);
   mu_assert ("error getting track CDTEXT", cdtext != NULL);

   val = cdtext_get (PTI_PERFORMER, cdtext);
   mu_assert ("error getting track performer", val != NULL);
   mu_assert ("error validating track performer", strcmp (val, "Bloc Party") == 0);

   val = cdtext_get (PTI_TITLE, cdtext);
   mu_assert ("error getting track title", val != NULL);
   mu_assert ("error validating track title", strcmp (val, "Helicopter") == 0);

   ival = track_get_zero_pre (track);
   mu_assert ("invalid track pre-gap", ival == MSF_TO_F(0,2,0));
   ival = track_get_start (track);
   mu_assert ("invalid track start", ival == MSF_TO_F(7,44,69));
   ival = track_get_length (track);
   mu_assert ("invalid track length", ival == -1);

   ival = track_get_index (track, 0);
   mu_assert ("invalid index", ival == MSF_TO_F(7,42,69));
   ival = track_get_index (track, 1);
   mu_assert ("invalid index", ival == MSF_TO_F(7,44,69));

   cd_delete (cd);

   return NULL;
}
Пример #3
0
void cue_print_track (FILE *fp, Track *track, int trackno)
{
	Cdtext *cdtext = track_get_cdtext(track);
	int i; 	/* index */

	if (NULL != track_get_filename(track)) {
		/* 
		 * always print filename for track 1, afterwards only
		 * print filename if it differs from the previous track
		 */
		if (0 != strcmp(track_get_filename(track), filename)) {
			filename = track_get_filename(track);
			fprintf(fp, "FILE \"%s\" ", filename);

			/* NOTE: what to do with other formats (MP3, etc)? */
			if (MODE_AUDIO == track_get_mode(track))
				fprintf(fp, "WAVE\n");
			else
				fprintf(fp, "BINARY\n");
		}
	}

	fprintf(fp, "TRACK %02d ", trackno);
	switch (track_get_mode(track)) {
	case MODE_AUDIO:
		fprintf(fp, "AUDIO\n");
		break;
	case MODE_MODE1:
		fprintf(fp, "MODE1/2048\n");
		break;
	case MODE_MODE1_RAW:
		fprintf(fp, "MODE1/2352\n");
		break;
	case MODE_MODE2:
		fprintf(fp, "MODE2/2048\n");
		break;
	case MODE_MODE2_FORM1:
		fprintf(fp, "MODE2/2336\n");
		break;
	case MODE_MODE2_FORM2:
		fprintf(fp, "MODE2/2324\n");
		break;
	case MODE_MODE2_FORM_MIX:
		fprintf(fp, "MODE2/2336\n");
		break;
	case MODE_MODE2_RAW:
		fprintf(fp, "MODE2/2352\n");
		break;
	}

	cue_print_cdtext(cdtext, fp, 1);

	if (0 != track_is_set_flag(track, FLAG_ANY)) {
		fprintf(fp, "FLAGS");
		if (0 != track_is_set_flag(track, FLAG_PRE_EMPHASIS))
			fprintf(fp, " PRE");
		if (0 != track_is_set_flag(track, FLAG_COPY_PERMITTED))
			fprintf(fp, " DCP");
		if (0 != track_is_set_flag(track, FLAG_FOUR_CHANNEL))
			fprintf(fp, " 4CH");
		if (0 != track_is_set_flag(track, FLAG_SCMS))
			fprintf(fp, " SCMS");
		fprintf(fp, "\n");
	}

	if (NULL != track_get_isrc(track))
		fprintf(fp, "ISRC %s\n", track_get_isrc(track));

	if (0 != track_get_zero_pre(track))
		fprintf (fp, "PREGAP %s\n", time_frame_to_mmssff(track_get_zero_pre(track)));

	/* don't print index 0 if index 1 = 0 */
	if (track_get_index(track, 1) == 0)
		i = 1;
	else
		i = 0;

	for (; i < track_get_nindex(track); i++) {
		fprintf(fp, "INDEX %02d ", i);
		cue_print_index( \
		track_get_index(track, i) \
		+ track_get_start(track) \
		- track_get_zero_pre(track) , fp);
	}

	if (0 != track_get_zero_post(track))
		fprintf (fp, "POSTGAP %s\n", time_frame_to_mmssff(track_get_zero_post(track)));

	prev_length = track_get_length(track);
}
Пример #4
0
void toc_print_track (FILE *fp, Track *track)
{
	Cdtext *cdtext = track_get_cdtext(track);
	int i;	/* index */

	fprintf(fp, "TRACK ");
	switch (track_get_mode(track)) {
	case MODE_AUDIO:
		fprintf(fp, "AUDIO");
	       	break;
	case MODE_MODE1:
		fprintf(fp, "MODE1");
	       	break;
	case MODE_MODE1_RAW:
		fprintf(fp, "MODE1_RAW");
	       	break;
	case MODE_MODE2:
		fprintf(fp, "MODE2");
	       	break;
	case MODE_MODE2_FORM1:
		fprintf(fp, "MODE2_FORM1");
	       	break;
	case MODE_MODE2_FORM2:
		fprintf(fp, "MODE2_FORM2");
	       	break;
	case MODE_MODE2_FORM_MIX:
		fprintf(fp, "MODE2_FORM_MIX");
	       	break;
	}
	fprintf(fp, "\n");

	if (0 != track_is_set_flag(track, FLAG_PRE_EMPHASIS)) {
		fprintf(fp, "PRE_EMPHASIS\n");
	}
	if (0 != track_is_set_flag(track, FLAG_COPY_PERMITTED)) {
		fprintf(fp, "COPY\n");
	}
	if (0 != track_is_set_flag(track, FLAG_FOUR_CHANNEL)) {
		fprintf(fp, "FOUR_CHANNEL_AUDIO\n");
	}

	if (NULL != track_get_isrc(track)) {
		fprintf(fp, "ISRC \"%s\"\n", track_get_isrc(track));
	}

	if (0 != cdtext_is_empty(cdtext)) {
		fprintf(fp, "CD_TEXT {\n");
		fprintf(fp, "\tLANGUAGE 0 {\n");
		toc_print_cdtext(cdtext, fp, 1);
		fprintf(fp, "\t}\n");
		fprintf(fp, "}\n");
	}

	if (0 != track_get_zero_pre(track)) {
		fprintf(fp, "SILENCE ");
		fprintf(fp, "%s", time_frame_to_mmssff(track_get_zero_pre(track)));
		fprintf(fp, "\n");
	}

	fprintf(fp, "FILE ");
	fprintf(fp, "\"%s\" ", track_get_filename(track));
	if (0 == track_get_start(track)) {
		fprintf(fp, "0");
	} else {
		fprintf(fp, "%s", time_frame_to_mmssff(track_get_start(track)));
	}
	if (0 != track_get_length(track)) {
		fprintf(fp, " %s", time_frame_to_mmssff(track_get_length(track)));
	}
	fprintf(fp, "\n");

	if (0 != track_get_zero_post(track)) {
		fprintf(fp, "SILENCE ");
		fprintf(fp, "%s", time_frame_to_mmssff(track_get_zero_post(track)));
		fprintf(fp, "\n");
	}

	if (track_get_index(track, 1) != 0) {
		fprintf(fp, "START ");
		fprintf(fp, "%s\n", time_frame_to_mmssff(track_get_index(track, 1)));
	}

	for (i = 2; i < track_get_nindex(track); i++) {
		fprintf(fp, "INDEX ");
		fprintf(fp, "%s\n", time_frame_to_mmssff(
			// Indices in TOC are relative to the START
			track_get_index(track, i) - track_get_index(track, 1)
		));
	}
}
Пример #5
0
static char* cue_pregap_test()
{
   Cd *cd = cue_parse_string (cue_pregap);
   mu_assert ("error parsing CUE", cd != NULL);

   Rem *rem = cd_get_rem (cd);
   mu_assert ("error getting REM", rem != NULL);

   Cdtext *cdtext = cd_get_cdtext (cd);
   mu_assert ("error getting CDTEXT", cdtext != NULL);

   const char *val;
   val = cdtext_get (PTI_PERFORMER, cdtext);
   mu_assert ("error validating CD performer", val == NULL);

   val = cdtext_get (PTI_TITLE, cdtext);
   mu_assert ("error validating CD title", val == NULL);

   int ival = cd_get_ntrack (cd);
   mu_assert ("invalid number of tracks", ival == 2);

   Track *track;
   /* Track 1 */
   track = cd_get_track (cd, 1);
   mu_assert ("error getting track", track != NULL);

   val = track_get_filename (track);
   mu_assert ("error getting track filename", val != NULL);
   mu_assert ("error validating track filename", strcmp (val, "The Specials - Singles - 01 - Gangsters.wav") == 0);

   cdtext = track_get_cdtext (track);
   mu_assert ("error getting track CDTEXT", cdtext != NULL);

   val = cdtext_get (PTI_PERFORMER, cdtext);
   mu_assert ("error getting track performer", val != NULL);
   mu_assert ("error validating track performer", strcmp (val, "The Specials") == 0);

   val = cdtext_get (PTI_TITLE, cdtext);
   mu_assert ("error getting track title", val != NULL);
   mu_assert ("error validating track title", strcmp (val, "Gangsters") == 0);

   ival = track_get_start (track);
   mu_assert ("invalid track start", ival == 0);
   ival = track_get_length (track);
   mu_assert ("invalid track length", ival == -1);

   ival = track_get_index (track, 1);
   mu_assert ("invalid index", ival == 0);

   /* Track 2 */
   track = cd_get_track (cd, 2);
   mu_assert ("error getting track", track != NULL);

   val = track_get_filename (track);
   mu_assert ("error getting track filename", val != NULL);
   mu_assert ("error validating track filename", strcmp (val, "The Specials - Singles - 02 - Rudi, A Message To You.wav") == 0);

   cdtext = track_get_cdtext (track);
   mu_assert ("error getting track CDTEXT", cdtext != NULL);

   val = cdtext_get (PTI_PERFORMER, cdtext);
   mu_assert ("error getting track performer", val != NULL);
   mu_assert ("error validating track performer", strcmp (val, "The Specials") == 0);

   val = cdtext_get (PTI_TITLE, cdtext);
   mu_assert ("error getting track title", val != NULL);
   mu_assert ("error validating track title", strcmp (val, "Rudi, A Message To You") == 0);

   ival = track_get_zero_pre (track);
   mu_assert ("invalid track pre-gap", ival == 28);
   ival = track_get_start (track);
   mu_assert ("invalid track start", ival == 0);
   ival = track_get_length (track);
   mu_assert ("invalid track length", ival == -1);

   ival = track_get_index (track, 1);
   mu_assert ("invalid index", ival == 0);

   cd_delete (cd);

   return NULL;
}