removed unused files, the mixer has it's own resampling code

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9815 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper 2004-11-06 22:07:09 +00:00
parent b5602a834c
commit aa09be21b3
7 changed files with 0 additions and 984 deletions

View File

@ -1,32 +0,0 @@
#ifndef _CHANNEL_MIXER_
#define _CHANNEL_MIXER_
/***********************************************************************
* AUTHOR: Marcus Overhagen
* FILE: ChannelMixer.h
* DESCR: Converts mono into stereo
* stereo into mono (this one isn't very good)
* (multiple channel support should be added in the future)
***********************************************************************/
namespace MediaKitPrivate {
class ChannelMixer
{
public:
static status_t
mix(void *dest, int dest_chan_count,
const void *source, int source_chan_count,
int framecount, uint32 format);
static status_t
mix_2_to_1(void *dest, const void *source, int framecount, uint32 format);
static status_t
mix_1_to_2(void *dest, const void *source, int framecount, uint32 format);
};
} //namespace MediaKitPrivate
#endif

View File

@ -1,53 +0,0 @@
#ifndef _SAMPLE_CONVERTER_
#define _SAMPLE_CONVERTER_
/***********************************************************************
* AUTHOR: Marcus Overhagen
* FILE: SampleConverter.h
* DESCR: Converts between different sample formats:
* media_raw_audio_format::B_AUDIO_FLOAT
* media_raw_audio_format::B_AUDIO_INT
* media_raw_audio_format::B_AUDIO_SHORT
* media_raw_audio_format::B_AUDIO_CHAR
* media_raw_audio_format::B_AUDIO_UCHAR
***********************************************************************/
namespace MediaKitPrivate {
class SampleConverter
{
public:
static status_t
convert(void *dest, uint32 dest_format,
const void *source, uint32 source_format,
int samplecount);
static void convert(uint8 *dest, const float *source, int samplecount);
static void convert(uint8 *dest, const int32 *source, int samplecount);
static void convert(uint8 *dest, const int16 *source, int samplecount);
static void convert(uint8 *dest, const int8 *source, int samplecount);
static void convert(int8 *dest, const float *source, int samplecount);
static void convert(int8 *dest, const int32 *source, int samplecount);
static void convert(int8 *dest, const int16 *source, int samplecount);
static void convert(int8 *dest, const uint8 *source, int samplecount);
static void convert(int16 *dest, const float *source, int samplecount);
static void convert(int16 *dest, const int32 *source, int samplecount);
static void convert(int16 *dest, const int8 *source, int samplecount);
static void convert(int16 *dest, const uint8 *source, int samplecount);
static void convert(int32 *dest, const float *source, int samplecount);
static void convert(int32 *dest, const int16 *source, int samplecount);
static void convert(int32 *dest, const int8 *source, int samplecount);
static void convert(int32 *dest, const uint8 *source, int samplecount);
static void convert(float *dest, const int32 *source, int samplecount);
static void convert(float *dest, const int16 *source, int samplecount);
static void convert(float *dest, const int8 *source, int samplecount);
static void convert(float *dest, const uint8 *source, int samplecount);
};
} //namespace MediaKitPrivate
#endif

View File

@ -1,29 +0,0 @@
#ifndef _SAMPLINGRATE_CONVERTER_
#define _SAMPLINGRATE_CONVERTER_
/***********************************************************************
* AUTHOR: Marcus Overhagen
* FILE: SamplingrateConverter.cpp
* DESCR: Converts between different sampling rates
* This is really bad code, as there are much better algorithms
* than the simple duplicating or dropping of samples.
* Also, the implementation isn't very nice.
* Feel free to send me better versions to marcus@overhagen.de
***********************************************************************/
namespace MediaKitPrivate {
class SamplingrateConverter
{
public:
static status_t
convert(void *dest, int destframecount,
const void *src, int srcframecount,
uint32 format,
int channel_count);
};
} //namespace MediaKitPrivate
#endif

View File

@ -1,186 +0,0 @@
/*
* Copyright (c) 2002, 2003 Marcus Overhagen <Marcus@Overhagen.de>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files or portions
* thereof (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject
* to the following conditions:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice
* in the binary, as well as this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with
* the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
/* Converts mono into stereo, stereo into mono
* (multiple channel support should be added in the future)
*/
#include <SupportDefs.h>
#include <MediaDefs.h>
#include <stdio.h>
#include "ChannelMixer.h"
namespace MediaKitPrivate {
status_t
ChannelMixer::mix(void *dest, int dest_chan_count,
const void *source, int source_chan_count,
int framecount, uint32 format)
{
if (dest_chan_count == 1 && source_chan_count == 2)
return mix_2_to_1(dest, source, framecount, format);
else if (dest_chan_count == 2 && source_chan_count == 1)
return mix_1_to_2(dest, source, framecount, format);
else {
fprintf(stderr,"ChannelMixer::mix() dest_chan_count = %d, source_chan_count = %d not supported\n",
dest_chan_count,
source_chan_count);
return B_ERROR;
}
}
status_t
ChannelMixer::mix_2_to_1(void *dest, const void *source, int framecount, uint32 format)
{
switch (format) {
case media_raw_audio_format::B_AUDIO_FLOAT:
{
register float *d = (float *)dest;
register float *s = (float *)source;
while (framecount--) {
*(d++) = (s[0] + s[1]) / 2.0f;
s += 2;
}
return B_OK;
}
case media_raw_audio_format::B_AUDIO_INT:
{
register int32 *d = (int32 *)dest;
register int32 *s = (int32 *)source;
while (framecount--) {
*(d++) = (s[0] >> 1) + (s[1] >> 1);
s += 2;
}
return B_OK;
}
case media_raw_audio_format::B_AUDIO_SHORT:
{
register int16 *d = (int16 *)dest;
register int16 *s = (int16 *)source;
while (framecount--) {
register int32 temp = s[0] + s[1];
*(d++) = int16(temp >> 1);
s += 2;
}
return B_OK;
}
case media_raw_audio_format::B_AUDIO_CHAR:
{
register int8 *d = (int8 *)dest;
register int8 *s = (int8 *)source;
while (framecount--) {
register int32 temp = s[0] + s[1];
*(d++) = int8(temp >> 1);
s += 2;
}
return B_OK;
}
case media_raw_audio_format::B_AUDIO_UCHAR:
{
register uint8 *d = (uint8 *)dest;
register uint8 *s = (uint8 *)source;
while (framecount--) {
register int32 temp = (int32(s[0]) - 128) + (int32(s[1]) - 128);
*(d++) = int8((temp >> 1) + 128);
s += 2;
}
return B_OK;
}
default:
{
fprintf(stderr,"ChannelMixer::mix_2_to_1() unsupported sample format %d\n",(int)format);
return B_ERROR;
}
}
}
status_t
ChannelMixer::mix_1_to_2(void *dest, const void *source, int framecount, uint32 format)
{
switch (format) {
case media_raw_audio_format::B_AUDIO_FLOAT:
{
register float *d = (float *)dest;
register float *s = (float *)source;
while (framecount--) {
*(d++) = *s;
*(d++) = *(s++);
}
return B_OK;
}
case media_raw_audio_format::B_AUDIO_INT:
{
register int32 *d = (int32 *)dest;
register int32 *s = (int32 *)source;
while (framecount--) {
*(d++) = *s;
*(d++) = *(s++);
}
return B_OK;
}
case media_raw_audio_format::B_AUDIO_SHORT:
{
register int16 *d = (int16 *)dest;
register int16 *s = (int16 *)source;
while (framecount--) {
*(d++) = *s;
*(d++) = *(s++);
}
return B_OK;
}
case media_raw_audio_format::B_AUDIO_CHAR:
{
register int8 *d = (int8 *)dest;
register int8 *s = (int8 *)source;
while (framecount--) {
*(d++) = *s;
*(d++) = *(s++);
}
return B_OK;
}
case media_raw_audio_format::B_AUDIO_UCHAR:
{
register uint8 *d = (uint8 *)dest;
register uint8 *s = (uint8 *)source;
while (framecount--) {
*(d++) = *s;
*(d++) = *(s++);
}
return B_OK;
}
default:
{
fprintf(stderr,"ChannelMixer::mix_1_to_2() unsupported sample format %d\n",(int)format);
return B_ERROR;
}
}
}
} //namespace MediaKitPrivate

View File

@ -57,9 +57,6 @@ SharedLibrary media :
TimeSourceObject.cpp
TimeSourceObjectManager.cpp
SoundPlayNode.cpp
ChannelMixer.cpp
SampleConverter.cpp
SamplingrateConverter.cpp
# Old (R3) Media Kit
OldAudioModule.cpp

View File

@ -1,292 +0,0 @@
/***********************************************************************
* AUTHOR: Marcus Overhagen
* FILE: SampleConverter.cpp
* DESCR: Converts between different sample formats
***********************************************************************/
#include <SupportDefs.h>
#include <MediaDefs.h>
#include <stdio.h>
#include "SampleConverter.h"
extern "C" {
// used by BeOS R5 legacy.media_addon and mixer.media_addon
void convertBufferFloatToShort(float *out, short *in, int32 count);
void convertBufferFloatToShort(float *out, short *in, int32 count)
{
MediaKitPrivate::SampleConverter::convert(
out,
media_raw_audio_format::B_AUDIO_FLOAT,
in,
media_raw_audio_format::B_AUDIO_SHORT,
count);
}
};
namespace MediaKitPrivate {
status_t
SampleConverter::convert(void *dest, uint32 dest_format,
const void *source, uint32 source_format, int samplecount)
{
switch (dest_format) {
case media_raw_audio_format::B_AUDIO_FLOAT:
switch (source_format) {
case media_raw_audio_format::B_AUDIO_FLOAT:
memcpy(dest,source,samplecount * sizeof(float));
return B_OK;
case media_raw_audio_format::B_AUDIO_INT:
convert((float *)dest,(const int32 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_SHORT:
convert((float *)dest,(const int16 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_CHAR:
convert((float *)dest,(const int8 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_UCHAR:
convert((float *)dest,(const uint8 *)source,samplecount);
return B_OK;
default:
fprintf(stderr,"SampleConverter::convert() unsupported source sample format %d\n",(int)source_format);
return B_ERROR;
}
case media_raw_audio_format::B_AUDIO_INT:
switch (source_format) {
case media_raw_audio_format::B_AUDIO_FLOAT:
convert((int32 *)dest,(const float *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_INT:
memcpy(dest,source,samplecount * sizeof(int32));
return B_OK;
case media_raw_audio_format::B_AUDIO_SHORT:
convert((int32 *)dest,(const int16 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_CHAR:
convert((int32 *)dest,(const int8 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_UCHAR:
convert((int32 *)dest,(const uint8 *)source,samplecount);
return B_OK;
default:
fprintf(stderr,"SampleConverter::convert() unsupported source sample format %d\n",(int)source_format);
return B_ERROR;
}
case media_raw_audio_format::B_AUDIO_SHORT:
switch (source_format) {
case media_raw_audio_format::B_AUDIO_FLOAT:
convert((int16 *)dest,(const float *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_INT:
convert((int16 *)dest,(const int32 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_SHORT:
memcpy(dest,source,samplecount * sizeof(int16));
return B_OK;
case media_raw_audio_format::B_AUDIO_CHAR:
convert((int16 *)dest,(const int8 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_UCHAR:
convert((int16 *)dest,(const uint8 *)source,samplecount);
return B_OK;
default:
fprintf(stderr,"SampleConverter::convert() unsupported source sample format %d\n",(int)source_format);
return B_ERROR;
}
case media_raw_audio_format::B_AUDIO_CHAR:
switch (source_format) {
case media_raw_audio_format::B_AUDIO_FLOAT:
convert((int8 *)dest,(const float *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_INT:
convert((int8 *)dest,(const int32 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_SHORT:
convert((int8 *)dest,(const int16 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_CHAR:
memcpy(dest,source,samplecount * sizeof(int8));
return B_OK;
case media_raw_audio_format::B_AUDIO_UCHAR:
convert((int8 *)dest,(const uint8 *)source,samplecount);
return B_OK;
default:
fprintf(stderr,"SampleConverter::convert() unsupported source sample format %d\n",(int)source_format);
return B_ERROR;
}
case media_raw_audio_format::B_AUDIO_UCHAR:
switch (source_format) {
case media_raw_audio_format::B_AUDIO_FLOAT:
convert((uint8 *)dest,(const float *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_INT:
convert((uint8 *)dest,(const int32 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_SHORT:
convert((uint8 *)dest,(const int16 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_CHAR:
convert((uint8 *)dest,(const int8 *)source,samplecount);
return B_OK;
case media_raw_audio_format::B_AUDIO_UCHAR:
memcpy(dest,source,samplecount * sizeof(uint8));
return B_OK;
default:
fprintf(stderr,"SampleConverter::convert() unsupported source sample format %d\n",(int)source_format);
return B_ERROR;
}
default:
fprintf(stderr,"SampleConverter::convert() unsupported destination sample format %d\n",(int)source_format);
return B_ERROR;
}
}
void SampleConverter::convert(uint8 *dest, const float *source, int samplecount)
{
while (samplecount--) {
register int32 sample = int32(*(source++) * 127.0f);
if (sample > 127)
sample = 255;
else if (sample < -127)
sample = 1;
*dest++ = uint8(sample + 128);
}
}
void SampleConverter::convert(uint8 *dest, const int32 *source, int samplecount)
{
while (samplecount--)
*dest++ = uint8((*source++ / (256 * 256 * 256)) + 128);
}
void SampleConverter::convert(uint8 *dest, const int16 *source, int samplecount)
{
while (samplecount--)
*dest++ = uint8((int32(*source++) / 256) + 128);
}
void SampleConverter::convert(uint8 *dest, const int8 *source, int samplecount)
{
while (samplecount--)
*dest++ = uint8(int32(*source++) + 128);
}
void SampleConverter::convert(int8 *dest, const float *source, int samplecount)
{
while (samplecount--) {
register int32 sample = (int32) (*(source++) * 127.0f);
if (sample > 127)
*dest++ = 127;
else if (sample < -127)
*dest++ = -127;
else
*dest++ = int8(sample);
}
}
void SampleConverter::convert(int8 *dest, const int32 *source, int samplecount)
{
while (samplecount--)
*dest++ = int8(*source++ / (256 * 256 * 256));
}
void SampleConverter::convert(int8 *dest, const int16 *source, int samplecount)
{
while (samplecount--)
*dest++ = int8(*source++ / 256);
}
void SampleConverter::convert(int8 *dest, const uint8 *source, int samplecount)
{
while (samplecount--)
*dest++ = int8(*source++ - 128);
}
void SampleConverter::convert(int16 *dest, const float *source, int samplecount)
{
while (samplecount--) {
register int32 sample = (int32) (*source++ * 32767.0f);
if (sample > 32767)
*dest++ = 32767;
else if (sample < -32767)
*dest++ = -32767;
else
*dest++ = int16(sample);
}
}
void SampleConverter::convert(int16 *dest, const int32 *source, int samplecount)
{
while (samplecount--)
*dest++ = int16(*source++ / (256 * 256));
}
void SampleConverter::convert(int16 *dest, const int8 *source, int samplecount)
{
while (samplecount--)
*dest++ = int16(*source++) * 256;
}
void SampleConverter::convert(int16 *dest, const uint8 *source, int samplecount)
{
while (samplecount--)
*dest++ = (int16(*source++) - 128) * 256;
}
void SampleConverter::convert(int32 *dest, const float *source, int samplecount)
{
while (samplecount--) {
register double sample = double(*source++) * 2147483647.0;
if (sample > 2147483647.0)
*dest++ = 2147483647;
else if (sample < -2147483647.0)
*dest++ = -2147483647;
else
*dest++ = int32(sample);
}
}
void SampleConverter::convert(int32 *dest, const int16 *source, int samplecount)
{
while (samplecount--)
*dest++ = int32(*source++) * 256 * 256;
}
void SampleConverter::convert(int32 *dest, const int8 *source, int samplecount)
{
while (samplecount--)
*dest++ = int32(*source++) * 256 * 256 * 256;
}
void SampleConverter::convert(int32 *dest, const uint8 *source, int samplecount)
{
while (samplecount--)
*dest++ = (int32(*source++) - 128) * 256 * 256 * 256;
}
void SampleConverter::convert(float *dest, const int32 *source, int samplecount)
{
while (samplecount--)
*dest++ = float(*source++) / 2147483647.0f;
}
void SampleConverter::convert(float *dest, const int16 *source, int samplecount)
{
while (samplecount--)
*dest++ = float(*source++) / 32767.0f;
}
void SampleConverter::convert(float *dest, const int8 *source, int samplecount)
{
while (samplecount--)
*dest++ = float(*source++) / 127.0f;
}
void SampleConverter::convert(float *dest, const uint8 *source, int samplecount)
{
while (samplecount--)
*dest++ = (float(*source++) - 128.0f) / 127.0f;
}
} //namespace MediaKitPrivate

View File

@ -1,389 +0,0 @@
/***********************************************************************
* AUTHOR: Marcus Overhagen
* FILE: SamplingrateConverter.cpp
* DESCR: Converts between different sampling rates
* This is really bad code, as there are much better algorithms
* than the simple duplicating or dropping of samples.
* Also, the implementation isn't very nice.
* Feel free to send me better versions to marcus@overhagen.de
***********************************************************************/
#include <SupportDefs.h>
#include <MediaDefs.h>
#include <stdio.h>
#include "SamplingrateConverter.h"
namespace MediaKitPrivate {
static void Upsample_stereo(const float *inbuffer, int inframecount, float *outbuffer, int outframecount);
static void Upsample_mono(const float *inbuffer, int inframecount, float *outbuffer, int outframecount);
static void Upsample_stereo(const int32 *inbuffer, int inframecount, int32 *outbuffer, int outframecount);
static void Upsample_mono(const int32 *inbuffer, int inframecount, int32 *outbuffer, int outframecount);
static void Upsample_stereo(const int16 *inbuffer, int inframecount, int16 *outbuffer, int outframecount);
static void Upsample_mono(const int16 *inbuffer, int inframecount, int16 *outbuffer, int outframecount);
static void Upsample_stereo(const int8 *inbuffer, int inframecount, int8 *outbuffer, int outframecount);
static void Upsample_mono(const int8 *inbuffer, int inframecount, int8 *outbuffer, int outframecount);
static void Upsample_stereo(const uint8 *inbuffer, int inframecount, uint8 *outbuffer, int outframecount);
static void Upsample_mono(const uint8 *inbuffer, int inframecount, uint8 *outbuffer, int outframecount);
static void Downsample_stereo(const float *inbuffer, int inframecount, float *outbuffer, int outframecount);
static void Downsample_mono(const float *inbuffer, int inframecount, float *outbuffer, int outframecount);
static void Downsample_stereo(const int32 *inbuffer, int inframecount, int32 *outbuffer, int outframecount);
static void Downsample_mono(const int32 *inbuffer, int inframecount, int32 *outbuffer, int outframecount);
static void Downsample_stereo(const int16 *inbuffer, int inframecount, int16 *outbuffer, int outframecount);
static void Downsample_mono(const int16 *inbuffer, int inframecount, int16 *outbuffer, int outframecount);
static void Downsample_stereo(const int8 *inbuffer, int inframecount, int8 *outbuffer, int outframecount);
static void Downsample_mono(const int8 *inbuffer, int inframecount, int8 *outbuffer, int outframecount);
static void Downsample_stereo(const uint8 *inbuffer, int inframecount, uint8 *outbuffer, int outframecount);
static void Downsample_mono(const uint8 *inbuffer, int inframecount, uint8 *outbuffer, int outframecount);
status_t
SamplingrateConverter::convert(void *dest, int destframecount,
const void *src, int srcframecount,
uint32 format,
int channel_count)
{
if (channel_count != 1 && channel_count != 2) {
fprintf(stderr,"SamplingrateConverter::convert() unsupported channel count %d\n",channel_count);
return B_ERROR;
}
switch (format) {
case media_raw_audio_format::B_AUDIO_FLOAT:
if (destframecount > srcframecount) {
if (channel_count == 1)
Upsample_mono((const float *)src,srcframecount,(float *)dest,destframecount);
else
Upsample_stereo((const float *)src,srcframecount,(float *)dest,destframecount);
} else {
if (channel_count == 1)
Downsample_mono((const float *)src,srcframecount,(float *)dest,destframecount);
else
Downsample_stereo((const float *)src,srcframecount,(float *)dest,destframecount);
}
return B_OK;
case media_raw_audio_format::B_AUDIO_INT:
if (destframecount > srcframecount) {
if (channel_count == 1)
Upsample_mono((const int32 *)src,srcframecount,(int32 *)dest,destframecount);
else
Upsample_stereo((const int32 *)src,srcframecount,(int32 *)dest,destframecount);
} else {
if (channel_count == 1)
Downsample_mono((const int32 *)src,srcframecount,(int32 *)dest,destframecount);
else
Downsample_stereo((const int32 *)src,srcframecount,(int32 *)dest,destframecount);
}
return B_OK;
case media_raw_audio_format::B_AUDIO_SHORT:
if (destframecount > srcframecount) {
if (channel_count == 1)
Upsample_mono((const int16 *)src,srcframecount,(int16 *)dest,destframecount);
else
Upsample_stereo((const int16 *)src,srcframecount,(int16 *)dest,destframecount);
} else {
if (channel_count == 1)
Downsample_mono((const int16 *)src,srcframecount,(int16 *)dest,destframecount);
else
Downsample_stereo((const int16 *)src,srcframecount,(int16 *)dest,destframecount);
}
return B_OK;
case media_raw_audio_format::B_AUDIO_CHAR:
if (destframecount > srcframecount) {
if (channel_count == 1)
Upsample_mono((const int8 *)src,srcframecount,(int8 *)dest,destframecount);
else
Upsample_stereo((const int8 *)src,srcframecount,(int8 *)dest,destframecount);
} else {
if (channel_count == 1)
Downsample_mono((const int8 *)src,srcframecount,(int8 *)dest,destframecount);
else
Downsample_stereo((const int8 *)src,srcframecount,(int8 *)dest,destframecount);
}
return B_OK;
case media_raw_audio_format::B_AUDIO_UCHAR:
if (destframecount > srcframecount) {
if (channel_count == 1)
Upsample_mono((const uint8 *)src,srcframecount,(uint8 *)dest,destframecount);
else
Upsample_stereo((const uint8 *)src,srcframecount,(uint8 *)dest,destframecount);
} else {
if (channel_count == 1)
Downsample_mono((const uint8 *)src,srcframecount,(uint8 *)dest,destframecount);
else
Downsample_stereo((const uint8 *)src,srcframecount,(uint8 *)dest,destframecount);
}
return B_OK;
default:
fprintf(stderr,"SamplingrateConverter::convert() unsupported sample format %d\n",(int)format);
return B_ERROR;
}
}
void Upsample_stereo(const float *inbuffer, int inframecount, float *outbuffer, int outframecount)
{
float delta = float(inframecount) / float(outframecount);
float current = 0.0f;
while (outframecount--) {
*outbuffer++ = inbuffer[0];
*outbuffer++ = inbuffer[1];
current += delta;
if (current > 1.0f) {
current -= 1.0f;
inbuffer += 2;
}
}
}
void Upsample_mono(const float *inbuffer, int inframecount, float *outbuffer, int outframecount)
{
float delta = float(inframecount) / float(outframecount);
float current = 0.0f;
while (outframecount--) {
*outbuffer++ = inbuffer[0];
current += delta;
if (current > 1.0f) {
current -= 1.0f;
inbuffer++;
}
}
}
void Upsample_stereo(const int32 *inbuffer, int inframecount, int32 *outbuffer, int outframecount)
{
float delta = float(inframecount) / float(outframecount);
float current = 0.0f;
while (outframecount--) {
*outbuffer++ = inbuffer[0];
*outbuffer++ = inbuffer[1];
current += delta;
if (current > 1.0f) {
current -= 1.0f;
inbuffer += 2;
}
}
}
void Upsample_mono(const int32 *inbuffer, int inframecount, int32 *outbuffer, int outframecount)
{
float delta = float(inframecount) / float(outframecount);
float current = 0.0f;
while (outframecount--) {
*outbuffer++ = inbuffer[0];
current += delta;
if (current > 1.0f) {
current -= 1.0f;
inbuffer++;
}
}
}
void Upsample_stereo(const int16 *inbuffer, int inframecount, int16 *outbuffer, int outframecount)
{
float delta = float(inframecount) / float(outframecount);
float current = 0.0f;
while (outframecount--) {
*outbuffer++ = inbuffer[0];
*outbuffer++ = inbuffer[1];
current += delta;
if (current > 1.0f) {
current -= 1.0f;
inbuffer += 2;
}
}
}
void Upsample_mono(const int16 *inbuffer, int inframecount, int16 *outbuffer, int outframecount)
{
float delta = float(inframecount) / float(outframecount);
float current = 0.0f;
while (outframecount--) {
*outbuffer++ = inbuffer[0];
current += delta;
if (current > 1.0f) {
current -= 1.0f;
inbuffer++;
}
}
}
void Upsample_stereo(const int8 *inbuffer, int inframecount, int8 *outbuffer, int outframecount)
{
float delta = float(inframecount) / float(outframecount);
float current = 0.0f;
while (outframecount--) {
*outbuffer++ = inbuffer[0];
*outbuffer++ = inbuffer[1];
current += delta;
if (current > 1.0f) {
current -= 1.0f;
inbuffer += 2;
}
}
}
void Upsample_mono(const int8 *inbuffer, int inframecount, int8 *outbuffer, int outframecount)
{
float delta = float(inframecount) / float(outframecount);
float current = 0.0f;
while (outframecount--) {
*outbuffer++ = inbuffer[0];
current += delta;
if (current > 1.0f) {
current -= 1.0f;
inbuffer++;
}
}
}
void Upsample_stereo(const uint8 *inbuffer, int inframecount, uint8 *outbuffer, int outframecount)
{
float delta = float(inframecount) / float(outframecount);
float current = 0.0f;
while (outframecount--) {
*outbuffer++ = inbuffer[0];
*outbuffer++ = inbuffer[1];
current += delta;
if (current > 1.0f) {
current -= 1.0f;
inbuffer += 2;
}
}
}
void Upsample_mono(const uint8 *inbuffer, int inframecount, uint8 *outbuffer, int outframecount)
{
float delta = float(inframecount) / float(outframecount);
float current = 0.0f;
while (outframecount--) {
*outbuffer++ = inbuffer[0];
current += delta;
if (current > 1.0f) {
current -= 1.0f;
inbuffer++;
}
}
}
void Downsample_stereo(const float *inbuffer, int inframecount, float *outbuffer, int outframecount)
{
double delta = double(inframecount) / double(outframecount);
double pos = 0.0;
while (outframecount--) {
int p = int(pos);
*outbuffer++ = inbuffer[p];
*outbuffer++ = inbuffer[p+1];
pos += delta;
}
}
void Downsample_mono(const float *inbuffer, int inframecount, float *outbuffer, int outframecount)
{
double delta = double(inframecount) / double(outframecount);
double pos = 0.0;
while (outframecount--) {
*outbuffer++ = inbuffer[int(pos)];
pos += delta;
}
}
void Downsample_stereo(const int32 *inbuffer, int inframecount, int32 *outbuffer, int outframecount)
{
double delta = double(inframecount) / double(outframecount);
double pos = 0.0;
while (outframecount--) {
int p = int(pos);
*outbuffer++ = inbuffer[p];
*outbuffer++ = inbuffer[p+1];
pos += delta;
}
}
void Downsample_mono(const int32 *inbuffer, int inframecount, int32 *outbuffer, int outframecount)
{
double delta = double(inframecount) / double(outframecount);
double pos = 0.0;
while (outframecount--) {
*outbuffer++ = inbuffer[int(pos)];
pos += delta;
}
}
void Downsample_stereo(const int16 *inbuffer, int inframecount, int16 *outbuffer, int outframecount)
{
double delta = double(inframecount) / double(outframecount);
double pos = 0.0;
while (outframecount--) {
int p = int(pos);
*outbuffer++ = inbuffer[p];
*outbuffer++ = inbuffer[p+1];
pos += delta;
}
}
void Downsample_mono(const int16 *inbuffer, int inframecount, int16 *outbuffer, int outframecount)
{
double delta = double(inframecount) / double(outframecount);
double pos = 0.0;
while (outframecount--) {
*outbuffer++ = inbuffer[int(pos)];
pos += delta;
}
}
void Downsample_stereo(const int8 *inbuffer, int inframecount, int8 *outbuffer, int outframecount)
{
double delta = double(inframecount) / double(outframecount);
double pos = 0.0;
while (outframecount--) {
int p = int(pos);
*outbuffer++ = inbuffer[p];
*outbuffer++ = inbuffer[p+1];
pos += delta;
}
}
void Downsample_mono(const int8 *inbuffer, int inframecount, int8 *outbuffer, int outframecount)
{
double delta = double(inframecount) / double(outframecount);
double pos = 0.0;
while (outframecount--) {
*outbuffer++ = inbuffer[int(pos)];
pos += delta;
}
}
void Downsample_stereo(const uint8 *inbuffer, int inframecount, uint8 *outbuffer, int outframecount)
{
double delta = double(inframecount) / double(outframecount);
double pos = 0.0;
while (outframecount--) {
int p = int(pos);
*outbuffer++ = inbuffer[p];
*outbuffer++ = inbuffer[p+1];
pos += delta;
}
}
void Downsample_mono(const uint8 *inbuffer, int inframecount, uint8 *outbuffer, int outframecount)
{
double delta = double(inframecount) / double(outframecount);
double pos = 0.0;
while (outframecount--) {
*outbuffer++ = inbuffer[int(pos)];
pos += delta;
}
}
} //namespace MediaKitPrivate