Change interpolation setting API

Change interpolation setting API so that different interpolation algorithms
can be selected.

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 14 years ago
parent 1d36dab7da
commit f9baeda4fe
  1. 1
      src/common.h
  2. 15
      src/main.c
  3. 13
      src/options.c
  4. 4
      src/sound_ahi.c
  5. 4
      src/sound_aix.c
  6. 12
      src/sound_alsa.c
  7. 6
      src/sound_alsa05.c
  8. 4
      src/sound_beos.c
  9. 8
      src/sound_bsd.c
  10. 8
      src/sound_coreaudio.c
  11. 4
      src/sound_dart.c
  12. 8
      src/sound_hpux.c
  13. 8
      src/sound_netbsd.c
  14. 14
      src/sound_oss.c
  15. 4
      src/sound_pulseaudio.c
  16. 4
      src/sound_qnx.c
  17. 12
      src/sound_sgi.c
  18. 8
      src/sound_sndio.c
  19. 4
      src/sound_solaris.c
  20. 8
      src/sound_wav.c
  21. 4
      src/sound_win32.c

@ -10,6 +10,7 @@ struct options {
int format; /* sample format */
int max_time; /* max. replay time */
int mix; /* channel separation */
int interp; /* interpolation type */
int loop; /* loop module */
int random; /* play in random order */
int verbose;

@ -167,10 +167,13 @@ int main(int argc, char **argv)
memset(&options, 0, sizeof (struct options));
memset(&control, 0, sizeof (struct control));
/* set defaults */
options.verbose = 1;
options.rate = 44100;
options.mix = -1;
options.driver_id = NULL;
options.interp = XMP_INTERP_LINEAR;
get_options(argc, argv, &options);
@ -202,10 +205,10 @@ int main(int argc, char **argv)
report("Using %s\n", sound->description);
report("Mixer set to %d Hz, %dbit, %s%s%s\n", options.rate,
options.format & XMP_MIX_8BIT ? 8 : 16,
options.format & XMP_MIX_NEAREST ? "" : "interpolated ",
options.format & XMP_MIX_MONO ? "mono" : "stereo",
options.format & XMP_MIX_NOFILTER ? " (no filter)" : "");
options.format & XMP_FORMAT_8BIT ? 8 : 16,
/*options.format & XMP_FORMAT_NEAREST ? "" : "interpolated ",*/"FIXME",
options.format & XMP_FORMAT_MONO ? "mono" : "stereo",
/*options.format & XMP_FORMAT_NOFILTER ? " (no filter)" :*/ "");
}
if (options.probeonly) {
@ -247,7 +250,7 @@ int main(int argc, char **argv)
}
if (options.mix >= 0) {
xmp_mixer_mix(handle, options.mix);
xmp_mixer_set(handle, XMP_MIXER_MIX, options.mix);
}
lf_flag = 0;
@ -297,6 +300,8 @@ int main(int argc, char **argv)
control.loop = options.loop;
if (xmp_player_start(handle, options.rate, options.format) == 0) {
xmp_mixer_set(handle, XMP_MIXER_INTERP, options.interp);
xmp_set_position(handle, options.start);
/* Mute channels */

@ -143,7 +143,7 @@ void get_options(int argc, char **argv, struct options *options)
break;
case 'b':
if (atoi(optarg) == 8) {
options->format |= XMP_MIX_8BIT;
options->format |= XMP_FORMAT_8BIT;
}
break;
case 'c':
@ -157,8 +157,11 @@ void get_options(int argc, char **argv, struct options *options)
options->driver_id = optarg;
break;
case 'F':
options->format |= XMP_MIX_NOFILTER;
/* FIXME */
#if 0
options->format |= XMP_FORMAT_NOFILTER;
break;
#endif
case 'f':
options->rate = strtoul(optarg, NULL, 0);
break;
@ -182,13 +185,13 @@ void get_options(int argc, char **argv, struct options *options)
options->loop = 1;
break;
case 'm':
options->format |= XMP_MIX_MONO;
options->format |= XMP_FORMAT_MONO;
break;
case 'N':
options->silent = 1;
break;
case 'n':
options->format |= XMP_MIX_NEAREST;
options->interp = XMP_INTERP_NEAREST;
break;
case OPT_NOCMD:
options->nocmd = 1;
@ -252,7 +255,7 @@ void get_options(int argc, char **argv, struct options *options)
options->max_time = strtoul(optarg, NULL, 0) * 1000;
break;
case 'u':
options->format |= XMP_MIX_UNSIGNED;
options->format |= XMP_FORMAT_UNSIGNED;
break;
case 'V':
puts("Extended Module Player " VERSION);

@ -16,8 +16,8 @@ static int init(struct options *options)
{
char **parm = options->driver_parm;
char outfile[256];
int nch = options->format & XMP_MIX_MONO ? 1 : 2;
int res = options->format & XMP_MIX_8BIT ? 8 : 16;
int nch = options->format & XMP_FORMAT_MONO ? 1 : 2;
int res = options->format & XMP_FORMAT_8BIT ? 8 : 16;
int bsize = options->rate * nch * res / 4;
parm_init(parm);

@ -45,8 +45,8 @@ static int init(struct options *options)
init.mode = PCM; /* audio format */
init.srate = options->rate; /* sample rate */
init.operation = PLAY; /* PLAY or RECORD */
init.channels = options->format & XMP_MIX_MONO ? 1 : 2;
init.bits_per_sample = options->format & XMP_MIX_8BIT ? 8 : 16;
init.channels = options->format & XMP_FORMAT_MONO ? 1 : 2;
init.bits_per_sample = options->format & XMP_FORMAT_8BIT ? 8 : 16;
init.flags = BIG_ENDIAN | TWOS_COMPLEMENT;
if (ioctl(audio_fd, AUDIO_INIT, &init) < 0) {

@ -29,12 +29,12 @@ static int init(struct options *options)
return -1;
}
channels = format & XMP_MIX_MONO ? 1 : 2;
if (format & XMP_MIX_UNSIGNED) {
fmt = format & XMP_MIX_8BIT ?
channels = format & XMP_FORMAT_MONO ? 1 : 2;
if (format & XMP_FORMAT_UNSIGNED) {
fmt = format & XMP_FORMAT_8BIT ?
SND_PCM_FORMAT_U8 : SND_PCM_FORMAT_U16;
} else {
fmt = format & XMP_MIX_8BIT ?
fmt = format & XMP_FORMAT_8BIT ?
SND_PCM_FORMAT_S8 : SND_PCM_FORMAT_S16;
}
@ -62,9 +62,9 @@ static int init(struct options *options)
}
if (channels == 1) {
format |= XMP_MIX_MONO;
format |= XMP_FORMAT_MONO;
} else {
format &= ~XMP_MIX_MONO;
format &= ~XMP_FORMAT_MONO;
}
options->rate = rate;

@ -54,7 +54,7 @@ static int to_fmt(struct options *options)
{
int fmt;
if (options->format & XMP_MIX_8BIT) {
if (options->format & XMP_FORMAT_8BIT) {
fmt = SND_PCM_SFMT_U8 | SND_PCM_SFMT_S8;
} else {
fmt = SND_PCM_SFMT_S16_LE | SND_PCM_SFMT_S16_BE |
@ -67,7 +67,7 @@ static int to_fmt(struct options *options)
}
}
if (options->format & XMP_MIX_UNSIGNED) {
if (options->format & XMP_FORMAT_UNSIGNED) {
fmt &= SND_PCM_SFMT_U8|SND_PCM_SFMT_U16_LE|SND_PCM_SFMT_U16_BE;
} else {
fmt &= SND_PCM_SFMT_S8|SND_PCM_SFMT_S16_LE|SND_PCM_SFMT_S16_BE;
@ -134,7 +134,7 @@ static int init(struct options *options)
params.format.interleave = 1;
params.format.format = to_fmt(o);
params.format.rate = options->rate;
params.format.voices = (o->outfmt & XMP_MIX_MONO) ? 1 : 2;
params.format.voices = (o->outfmt & XMP_FORMAT_MONO) ? 1 : 2;
if ((rc = snd_pcm_plugin_params(pcm_handle, &params)) < 0) {
printf("Unable to set output parameters: %s\n",

@ -156,8 +156,8 @@ static int init(struct options *options)
sound_beos.description = desc;
fmt.frame_rate = options->rate;
fmt.channel_count = options->format & XMP_MIX_MONO ? 1 : 2;
fmt.format = options->format & XMP_MIX_8BIT ?
fmt.channel_count = options->format & XMP_FORMAT_MONO ? 1 : 2;
fmt.format = options->format & XMP_FORMAT_8BIT ?
B_AUDIO_CHAR : B_AUDIO_SHORT;
fmt.byte_order = B_HOST_IS_LENDIAN ?
B_MEDIA_LITTLE_ENDIAN : B_MEDIA_BIG_ENDIAN;

@ -34,18 +34,18 @@ static int init(struct options *options)
AUDIO_INITINFO(&ainfo);
ainfo.play.sample_rate = options->rate;
ainfo.play.channels = options->format & XMP_MIX_MONO ? 1 : 2;
ainfo.play.channels = options->format & XMP_FORMAT_MONO ? 1 : 2;
ainfo.play.gain = gain;
ainfo.play.buffer_size = bsize;
if (options->format & XMP_MIX_8BIT) {
if (options->format & XMP_FORMAT_8BIT) {
ainfo.play.precision = 8;
ainfo.play.encoding = AUDIO_ENCODING_ULINEAR;
options->format |= XMP_MIX_UNSIGNED;
options->format |= XMP_FORMAT_UNSIGNED;
} else {
ainfo.play.precision = 16;
ainfo.play.encoding = AUDIO_ENCODING_SLINEAR;
options->format &= ~XMP_MIX_UNSIGNED;
options->format &= ~XMP_FORMAT_UNSIGNED;
}
if (ioctl(audio_fd, AUDIO_SETINFO, &ainfo) == -1) {

@ -128,14 +128,14 @@ static int init(struct options *options)
ad.mFormatFlags = kAudioFormatFlagIsPacked /* |
kAudioFormatFlagNativeEndian */;
if (~options->format & XMP_MIX_UNSIGNED) {
if (~options->format & XMP_FORMAT_UNSIGNED) {
ad.mFormatFlags |= kAudioFormatFlagIsSignedInteger;
}
ad.mChannelsPerFrame = options->format & XMP_MIX_MONO ? 1 : 2;
ad.mBitsPerChannel = options->format & XMP_MIX_8BIT ? 8 : 16;
ad.mChannelsPerFrame = options->format & XMP_FORMAT_MONO ? 1 : 2;
ad.mBitsPerChannel = options->format & XMP_FORMAT_8BIT ? 8 : 16;
if (options->format & XMP_MIX_8BIT) {
if (options->format & XMP_FORMAT_8BIT) {
ad.mBytesPerFrame = ad.mChannelsPerFrame;
} else {
ad.mBytesPerFrame = 2 * ad.mChannelsPerFrame;

@ -110,10 +110,10 @@ static int init(struct options *options)
memset(&MixSetupParms, 0, sizeof(MCI_MIXSETUP_PARMS));
MixSetupParms.ulBitsPerSample =
options->format & XMP_MIX_8BIT ? 8 : 16;
options->format & XMP_FORMAT_8BIT ? 8 : 16;
MixSetupParms.ulFormatTag = MCI_WAVE_FORMAT_PCM;
MixSetupParms.ulSamplesPerSec = options->rate;
MixSetupParms.ulChannels = options->format & XMP_MIX_MONO ? 1 : 2;
MixSetupParms.ulChannels = options->format & XMP_FORMAT_MONO ? 1 : 2;
MixSetupParms.ulFormatMode = MCI_PLAY;
MixSetupParms.ulDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO;
MixSetupParms.pmixEvent = OS2_Dart_UpdateBuffers;

@ -23,7 +23,7 @@ static int init(struct options *options)
int gain = 128;
int bsize = 32 * 1024;
int port = AUDIO_OUT_SPEAKER;
int nch = options->format & XMP_MIX_MONO ? 1 : 2;
int nch = options->format & XMP_FORMAT_MONO ? 1 : 2;
struct audio_gains agains;
struct audio_describe adescribe;
int i;
@ -55,13 +55,13 @@ static int init(struct options *options)
if ((flags = fcntl(audio_fd, F_SETFL, flags)) < 0)
goto err1;
options->format &= ~XMP_MIX_8BIT;
options->format &= ~XMP_FORMAT_8BIT;
if (ioctl(audio_fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_LINEAR16BIT) == -1)
goto err1;
if (ioctl(audio_fd, AUDIO_SET_CHANNELS, nch) == -1) {
options->format ^= XMP_MIX_MONO;
nch = options->format & XMP_MIX_MONO ? 1 : 2;
options->format ^= XMP_FORMAT_MONO;
nch = options->format & XMP_FORMAT_MONO ? 1 : 2;
if (ioctl(audio_fd, AUDIO_SET_CHANNELS, nch) == -1) {
goto err1;

@ -61,16 +61,16 @@ static int init(struct options *options)
AUDIO_INITINFO(&ainfo);
ainfo.play.sample_rate = options->rate;
ainfo.play.channels = options->format & XMP_MIX_MONO ? 1 : 2;
ainfo.play.channels = options->format & XMP_FORMAT_MONO ? 1 : 2;
if (options->format & XMP_MIX_8BIT) {
if (options->format & XMP_FORMAT_8BIT) {
ainfo.play.precision = 8;
ainfo.play.precision = AUDIO_ENCODING_ULINEAR;
options->format |= XMP_MIX_UNSIGNED;
options->format |= XMP_FORMAT_UNSIGNED;
} else {
ainfo.play.precision = 16;
ainfo.play.precision = AUDIO_ENCODING_SLINEAR;
options->format &= ~XMP_MIX_UNSIGNED;
options->format &= ~XMP_FORMAT_UNSIGNED;
}
ainfo.play.gain = gain;

@ -39,13 +39,13 @@ static int to_fmt(int format)
{
int fmt;
if (format & XMP_MIX_8BIT)
if (format & XMP_FORMAT_8BIT)
fmt = AFMT_U8 | AFMT_S8;
else {
fmt = AFMT_S16_NE | AFMT_U16_NE;
}
if (format & XMP_MIX_UNSIGNED)
if (format & XMP_FORMAT_UNSIGNED)
fmt &= AFMT_U8 | AFMT_U16_LE | AFMT_U16_BE;
else
fmt &= AFMT_S8 | AFMT_S16_LE | AFMT_S16_BE;
@ -58,11 +58,11 @@ static int from_fmt(int fmt)
int format = 0;
if (!(fmt & (AFMT_S16_LE | AFMT_S16_BE | AFMT_U16_LE | AFMT_U16_BE))) {
format |= XMP_MIX_8BIT;
format |= XMP_FORMAT_8BIT;
}
if (fmt & (AFMT_U8 | AFMT_U16_LE | AFMT_U16_BE)) {
format |= XMP_MIX_UNSIGNED;
format |= XMP_FORMAT_UNSIGNED;
}
return format;
@ -80,12 +80,12 @@ static void setaudio(int *rate, int *format)
ioctl(audio_fd, SNDCTL_DSP_SETFMT, &fmt);
*format = from_fmt(fmt);
fmt = !(*format & XMP_MIX_MONO);
fmt = !(*format & XMP_FORMAT_MONO);
ioctl(audio_fd, SNDCTL_DSP_STEREO, &fmt);
if (fmt) {
*format &= ~XMP_MIX_MONO;
*format &= ~XMP_FORMAT_MONO;
} else {
*format |= XMP_MIX_MONO;
*format |= XMP_FORMAT_MONO;
}
ioctl(audio_fd, SNDCTL_DSP_SPEED, rate);

@ -11,10 +11,10 @@ static int init(struct options *options)
pa_sample_spec ss;
int error;
options->format &= ~(XMP_MIX_UNSIGNED | XMP_MIX_8BIT);
options->format &= ~(XMP_FORMAT_UNSIGNED | XMP_FORMAT_8BIT);
ss.format = PA_SAMPLE_S16NE;
ss.channels = options->format & XMP_MIX_MONO ? 1 : 2;
ss.channels = options->format & XMP_FORMAT_MONO ? 1 : 2;
ss.rate = options->rate;
s = pa_simple_new(NULL, /* Use the default server */

@ -20,7 +20,7 @@ static int init(struct options *options)
parm_end();
rate = options->rate;
bits = options->format & XMP_MIX_8BIT ? 8 : 16;
bits = options->format & XMP_FORMAT_8BIT ? 8 : 16;
stereo = 1;
bufsize = 32 * 1024;
@ -30,7 +30,7 @@ static int init(struct options *options)
return -1;
}
if (options->outfmt & XMP_MIX_MONO)
if (options->outfmt & XMP_FORMAT_MONO)
stereo = 0;
if (ioctl(fd_audio, SOUND_PCM_WRITE_BITS, &bits) < 0) {

@ -74,11 +74,11 @@ static int init(struct options *options)
* Set sample width; 24 bit samples are not currently supported by xmp
*/
if (options->format & XMP_MIX_8BIT) {
if (options->format & XMP_FORMAT_8BIT) {
if (ALsetwidth(config, AL_SAMPLE_8) < 0) {
if (ALsetwidth(config, AL_SAMPLE_16) < 0)
return -1;
options->format &= ~XMP_MIX_8BIT;
options->format &= ~XMP_FORMAT_8BIT;
} else {
al_sample_16 = 0;
}
@ -86,7 +86,7 @@ static int init(struct options *options)
if (ALsetwidth(config, AL_SAMPLE_16) < 0) {
if (ALsetwidth(config, AL_SAMPLE_8) < 0)
return -1;
options->format |= XMP_MIX_8BIT;
options->format |= XMP_FORMAT_8BIT;
} else {
al_sample_16 = 1;
}
@ -96,17 +96,17 @@ static int init(struct options *options)
* Set number of channels; 4 channel output is not currently supported
*/
if (options->format & XMP_MIX_MONO) {
if (options->format & XMP_FORMAT_MONO) {
if (ALsetchannels(config, AL_MONO) < 0) {
if (ALsetchannels(config, AL_STEREO) < 0)
return -1;
options->format &= ~XMP_MIX_MONO;
options->format &= ~XMP_FORMAT_MONO;
}
} else {
if (ALsetchannels(config, AL_STEREO) < 0) {
if (ALsetchannels(config, AL_MONO) < 0)
return -1;
options->format |= XMP_MIX_MONO;
options->format |= XMP_FORMAT_MONO;
}
}

@ -33,19 +33,19 @@ static int init(struct options *options)
}
sio_initpar(&par);
par.pchan = options->format & XMP_MIX_MONO ? 1 : 2;
par.pchan = options->format & XMP_FORMAT_MONO ? 1 : 2;
par.rate = options->rate;
par.le = SIO_LE_NATIVE;
par.appbufsz = par.rate / 4;
if (options->format & XMP_MIX_8BIT) {
if (options->format & XMP_FORMAT_8BIT) {
par.bits = 8;
par.sig = 0;
options->format |= XMP_MIX_UNSIGNED;
options->format |= XMP_FORMAT_UNSIGNED;
} else {
par.bits = 16;
par.sig = 1;
options->format &= ~XMP_MIX_UNSIGNED;
options->format &= ~XMP_FORMAT_UNSIGNED;
}

@ -108,8 +108,8 @@ static int init(struct options *options)
AUDIO_INITINFO(&ainfo2); /* For AMD 7930 if needed */
ainfo.play.sample_rate = options->rate;
ainfo.play.channels = options->format & XMP_MIX_MONO ? 1 : 2;
ainfo.play.precision = options->format & XMP_MIX_8BIT ? 8 : 16;
ainfo.play.channels = options->format & XMP_FORMAT_MONO ? 1 : 2;
ainfo.play.precision = options->format & XMP_FORMAT_8BIT ? 8 : 16;
ainfo.play.encoding = AUDIO_ENCODING_LINEAR;
ainfo2.play.gain = ainfo.play.gain = gain;
ainfo2.play.port = ainfo.play.port = port;

@ -85,15 +85,15 @@ static int init(struct options *options)
write_32l(fd, len);
write(fd, "WAVE", 4);
chan = options->format & XMP_MIX_MONO ? 1 : 2;
chan = options->format & XMP_FORMAT_MONO ? 1 : 2;
sampling_rate = options->rate;
bits_per_sample = options->format & XMP_MIX_8BIT ? 8 : 16;
bits_per_sample = options->format & XMP_FORMAT_8BIT ? 8 : 16;
if (bits_per_sample == 8) {
options->format |= XMP_MIX_UNSIGNED;
options->format |= XMP_FORMAT_UNSIGNED;
format_16bit = 0;
} else {
options->format &= ~XMP_MIX_UNSIGNED;
options->format &= ~XMP_FORMAT_UNSIGNED;
format_16bit = 1;
}

@ -78,8 +78,8 @@ static int init(struct options *options)
return -1;
wfe.wFormatTag = WAVE_FORMAT_PCM;
wfe.wBitsPerSample = options->format & XMP_MIX_8BIT ? 8 : 16;
wfe.nChannels = options->format & XMP_MIX_MONO ? 1 : 2;
wfe.wBitsPerSample = options->format & XMP_FORMAT_8BIT ? 8 : 16;
wfe.nChannels = options->format & XMP_FORMAT_MONO ? 1 : 2;
wfe.nSamplesPerSec = options->rate;
wfe.nAvgBytesPerSec = wfe.nSamplesPerSec * wfe.nChannels *
wfe.wBitsPerSample / 8;

Loading…
Cancel
Save