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

	if (new_ppqn == NULL) {
		g_message("Pulses Per Quarter Note (aka Division) is %d.", smf->ppqn);
	} else {
		tmp = strtol(new_ppqn, &end, 10);
		if (end - new_ppqn != strlen(new_ppqn)) {
			g_critical("Invalid PPQN, garbage characters after the number.");
			return (-1);
		}

		if (tmp <= 0) {
			g_critical("Invalid PPQN, valid values are greater than zero.");
			return (-2);
		}

		if (smf_set_ppqn(smf, tmp)) {
			g_message("smf_set_ppqn failed.");
			return (-3);
		}

		g_message("Pulses Per Quarter Note changed to %d.", smf->ppqn);
	}
	
	return (0);
}
コード例 #2
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);
}