From 68ab769dc4fddc146c08f41e71d58e145baac4f5 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 18 Mar 2021 10:10:00 +0300
Subject: [PATCH] timidity: add header guards, hide private syms by prefixing
with timi_.
---
src/codecs/timidity/common.c | 6 ++---
src/codecs/timidity/common.h | 20 ++++++++++++---
src/codecs/timidity/instrum.c | 8 +++---
src/codecs/timidity/instrum.h | 9 +++++++
src/codecs/timidity/mix.c | 13 +++++-----
src/codecs/timidity/mix.h | 9 +++++++
src/codecs/timidity/options.h | 20 ++++++++++-----
src/codecs/timidity/output.c | 18 ++++++-------
src/codecs/timidity/output.h | 47 +++++++++++++++++++---------------
src/codecs/timidity/playmidi.c | 31 +++++++++++-----------
src/codecs/timidity/playmidi.h | 9 ++++---
src/codecs/timidity/readmidi.c | 1 +
src/codecs/timidity/readmidi.h | 7 +++++
src/codecs/timidity/resample.c | 14 +++++-----
src/codecs/timidity/resample.h | 8 ++++++
src/codecs/timidity/tables.c | 1 +
src/codecs/timidity/tables.h | 13 +++++++++-
src/codecs/timidity/timidity.c | 26 +++++++++----------
18 files changed, 168 insertions(+), 92 deletions(-)
diff --git a/src/codecs/timidity/common.c b/src/codecs/timidity/common.c
index 2798284..1096a38 100644
--- a/src/codecs/timidity/common.c
+++ b/src/codecs/timidity/common.c
@@ -32,7 +32,7 @@ typedef struct _PathList {
static PathList *pathlist = NULL;
/* This is meant to find and open files for reading */
-SDL_RWops *open_file(const char *name)
+SDL_RWops *timi_openfile(const char *name)
{
SDL_RWops *rw;
@@ -81,7 +81,7 @@ SDL_RWops *open_file(const char *name)
}
/* This adds a directory to the path list */
-int add_to_pathlist(const char *s, size_t l)
+int timi_add_pathlist(const char *s, size_t l)
{
PathList *plp = SDL_malloc(sizeof(PathList));
if (plp == NULL) return -2;
@@ -97,7 +97,7 @@ int add_to_pathlist(const char *s, size_t l)
return 0;
}
-void free_pathlist(void)
+void timi_free_pathlist(void)
{
PathList *plp = pathlist;
PathList *next;
diff --git a/src/codecs/timidity/common.h b/src/codecs/timidity/common.h
index 46e68db..69d5f5f 100644
--- a/src/codecs/timidity/common.h
+++ b/src/codecs/timidity/common.h
@@ -8,6 +8,20 @@
common.h
*/
-extern SDL_RWops *open_file(const char *name);
-extern int add_to_pathlist(const char *s, size_t len);
-extern void free_pathlist(void);
+#ifndef TIMIDITY_COMMON_H
+#define TIMIDITY_COMMON_H
+
+extern SDL_RWops *timi_openfile(const char *name);
+
+/* pathlist funcs only to be used during Timidity_Init/Timidity_Exit */
+extern int timi_add_pathlist(const char *s, size_t len);
+extern void timi_free_pathlist(void);
+
+/* hide private symbols by prefixing with "_timi_" */
+#undef TIMI_NAMESPACE
+#define TIMI_NAMESPACE(x) _timi_ ## x
+
+/* debug output */
+#define SNDDBG(X)
+
+#endif /* TIMIDITY_COMMON_H */
diff --git a/src/codecs/timidity/instrum.c b/src/codecs/timidity/instrum.c
index 0400199..8868d46 100644
--- a/src/codecs/timidity/instrum.c
+++ b/src/codecs/timidity/instrum.c
@@ -93,8 +93,8 @@ static Sint32 convert_vibrato_sweep(MidiSong *song, Uint8 sweep,
return 0;
return
- (Sint32) (FSCALE((double) (vib_control_ratio) * SWEEP_TUNING, SWEEP_SHIFT)
- / (double)(song->rate * sweep));
+ (Sint32) (TIM_FSCALE((double) (vib_control_ratio) * SWEEP_TUNING, SWEEP_SHIFT)
+ / (double)(song->rate * sweep));
/* this was overflowing with seashore.pat
@@ -160,13 +160,13 @@ static void load_instrument(MidiSong *song, const char *name,
if (!name) return;
/* Open patch file */
- if ((rw=open_file(name)) == NULL)
+ if ((rw=timi_openfile(name)) == NULL)
{
/* Try with various extensions */
for (i=0; patch_ext[i]; i++)
{
SDL_snprintf(tmp, sizeof(tmp), "%s%s", name, patch_ext[i]);
- if ((rw=open_file(tmp)) != NULL)
+ if ((rw=timi_openfile(tmp)) != NULL)
break;
}
}
diff --git a/src/codecs/timidity/instrum.h b/src/codecs/timidity/instrum.h
index fa3f3ba..0fa6505 100644
--- a/src/codecs/timidity/instrum.h
+++ b/src/codecs/timidity/instrum.h
@@ -8,6 +8,9 @@
instrum.h
*/
+#ifndef TIMIDITY_INSTRUM_H
+#define TIMIDITY_INSTRUM_H
+
/* Bits in modes: */
#define MODES_16BIT (1<<0)
#define MODES_UNSIGNED (1<<1)
@@ -23,6 +26,12 @@
#define SPECIAL_PROGRAM -1
+#define load_missing_instruments TIMI_NAMESPACE(load_missing_instruments)
+#define free_instruments TIMI_NAMESPACE(free_instruments)
+#define set_default_instrument TIMI_NAMESPACE(set_default_instrument)
+
extern int load_missing_instruments(MidiSong *song);
extern void free_instruments(MidiSong *song);
extern int set_default_instrument(MidiSong *song, const char *name);
+
+#endif /* TIMIDITY_INSTRUM_H */
diff --git a/src/codecs/timidity/mix.c b/src/codecs/timidity/mix.c
index a0759c7..fa8ce5e 100644
--- a/src/codecs/timidity/mix.c
+++ b/src/codecs/timidity/mix.c
@@ -12,6 +12,7 @@
#include "timidity.h"
#include "options.h"
+#include "common.h"
#include "instrum.h"
#include "playmidi.h"
#include "output.h"
@@ -76,12 +77,12 @@ void apply_envelope_to_amp(MidiSong *song, int v)
ramp *= (float)vol_table[song->voice[v].envelope_volume>>23];
}
- la = (Sint32)FSCALE(lamp,AMP_BITS);
+ la = (Sint32)TIM_FSCALE(lamp,AMP_BITS);
if (la>MAX_AMP_VALUE)
la=MAX_AMP_VALUE;
- ra = (Sint32)FSCALE(ramp,AMP_BITS);
+ ra = (Sint32)TIM_FSCALE(ramp,AMP_BITS);
if (ra>MAX_AMP_VALUE)
ra=MAX_AMP_VALUE;
@@ -95,7 +96,7 @@ void apply_envelope_to_amp(MidiSong *song, int v)
if (song->voice[v].sample->modes & MODES_ENVELOPE)
lamp *= (float)vol_table[song->voice[v].envelope_volume>>23];
- la = (Sint32)FSCALE(lamp,AMP_BITS);
+ la = (Sint32)TIM_FSCALE(lamp,AMP_BITS);
if (la>MAX_AMP_VALUE)
la=MAX_AMP_VALUE;
@@ -145,9 +146,9 @@ static void update_tremolo(MidiSong *song, int v)
song->voice[v].tremolo_phase -= SINE_CYCLE_LENGTH<<RATE_SHIFT; */
song->voice[v].tremolo_volume = (float)
- (1.0 - FSCALENEG((sine(song->voice[v].tremolo_phase >> RATE_SHIFT) + 1.0)
- * depth * TREMOLO_AMPLITUDE_TUNING,
- 17));
+ (1.0 - TIM_FSCALENEG((timi_sine(song->voice[v].tremolo_phase >> RATE_SHIFT) + 1.0)
+ * depth * TREMOLO_AMPLITUDE_TUNING,
+ 17));
/* I'm not sure about the +1.0 there -- it makes tremoloed voices'
volumes on average the lower the higher the tremolo amplitude. */
diff --git a/src/codecs/timidity/mix.h b/src/codecs/timidity/mix.h
index f729146..fef2f27 100644
--- a/src/codecs/timidity/mix.h
+++ b/src/codecs/timidity/mix.h
@@ -8,6 +8,15 @@
mix.h
*/
+#ifndef TIMIDITY_MIX_H
+#define TIMIDITY_MIX_H
+
+#define mix_voice TIMI_NAMESPACE(mix_voice)
+#define recompute_envelope TIMI_NAMESPACE(recompute_envelope)
+#define apply_envelope_to_amp TIMI_NAMESPACE(apply_envelope_to_amp)
+
extern void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c);
extern int recompute_envelope(MidiSong *song, int v);
extern void apply_envelope_to_amp(MidiSong *song, int v);
+
+#endif /* TIMIDITY_MIX_H */
diff --git a/src/codecs/timidity/options.h b/src/codecs/timidity/options.h
index bf90771..025dfd9 100644
--- a/src/codecs/timidity/options.h
+++ b/src/codecs/timidity/options.h
@@ -6,6 +6,9 @@
it under the terms of the Perl Artistic License, available in COPYING.
*/
+#ifndef TIMIDITY_OPTIONS_H
+#define TIMIDITY_OPTIONS_H
+
/* When a patch file can't be opened, one of these extensions is
appended to the filename and the open is tried again.
*/
@@ -34,10 +37,13 @@
#define CONTROLS_PER_SECOND 1000
/* Make envelopes twice as fast. Saves ~20% CPU time (notes decay
- faster) and sounds more like a GUS. There is now a command line
- option to toggle this as well. */
+ faster) and sounds more like a GUS. */
#define FAST_DECAY
+/* A somewhat arbitrary output frequency range. */
+#define MIN_OUTPUT_RATE 4000
+#define MAX_OUTPUT_RATE 256000
+
/* How many bits to use for the fractional part of sample positions.
This affects tonal accuracy. The entire position counter must fit
in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of
@@ -61,6 +67,7 @@
/**************************************************************************/
/* change FRACTION_BITS above, not these */
+#define INTEGER_BITS (32 - FRACTION_BITS)
#define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS)
#define FRACTION_MASK (~ INTEGER_MASK)
@@ -80,8 +87,8 @@
#define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1)
-#define FSCALE(a,b) (float)((a) * (double)(1<<(b)))
-#define FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b))))
+#define TIM_FSCALE(a,b) (float)((a) * (double)(1<<(b)))
+#define TIM_FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b))))
/* Vibrato and tremolo Choices of the Day */
#define SWEEP_TUNING 38
@@ -94,8 +101,7 @@
#define RATE_SHIFT 5
#ifndef PI
- #define PI 3.14159265358979323846
+#define PI 3.14159265358979323846
#endif
-/* for very loud debug output: */
-#define SNDDBG(X)
+#endif /* TIMIDITY_OPTIONS_H */
diff --git a/src/codecs/timidity/output.c b/src/codecs/timidity/output.c
index cc9f9d2..47ea1d1 100644
--- a/src/codecs/timidity/output.c
+++ b/src/codecs/timidity/output.c
@@ -18,7 +18,7 @@
/*****************************************************************/
/* Some functions to convert signed 32-bit data to other formats */
-void s32tos8(void *dp, Sint32 *lp, Sint32 c)
+void timi_s32tos8(void *dp, Sint32 *lp, Sint32 c)
{
Sint8 *cp=(Sint8 *)(dp);
Sint32 l;
@@ -31,7 +31,7 @@ void s32tos8(void *dp, Sint32 *lp, Sint32 c)
}
}
-void s32tou8(void *dp, Sint32 *lp, Sint32 c)
+void timi_s32tou8(void *dp, Sint32 *lp, Sint32 c)
{
Uint8 *cp=(Uint8 *)(dp);
Sint32 l;
@@ -44,7 +44,7 @@ void s32tou8(void *dp, Sint32 *lp, Sint32 c)
}
}
-void s32tos16(void *dp, Sint32 *lp, Sint32 c)
+void timi_s32tos16(void *dp, Sint32 *lp, Sint32 c)
{
Sint16 *sp=(Sint16 *)(dp);
Sint32 l;
@@ -57,7 +57,7 @@ void s32tos16(void *dp, Sint32 *lp, Sint32 c)
}
}
-void s32tou16(void *dp, Sint32 *lp, Sint32 c)
+void timi_s32tou16(void *dp, Sint32 *lp, Sint32 c)
{
Uint16 *sp=(Uint16 *)(dp);
Sint32 l;
@@ -70,7 +70,7 @@ void s32tou16(void *dp, Sint32 *lp, Sint32 c)
}
}
-void s32tos16x(void *dp, Sint32 *lp, Sint32 c)
+void timi_s32tos16x(void *dp, Sint32 *lp, Sint32 c)
{
Sint16 *sp=(Sint16 *)(dp);
Sint32 l;
@@ -83,7 +83,7 @@ void s32tos16x(void *dp, Sint32 *lp, Sint32 c)
}
}
-void s32tou16x(void *dp, Sint32 *lp, Sint32 c)
+void timi_s32tou16x(void *dp, Sint32 *lp, Sint32 c)
{
Uint16 *sp=(Uint16 *)(dp);
Sint32 l;
@@ -96,7 +96,7 @@ void s32tou16x(void *dp, Sint32 *lp, Sint32 c)
}
}
-void s32tof32(void *dp, Sint32 *lp, Sint32 c)
+void timi_s32tof32(void *dp, Sint32 *lp, Sint32 c)
{
float *sp=(float *)(dp);
while (c--)
@@ -105,7 +105,7 @@ void s32tof32(void *dp, Sint32 *lp, Sint32 c)
}
}
-void s32tos32(void *dp, Sint32 *lp, Sint32 c)
+void timi_s32tos32(void *dp, Sint32 *lp, Sint32 c)
{
Sint32 *sp=(Sint32 *)(dp);
while (c--)
@@ -114,7 +114,7 @@ void s32tos32(void *dp, Sint32 *lp, Sint32 c)
}
}
-void s32tos32x(void *dp, Sint32 *lp, Sint32 c)
+void timi_s32tos32x(void *dp, Sint32 *lp, Sint32 c)
{
Sint32 *sp=(Sint32 *)(dp);
while (c--)
diff --git a/src/codecs/timidity/output.h b/src/codecs/timidity/output.h
index 8cfd122..3a08f5b 100644
--- a/src/codecs/timidity/output.h
+++ b/src/codecs/timidity/output.h
@@ -8,6 +8,9 @@
output.h
*/
+#ifndef TIMIDITY_OUTPUT_H
+#define TIMIDITY_OUTPUT_H
+
/* Data format encoding bits */
#define PE_MONO 0x01 /* versus stereo */
@@ -19,37 +22,39 @@
data in another format */
/* 8-bit signed and unsigned*/
-extern void s32tos8(void *dp, Sint32 *lp, Sint32 c);
-extern void s32tou8(void *dp, Sint32 *lp, Sint32 c);
+extern void timi_s32tos8(void *dp, Sint32 *lp, Sint32 c);
+extern void timi_s32tou8(void *dp, Sint32 *lp, Sint32 c);
/* 16-bit */
-extern void s32tos16(void *dp, Sint32 *lp, Sint32 c);
-extern void s32tou16(void *dp, Sint32 *lp, Sint32 c);
+extern void timi_s32tos16(void *dp, Sint32 *lp, Sint32 c);
+extern void timi_s32tou16(void *dp, Sint32 *lp, Sint32 c);
/* byte-exchanged 16-bit */
-extern void s32tos16x(void *dp, Sint32 *lp, Sint32 c);
-extern void s32tou16x(void *dp, Sint32 *lp, Sint32 c);
+extern void timi_s32tos16x(void *dp, Sint32 *lp, Sint32 c);
+extern void timi_s32tou16x(void *dp, Sint32 *lp, Sint32 c);
/* 32-bit */
-extern void s32tof32(void *dp, Sint32 *lp, Sint32 c);
-extern void s32tos32(void *dp, Sint32 *lp, Sint32 c);
+extern void timi_s32tof32(void *dp, Sint32 *lp, Sint32 c);
+extern void timi_s32tos32(void *dp, Sint32 *lp, Sint32 c);
/* byte-exchanged 32-bit */
-extern void s32tos32x(void *dp, Sint32 *lp, Sint32 c);
+extern void timi_s32tos32x(void *dp, Sint32 *lp, Sint32 c);
/* little-endian and big-endian specific */
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
-#define s32tos16l s32tos16
-#define s32tos16b s32tos16x
-#define s32tou16l s32tou16
-#define s32tou16b s32tou16x
-#define s32tos32l s32tos32
-#define s32tos32b s32tos32x
+#define timi_s32tou16l timi_s32tou16
+#define timi_s32tou16b timi_s32tou16x
+#define timi_s32tos16l timi_s32tos16
+#define timi_s32tos16b timi_s32tos16x
+#define timi_s32tos32l timi_s32tos32
+#define timi_s32tos32b timi_s32tos32x
#else
-#define s32tos16l s32tos16x
-#define s32tos16b s32tos16
-#define s32tou16l s32tou16x
-#define s32tou16b s32tou16
-#define s32tos32l s32tos32x
-#define s32tos32b s32tos32
+#define timi_s32tou16l timi_s32tou16x
+#define timi_s32tou16b timi_s32tou16
+#define timi_s32tos16l timi_s32tos16x
+#define timi_s32tos16b timi_s32tos16
+#define timi_s32tos32l timi_s32tos32x
+#define timi_s32tos32b timi_s32tos32
#endif
+
+#endif /* TIMIDITY_OUTPUT_H */
diff --git a/src/codecs/timidity/playmidi.c b/src/codecs/timidity/playmidi.c
index f6cd32a..3f12ef4 100644
--- a/src/codecs/timidity/playmidi.c
+++ b/src/codecs/timidity/playmidi.c
@@ -14,6 +14,7 @@
#include "timidity.h"
#include "options.h"
+#include "common.h"
#include "instrum.h"
#include "playmidi.h"
#include "output.h"
@@ -147,11 +148,11 @@ static void recompute_freq(MidiSong *song, int v)
song->channel[song->voice[v].channel].pitchfactor);
}
- a = FSCALE(((double)(song->voice[v].sample->sample_rate) *
- (double)(song->voice[v].frequency)) /
- ((double)(song->voice[v].sample->root_freq) *
- (double)(song->rate)),
- FRACTION_BITS);
+ a = TIM_FSCALE(((double)(song->voice[v].sample->sample_rate) *
+ (double)(song->voice[v].frequency)) /
+ ((double)(song->voice[v].sample->root_freq) *
+ (double)(song->rate)),
+ FRACTION_BITS);
if (sign)
a = -a; /* need to preserve the loop direction */
@@ -176,32 +177,32 @@ static void recompute_amp(MidiSong *song, int v)
song->voice[v].panned=PANNED_CENTER;
song->voice[v].left_amp=
- FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
- 21);
+ TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
+ 21);
}
else if (song->voice[v].panning<5)
{
song->voice[v].panned = PANNED_LEFT;
song->voice[v].left_amp=
- FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
- 20);
+ TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
+ 20);
}
else if (song->voice[v].panning>123)
{
song->voice[v].panned = PANNED_RIGHT;
song->voice[v].left_amp= /* left_amp will be used */
- FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
- 20);
+ TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
+ 20);
}
else
{
song->voice[v].panned = PANNED_MYSTERY;
song->voice[v].left_amp=
- FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
- 27);
+ TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
+ 27);
song->voice[v].right_amp = song->voice[v].left_amp * (song->voice[v].panning);
song->voice[v].left_amp *= (float)(127 - song->voice[v].panning);
}
@@ -211,8 +212,8 @@ static void recompute_amp(MidiSong *song, int v)
song->voice[v].panned = PANNED_CENTER;
song->voice[v].left_amp=
- FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
- 21);
+ TIM_FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume,
+ 21);
}
}
diff --git a/src/codecs/timidity/playmidi.h b/src/codecs/timidity/playmidi.h
index 03b287a..8f8a489 100644
--- a/src/codecs/timidity/playmidi.h
+++ b/src/codecs/timidity/playmidi.h
@@ -1,14 +1,15 @@
/*
-
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.
- playmidi.h
+ playmidi.h
+*/
- */
+#ifndef TIMIDITY_PLAYMIDI_H
+#define TIMIDITY_PLAYMIDI_H
/* Midi events */
#define ME_NONE 0
@@ -51,3 +52,5 @@
/* Anything but PANNED_MYSTERY only uses the left volume */
#define ISDRUMCHANNEL(s, c) (((s)->drumchannels & (1<<(c))))
+
+#endif /* TIMIDITY_PLAYMIDI_H */
diff --git a/src/codecs/timidity/readmidi.c b/src/codecs/timidity/readmidi.c
index 03d6e12..c36223d 100644
--- a/src/codecs/timidity/readmidi.c
+++ b/src/codecs/timidity/readmidi.c
@@ -14,6 +14,7 @@
#include "common.h"
#include "instrum.h"
#include "playmidi.h"
+#include "readmidi.h"
/* Computes how many (fractional) samples one MIDI delta-time unit contains */
static void compute_sample_increment(MidiSong *song, Sint32 tempo,
diff --git a/src/codecs/timidity/readmidi.h b/src/codecs/timidity/readmidi.h
index 020b587..4b599a7 100644
--- a/src/codecs/timidity/readmidi.h
+++ b/src/codecs/timidity/readmidi.h
@@ -8,4 +8,11 @@
readmidi.h
*/
+#ifndef TIMIDITY_READMIDI_H
+#define TIMIDITY_READMIDI_H
+
+#define read_midi_file TIMI_NAMESPACE(read_midi_file)
+
extern MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp);
+
+#endif /* TIMIDITY_READMIDI_H */
diff --git a/src/codecs/timidity/resample.c b/src/codecs/timidity/resample.c
index 4372ca6..333903f 100644
--- a/src/codecs/timidity/resample.c
+++ b/src/codecs/timidity/resample.c
@@ -236,13 +236,13 @@ static Sint32 update_vibrato(MidiSong *song, Voice *vp, int sign)
}
}
- a = FSCALE(((double)(vp->sample->sample_rate) *
- (double)(vp->frequency)) /
- ((double)(vp->sample->root_freq) *
- (double)(song->rate)),
- FRACTION_BITS);
+ a = TIM_FSCALE(((double)(vp->sample->sample_rate) *
+ (double)(vp->frequency)) /
+ ((double)(vp->sample->root_freq) *
+ (double)(song->rate)),
+ FRACTION_BITS);
- pb=(int)((sine(vp->vibrato_phase *
+ pb=(int)((timi_sine(vp->vibrato_phase *
(SINE_CYCLE_LENGTH/(2*VIBRATO_SAMPLE_INCREMENTS)))
* (double)(depth) * VIBRATO_AMPLITUDE_TUNING));
@@ -571,7 +571,7 @@ void pre_resample(MidiSong *song, Sample *sp)
v3 = *(vptr + 1);
v4 = *(vptr + 2);
v5 = v2 - v3;
- xdiff = FSCALENEG(ofs & FRACTION_MASK, FRACTION_BITS);
+ xdiff = TIM_FSCALENEG(ofs & FRACTION_MASK, FRACTION_BITS);
v = (Sint32)(v2 + xdiff * (1.0/6.0) * (3 * (v3 - v5) - 2 * v1 - v4 +
xdiff * (3 * (v1 - v2 - v5) + xdiff * (3 * v5 + v4 - v1))));
*dest++ = (Sint16)((v > 32767) ? 32767 : ((v < -32768) ? -32768 : v));
diff --git a/src/codecs/timidity/resample.h b/src/codecs/timidity/resample.h
index 6c59e9e..ac38117 100644
--- a/src/codecs/timidity/resample.h
+++ b/src/codecs/timidity/resample.h
@@ -8,5 +8,13 @@
resample.h
*/
+#ifndef TIMIDITY_RESAMPLE_H
+#define TIMIDITY_RESAMPLE_H
+
+#define resample_voice TIMI_NAMESPACE(resample_voice)
+#define pre_resample TIMI_NAMESPACE(pre_resample)
+
extern sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr);
extern void pre_resample(MidiSong *song, Sample *sp);
+
+#endif /* TIMIDITY_RESAMPLE_H */
diff --git a/src/codecs/timidity/tables.c b/src/codecs/timidity/tables.c
index 2b479bb..a18eff7 100644
--- a/src/codecs/timidity/tables.c
+++ b/src/codecs/timidity/tables.c
@@ -8,6 +8,7 @@
#include "SDL.h"
+#include "common.h"
#include "tables.h"
const Sint32 freq_table[128]=
diff --git a/src/codecs/timidity/tables.h b/src/codecs/timidity/tables.h
index a8eec93..ac68539 100644
--- a/src/codecs/timidity/tables.h
+++ b/src/codecs/timidity/tables.h
@@ -8,13 +8,24 @@
tables.h
*/
+#ifndef TIMIDITY_TABLES_H
+#define TIMIDITY_TABLES_H
+
#if defined(HAVE_LIBC) && defined(__WATCOMC__) /* Watcom has issues... */
#define SDL_sin sin
#endif
-#define sine(x) (SDL_sin((2*PI/1024.0) * (x)))
+#define timi_sine(x) (SDL_sin((2*PI/1024.0) * (x)))
#define SINE_CYCLE_LENGTH 1024
+
+#define freq_table TIMI_NAMESPACE(freq_table)
+#define vol_table TIMI_NAMESPACE(vol_table)
+#define bend_fine TIMI_NAMESPACE(bend_fine)
+#define bend_coarse TIMI_NAMESPACE(bend_coarse)
+
extern const Sint32 freq_table[];
extern const double vol_table[];
extern const double bend_fine[];
extern const double bend_coarse[];
+
+#endif /* TIMIDITY_TABLES_H */
diff --git a/src/codecs/timidity/timidity.c b/src/codecs/timidity/timidity.c
index fe16e9c..0f43de4 100644
--- a/src/codecs/timidity/timidity.c
+++ b/src/codecs/timidity/timidity.c
@@ -73,7 +73,7 @@ static int read_config_file(const char *name, int rcf_count)
return -1;
}
- if (!(rw=open_file(name)))
+ if (!(rw=timi_openfile(name)))
return -1;
bank = NULL;
@@ -189,7 +189,7 @@ static int read_config_file(const char *name, int rcf_count)
goto fail;
}
for (i=1; i<words; i++) {
- if (add_to_pathlist(w[i], SDL_strlen(w[i])) < 0)
+ if (timi_add_pathlist(w[i], SDL_strlen(w[i])) < 0)
goto fail;
}
}
@@ -423,7 +423,7 @@ static int init_begin_config(const char *cf)
{
const char *p = get_last_dirsep(cf);
if (p != NULL)
- return add_to_pathlist(cf, p - cf + 1); /* including DIRSEP */
+ return timi_add_pathlist(cf, p - cf + 1); /* including DIRSEP */
return 0;
}
@@ -510,31 +510,31 @@ static void do_song_load(SDL_RWops *rw, SDL_AudioSpec *audio, MidiSong **out)
}
switch (audio->format) {
case AUDIO_S8:
- song->write = s32tos8;
+ song->write = timi_s32tos8;
break;
case AUDIO_U8:
- song->write = s32tou8;
+ song->write = timi_s32tou8;
break;
case AUDIO_S16LSB:
- song->write = s32tos16l;
+ song->write = timi_s32tos16l;
break;
case AUDIO_S16MSB:
- song->write = s32tos16b;
+ song->write = timi_s32tos16b;
break;
case AUDIO_U16LSB:
- song->write = s32tou16l;
+ song->write = timi_s32tou16l;
break;
case AUDIO_U16MSB:
- song->write = s32tou16b;
+ song->write = timi_s32tou16b;
break;
case AUDIO_S32LSB:
- song->write = s32tos32l;
+ song->write = timi_s32tos32l;
break;
case AUDIO_S32MSB:
- song->write = s32tos32b;
+ song->write = timi_s32tos32b;
break;
case AUDIO_F32SYS:
- song->write = s32tof32;
+ song->write = timi_s32tof32;
break;
default:
SDL_SetError("Unsupported audio format");
@@ -634,5 +634,5 @@ void Timidity_Exit(void)
}
}
- free_pathlist();
+ timi_free_pathlist();
}