static int import_oggvorbis_discriminant(char *sample_file)
{
struct timidity_file *tf = open_file(sample_file, 1, OF_NORMAL);
- char buf[4];
if (tf == NULL)
return 1;
+ char buf[4];
if (tf_read(buf, 1, 4, tf) != 4 || memcmp(buf, "OggS", 4) != 0) {
close_file(tf);
return 1;
static int import_oggvorbis_load(char *sample_file, Instrument *inst)
{
struct timidity_file *tf = open_file(sample_file, 1, OF_NORMAL);
- SampleDecodeResult sdr;
- int ret;
if (tf == NULL)
return 1;
- sdr = decode_oggvorbis(tf);
+ SampleDecodeResult sdr = decode_oggvorbis(tf);
close_file(tf);
- ret = make_instrument_from_sample_decode_result(inst, &sdr);
+ int ret = make_instrument_from_sample_decode_result(inst, &sdr);
clear_sample_decode_result(&sdr);
return ret;
}
static int import_flac_discriminant(char *sample_file)
{
struct timidity_file *tf = open_file(sample_file, 1, OF_NORMAL);
- char buf[4];
if (tf == NULL)
return 1;
+ char buf[4];
if (tf_read(buf, 1, 4, tf) != 4 || memcmp(buf, "fLaC", 4) != 0) {
close_file(tf);
return 1;
static int import_flac_load(char *sample_file, Instrument *inst)
{
struct timidity_file *tf = open_file(sample_file, 1, OF_NORMAL);
- SampleDecodeResult sdr;
- int ret;
if (tf == NULL)
return 1;
- sdr = decode_flac(tf);
+ SampleDecodeResult sdr = decode_flac(tf);
close_file(tf);
- ret = make_instrument_from_sample_decode_result(inst, &sdr);
+ int ret = make_instrument_from_sample_decode_result(inst, &sdr);
clear_sample_decode_result(&sdr);
return ret;
}
static int import_mp3_discriminant(char *sample_file)
{
struct timidity_file *tf = open_file(sample_file, 1, OF_NORMAL);
- unsigned char buf[3] = {0};
if (tf == NULL)
return 1;
+ unsigned char buf[3] = {0};
tf_read(buf, 1, 3, tf);
close_file(tf);
static int import_mp3_load(char *sample_file, Instrument *inst)
{
struct timidity_file *tf = open_file(sample_file, 1, OF_NORMAL);
- SampleDecodeResult sdr;
- int ret;
if (tf == NULL)
return 1;
- sdr = decode_mp3(tf);
+ SampleDecodeResult sdr = decode_mp3(tf);
close_file(tf);
- ret = make_instrument_from_sample_decode_result(inst, &sdr);
+ int ret = make_instrument_from_sample_decode_result(inst, &sdr);
clear_sample_decode_result(&sdr);
return ret;
}
static int make_instrument_from_sample_decode_result(Instrument *inst, SampleDecodeResult *sdr)
{
- int i;
if (sdr->channels == 0)
return 1;
initialize_sample(inst, (int)(sdr->data_length >> FRACTION_BITS), get_sample_size_for_sample_type(sdr->data_type), sdr->sample_rate);
- for (i = 0; i < inst->samples; i++) {
+ for (int i = 0; i < inst->samples; i++) {
Sample *s = &inst->sample[i];
s->data = sdr->data[i];
sdr->data[i] = NULL;