From f9baeda4fe70dec9dd9a3155a44fc5444a2869ea Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Sat, 25 Aug 2012 19:00:52 -0300 Subject: [PATCH] Change interpolation setting API Change interpolation setting API so that different interpolation algorithms can be selected. Signed-off-by: Claudio Matsuoka --- src/common.h | 1 + src/main.c | 15 ++++++++++----- src/options.c | 13 ++++++++----- src/sound_ahi.c | 4 ++-- src/sound_aix.c | 4 ++-- src/sound_alsa.c | 12 ++++++------ src/sound_alsa05.c | 6 +++--- src/sound_beos.c | 4 ++-- src/sound_bsd.c | 8 ++++---- src/sound_coreaudio.c | 8 ++++---- src/sound_dart.c | 4 ++-- src/sound_hpux.c | 8 ++++---- src/sound_netbsd.c | 8 ++++---- src/sound_oss.c | 14 +++++++------- src/sound_pulseaudio.c | 4 ++-- src/sound_qnx.c | 4 ++-- src/sound_sgi.c | 12 ++++++------ src/sound_sndio.c | 8 ++++---- src/sound_solaris.c | 4 ++-- src/sound_wav.c | 8 ++++---- src/sound_win32.c | 4 ++-- 21 files changed, 81 insertions(+), 72 deletions(-) diff --git a/src/common.h b/src/common.h index 3d8558f..25e177d 100644 --- a/src/common.h +++ b/src/common.h @@ -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; diff --git a/src/main.c b/src/main.c index f48446e..280ae6d 100644 --- a/src/main.c +++ b/src/main.c @@ -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 */ diff --git a/src/options.c b/src/options.c index 1de13d5..4ac2015 100644 --- a/src/options.c +++ b/src/options.c @@ -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); diff --git a/src/sound_ahi.c b/src/sound_ahi.c index a66a9d3..e08a87c 100644 --- a/src/sound_ahi.c +++ b/src/sound_ahi.c @@ -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); diff --git a/src/sound_aix.c b/src/sound_aix.c index a7b3081..97e5994 100644 --- a/src/sound_aix.c +++ b/src/sound_aix.c @@ -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) { diff --git a/src/sound_alsa.c b/src/sound_alsa.c index 7624d52..a7f395a 100644 --- a/src/sound_alsa.c +++ b/src/sound_alsa.c @@ -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; diff --git a/src/sound_alsa05.c b/src/sound_alsa05.c index bfc2887..e683c2f 100644 --- a/src/sound_alsa05.c +++ b/src/sound_alsa05.c @@ -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, ¶ms)) < 0) { printf("Unable to set output parameters: %s\n", diff --git a/src/sound_beos.c b/src/sound_beos.c index b40229f..5295b5d 100644 --- a/src/sound_beos.c +++ b/src/sound_beos.c @@ -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; diff --git a/src/sound_bsd.c b/src/sound_bsd.c index 0ae376c..4d6dc84 100644 --- a/src/sound_bsd.c +++ b/src/sound_bsd.c @@ -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) { diff --git a/src/sound_coreaudio.c b/src/sound_coreaudio.c index 51f1c93..ac70cc3 100644 --- a/src/sound_coreaudio.c +++ b/src/sound_coreaudio.c @@ -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; diff --git a/src/sound_dart.c b/src/sound_dart.c index d2b1a1c..b3ca70c 100644 --- a/src/sound_dart.c +++ b/src/sound_dart.c @@ -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; diff --git a/src/sound_hpux.c b/src/sound_hpux.c index f3625d1..2eceb9a 100644 --- a/src/sound_hpux.c +++ b/src/sound_hpux.c @@ -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; diff --git a/src/sound_netbsd.c b/src/sound_netbsd.c index 1ee7eba..a764f9c 100644 --- a/src/sound_netbsd.c +++ b/src/sound_netbsd.c @@ -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; diff --git a/src/sound_oss.c b/src/sound_oss.c index 1aaf40c..de3bef8 100644 --- a/src/sound_oss.c +++ b/src/sound_oss.c @@ -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); diff --git a/src/sound_pulseaudio.c b/src/sound_pulseaudio.c index 018fa58..9f6f6f1 100644 --- a/src/sound_pulseaudio.c +++ b/src/sound_pulseaudio.c @@ -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 */ diff --git a/src/sound_qnx.c b/src/sound_qnx.c index 58149b7..be5f1e7 100644 --- a/src/sound_qnx.c +++ b/src/sound_qnx.c @@ -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) { diff --git a/src/sound_sgi.c b/src/sound_sgi.c index 1feb54c..c991d70 100644 --- a/src/sound_sgi.c +++ b/src/sound_sgi.c @@ -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; } } diff --git a/src/sound_sndio.c b/src/sound_sndio.c index 4d6ea27..74c9535 100644 --- a/src/sound_sndio.c +++ b/src/sound_sndio.c @@ -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; } diff --git a/src/sound_solaris.c b/src/sound_solaris.c index 26ba401..b6f91fa 100644 --- a/src/sound_solaris.c +++ b/src/sound_solaris.c @@ -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; diff --git a/src/sound_wav.c b/src/sound_wav.c index 0f73258..7c89a44 100644 --- a/src/sound_wav.c +++ b/src/sound_wav.c @@ -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; } diff --git a/src/sound_win32.c b/src/sound_win32.c index aea6a04..807581a 100644 --- a/src/sound_win32.c +++ b/src/sound_win32.c @@ -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;