Skip to content

Commit

Permalink
timidity: minor clean-ups / tidy-ups, mostly whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
sezero committed Mar 17, 2021
1 parent ecd95f3 commit 5c4e48a
Show file tree
Hide file tree
Showing 14 changed files with 387 additions and 430 deletions.
25 changes: 13 additions & 12 deletions src/codecs/timidity/instrum.c
Expand Up @@ -141,8 +141,9 @@ static void reverse_data(Sint16 *sp, Sint32 ls, Sint32 le)
undefined.
TODO: do reverse loops right */
static Instrument *load_instrument(MidiSong *song, char *name, int percussion,
int panning, int amp, int note_to_use,
static Instrument *load_instrument(MidiSong *song, const char *name,
int percussion, int panning,
int amp, int note_to_use,
int strip_loop, int strip_envelope,
int strip_tail)
{
Expand Down Expand Up @@ -214,15 +215,15 @@ static Instrument *load_instrument(MidiSong *song, char *name, int percussion,
Uint16 tmpshort;
Uint8 tmpchar;

#define READ_CHAR(thing) \
if (1 != SDL_RWread(rw, &tmpchar, 1, 1)) goto fail; \
thing = tmpchar;
#define READ_SHORT(thing) \
if (1 != SDL_RWread(rw, &tmpshort, 2, 1)) goto fail; \
thing = SDL_SwapLE16(tmpshort);
#define READ_LONG(thing) \
if (1 != SDL_RWread(rw, &tmplong, 4, 1)) goto fail; \
thing = (Sint32)SDL_SwapLE32((Uint32)tmplong);
#define READ_CHAR(thing) \
if (1 != SDL_RWread(rw, &tmpchar, 1, 1)) goto fail; \
thing = tmpchar;
#define READ_SHORT(thing) \
if (1 != SDL_RWread(rw, &tmpshort, 2, 1)) goto fail; \
thing = SDL_SwapLE16(tmpshort);
#define READ_LONG(thing) \
if (1 != SDL_RWread(rw, &tmplong, 4, 1)) g oto fail; \
thing = (Sint32)SDL_SwapLE32((Uint32)tmplong);

SDL_RWseek(rw, 7, RW_SEEK_CUR); /* Skip the wave name */

Expand Down Expand Up @@ -581,7 +582,7 @@ void free_instruments(MidiSong *song)
}
}

int set_default_instrument(MidiSong *song, char *name)
int set_default_instrument(MidiSong *song, const char *name)
{
Instrument *ip;
if (!(ip=load_instrument(song, name, 0, -1, -1, -1, 0, 0, 0)))
Expand Down
8 changes: 3 additions & 5 deletions src/codecs/timidity/instrum.h
@@ -1,14 +1,12 @@
/*
TiMidity -- Experimental MIDI to WAVE converter
Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
This program is free software; you can redistribute it and/or modify
it under the terms of the Perl Artistic License, available in COPYING.
instrum.h
*/
instrum.h
*/

/* Bits in modes: */
#define MODES_16BIT (1<<0)
Expand All @@ -27,4 +25,4 @@

extern int load_missing_instruments(MidiSong *song);
extern void free_instruments(MidiSong *song);
extern int set_default_instrument(MidiSong *song, char *name);
extern int set_default_instrument(MidiSong *song, const char *name);
34 changes: 17 additions & 17 deletions src/codecs/timidity/mix.c
Expand Up @@ -77,14 +77,14 @@ void apply_envelope_to_amp(MidiSong *song, int v)
}

la = (Sint32)FSCALE(lamp,AMP_BITS);

if (la>MAX_AMP_VALUE)
la=MAX_AMP_VALUE;

ra = (Sint32)FSCALE(ramp,AMP_BITS);
if (ra>MAX_AMP_VALUE)
ra=MAX_AMP_VALUE;

song->voice[v].left_mix = la;
song->voice[v].right_mix = ra;
}
Expand Down Expand Up @@ -186,7 +186,7 @@ static void mix_mystery_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
left = vp->left_mix;
right = vp->right_mix;
}

while (count)
if (cc < count)
{
Expand Down Expand Up @@ -232,7 +232,7 @@ static void mix_center_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
return; /* Envelope ran out */
left = vp->left_mix;
}

while (count)
if (cc < count)
{
Expand Down Expand Up @@ -269,15 +269,15 @@ static void mix_single_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
left=vp->left_mix;
int cc;
sample_t s;

if (!(cc = vp->control_counter))
{
cc = song->control_ratio;
if (update_signal(song, v))
return; /* Envelope ran out */
left = vp->left_mix;
}

while (count)
if (cc < count)
{
Expand Down Expand Up @@ -314,15 +314,15 @@ static void mix_mono_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v,
left=vp->left_mix;
int cc;
sample_t s;

if (!(cc = vp->control_counter))
{
cc = song->control_ratio;
if (update_signal(song, v))
return; /* Envelope ran out */
left = vp->left_mix;
}

while (count)
if (cc < count)
{
Expand Down Expand Up @@ -355,7 +355,7 @@ static void mix_mystery(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int cou
left = song->voice[v].left_mix,
right = song->voice[v].right_mix;
sample_t s;

while (count--)
{
s = *sp++;
Expand All @@ -369,7 +369,7 @@ static void mix_center(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int coun
final_volume_t
left = song->voice[v].left_mix;
sample_t s;

while (count--)
{
s = *sp++;
Expand All @@ -383,7 +383,7 @@ static void mix_single(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int coun
final_volume_t
left = song->voice[v].left_mix;
sample_t s;

while (count--)
{
s = *sp++;
Expand All @@ -397,7 +397,7 @@ static void mix_mono(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count)
final_volume_t
left = song->voice[v].left_mix;
sample_t s;

while (count--)
{
s = *sp++;
Expand All @@ -408,7 +408,6 @@ static void mix_mono(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count)
/* Ramp a note out in c samples */
static void ramp_out(MidiSong *song, sample_t *sp, Sint32 *lp, int v, Sint32 c)
{

/* should be final_volume_t, but Uint8 gives trouble. */
Sint32 left, right, li, ri;

Expand Down Expand Up @@ -446,7 +445,7 @@ static void ramp_out(MidiSong *song, sample_t *sp, Sint32 *lp, int v, Sint32 c)
left += li;
if (left<0)
return;
s=*sp++;
s=*sp++;
MIXATION(left);
MIXATION(left);
}
Expand Down Expand Up @@ -534,16 +533,17 @@ void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c)
mix_center(song, sp, buf, v, c);
}
else
{
{
/* It's either full left or full right. In either case,
every other sample is 0. Just get the offset right: */
if (vp->panned == PANNED_RIGHT) buf++;

if (vp->envelope_increment || vp->tremolo_phase_increment)
mix_single_signal(song, sp, buf, v, c);
else
else
mix_single(song, sp, buf, v, c);
}
}
}
}

2 changes: 0 additions & 2 deletions src/codecs/timidity/mix.h
@@ -1,13 +1,11 @@
/*
TiMidity -- Experimental MIDI to WAVE converter
Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
This program is free software; you can redistribute it and/or modify
it under the terms of the Perl Artistic License, available in COPYING.
mix.h
*/

extern void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c);
Expand Down
5 changes: 2 additions & 3 deletions src/codecs/timidity/output.c
@@ -1,13 +1,12 @@
/*
/*
TiMidity -- Experimental MIDI to WAVE converter
Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
This program is free software; you can redistribute it and/or modify
it under the terms of the Perl Artistic License, available in COPYING.
output.c
Audio output (to file / device) functions.
*/

Expand Down
4 changes: 1 addition & 3 deletions src/codecs/timidity/output.h
@@ -1,13 +1,11 @@
/*
/*
TiMidity -- Experimental MIDI to WAVE converter
Copyright (C) 1995 Tuukka Toivonen <toivonen@clinet.fi>
This program is free software; you can redistribute it and/or modify
it under the terms of the Perl Artistic License, available in COPYING.
output.h
*/

/* Data format encoding bits */
Expand Down

0 comments on commit 5c4e48a

Please sign in to comment.