decoder/mikmod: sample rate is configurable

The new option "sample_rate" sets the sample rate for libmikmod.
This commit is contained in:
Max Kellermann 2009-11-14 02:03:03 +01:00
parent edaf017908
commit 1648c7aa5b
3 changed files with 42 additions and 4 deletions

1
NEWS
View File

@ -20,6 +20,7 @@ ver 0.16 (20??/??/??)
- ffmpeg: convert metadata to generic format - ffmpeg: convert metadata to generic format
- sndfile: new decoder plugin based on libsndfile - sndfile: new decoder plugin based on libsndfile
- flac: load external cue sheet when no internal one - flac: load external cue sheet when no internal one
- mikmod: sample rate is configurable
- mpg123: new decoder plugin based on libmpg123 - mpg123: new decoder plugin based on libmpg123
- sidplay: support sub-tunes - sidplay: support sub-tunes
- sidplay: implemented songlength database - sidplay: implemented songlength database

View File

@ -590,7 +590,35 @@ cd mpd-version</programlisting>
<section> <section>
<title>Decoder plugins</title> <title>Decoder plugins</title>
<para></para> <section>
<title><varname>mikmod</varname></title>
<para>
Module player based on MikMod.
</para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>Setting</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<varname>sample_rate</varname>
</entry>
<entry>
Sets the sample rate generated by
<filename>libmikmod</filename>. Default is 44100.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</section>
</section> </section>
<section> <section>

View File

@ -100,11 +100,20 @@ static MDRIVER drv_mpd = {
VC_VoiceRealVolume VC_VoiceRealVolume
}; };
static unsigned mikmod_sample_rate;
static bool static bool
mikmod_decoder_init(G_GNUC_UNUSED const struct config_param *param) mikmod_decoder_init(const struct config_param *param)
{ {
unsigned sample_rate;
static char params[] = ""; static char params[] = "";
mikmod_sample_rate = config_get_block_unsigned(param, "sample_rate",
44100);
if (!audio_valid_sample_rate(mikmod_sample_rate))
g_error("Invalid sample rate in line %d: %u",
param->line, sample_rate);
md_device = 0; md_device = 0;
md_reverb = 0; md_reverb = 0;
@ -112,7 +121,7 @@ mikmod_decoder_init(G_GNUC_UNUSED const struct config_param *param)
MikMod_RegisterAllLoaders(); MikMod_RegisterAllLoaders();
md_pansep = 64; md_pansep = 64;
md_mixfreq = 44100; md_mixfreq = mikmod_sample_rate;
md_mode = (DMODE_SOFT_MUSIC | DMODE_INTERP | DMODE_STEREO | md_mode = (DMODE_SOFT_MUSIC | DMODE_INTERP | DMODE_STEREO |
DMODE_16BITS); DMODE_16BITS);
@ -155,7 +164,7 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
/* Prevent module from looping forever */ /* Prevent module from looping forever */
handle->loop = 0; handle->loop = 0;
audio_format_init(&audio_format, 44100, 16, 2); audio_format_init(&audio_format, mikmod_sample_rate, 16, 2);
assert(audio_format_valid(&audio_format)); assert(audio_format_valid(&audio_format));
secPerByte = secPerByte =