コード例 #1
0
ファイル: smf.c プロジェクト: 63n/ardour
/**
 * Appends smf_track_t to smf.
 */
void
smf_add_track(smf_t *smf, smf_track_t *track)
{
#ifndef NDEBUG
	int cantfail;
#endif

	assert(track->smf == NULL);

	track->smf = smf;
	g_ptr_array_add(smf->tracks_array, track);

	smf->number_of_tracks++;
	track->track_number = smf->number_of_tracks;

	if (smf->number_of_tracks > 1) {
#ifndef NDEBUG
		cantfail = smf_set_format(smf, 1);
		assert(!cantfail);
#else
		smf_set_format(smf, 1);
#endif

	}
}
コード例 #2
0
ファイル: smfsh.c プロジェクト: DanielAeolusLaude/ardour
static int
cmd_format(char *new_format)
{
	int tmp;
	char *end;

	if (new_format == NULL) {
		g_message("Format is %d.", smf->format);
	} else {
		tmp = strtol(new_format, &end, 10);
		if (end - new_format != strlen(new_format)) {
			g_critical("Invalid format value, garbage characters after the number.");
			return (-1);
		}

		if (tmp < 0 || tmp > 2) {
			g_critical("Invalid format value, valid values are in range 0 - 2, inclusive.");
			return (-2);
		}

		if (smf_set_format(smf, tmp)) {
			g_critical("smf_set_format failed.");
			return (-3);
		}

		g_message("Forma changed to %d.", smf->format);
	}
	
	return (0);
}
コード例 #3
0
ファイル: smf.c プロジェクト: Darko8/libsmf
/**
 * Allocates new smf_t structure.
 * \return pointer to smf_t or NULL.
 */
smf_t *
smf_new(void)
{
	int cantfail;

	smf_t *smf = malloc(sizeof(smf_t));
	if (smf == NULL) {
		g_critical("Cannot allocate smf_t structure: %s", strerror(errno));
		return (NULL);
	}

	memset(smf, 0, sizeof(smf_t));

	smf->tracks_array = g_ptr_array_new();
	assert(smf->tracks_array);

	smf->tempo_array = g_ptr_array_new();
	assert(smf->tempo_array);

	cantfail = smf_set_ppqn(smf, 120);
	assert(!cantfail);

	cantfail = smf_set_format(smf, 0);
	assert(!cantfail);

	smf_init_tempo(smf);

	return (smf);
}
コード例 #4
0
ファイル: smf.c プロジェクト: Darko8/libsmf
/**
 * Appends smf_track_t to smf.
 */
void
smf_add_track(smf_t *smf, smf_track_t *track)
{
	int cantfail;

	assert(track->smf == NULL);

	track->smf = smf;
	g_ptr_array_add(smf->tracks_array, track);

	smf->number_of_tracks++;
	track->track_number = smf->number_of_tracks;

	if (smf->number_of_tracks > 1) {
		cantfail = smf_set_format(smf, 1);
		assert(!cantfail);
	}
}