1575526ffSbeveloper #ifndef _RESAMPLER_H 2575526ffSbeveloper #define _RESAMPLER_H 3575526ffSbeveloper /* Copyright (C) 2003 Marcus Overhagen 4575526ffSbeveloper * Released under terms of the MIT license. 5575526ffSbeveloper * 6575526ffSbeveloper * A simple resampling class for the audio mixer. 7c6a2e89fSStefano Ceccherini * You pick the conversion function on object creation, 8575526ffSbeveloper * and then call the Resample() function, specifying data pointer, 9575526ffSbeveloper * offset (in bytes) to the next sample, and count of samples for 10575526ffSbeveloper * both source and destination. 11575526ffSbeveloper * 12575526ffSbeveloper */ 13575526ffSbeveloper 14575526ffSbeveloper class Resampler 15575526ffSbeveloper { 16575526ffSbeveloper public: 17ff14d245SJérôme Duval Resampler(uint32 sourceformat, uint32 destformat, int16 dst_valid_bits); 18575526ffSbeveloper virtual ~Resampler(); 19575526ffSbeveloper 20575526ffSbeveloper status_t InitCheck(); 21575526ffSbeveloper 22575526ffSbeveloper void Resample(const void *src, int32 src_sample_offset, int32 src_sample_count, 23575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 24575526ffSbeveloper 25575526ffSbeveloper protected: 26575526ffSbeveloper virtual void float_to_float (const void *src, int32 src_sample_offset, int32 src_sample_count, 27575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 28575526ffSbeveloper virtual void int32_to_float (const void *src, int32 src_sample_offset, int32 src_sample_count, 29575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 30575526ffSbeveloper virtual void int16_to_float (const void *src, int32 src_sample_offset, int32 src_sample_count, 31575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 32575526ffSbeveloper virtual void int8_to_float (const void *src, int32 src_sample_offset, int32 src_sample_count, 33575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 34575526ffSbeveloper virtual void uint8_to_float (const void *src, int32 src_sample_offset, int32 src_sample_count, 35575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 36ff14d245SJérôme Duval virtual void float_to_int32_32 (const void *src, int32 src_sample_offset, int32 src_sample_count, 37ff14d245SJérôme Duval void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 38ff14d245SJérôme Duval virtual void float_to_int32_24 (const void *src, int32 src_sample_offset, int32 src_sample_count, 39575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 40*ebc67ddeSJérôme Duval virtual void float_to_int32_20 (const void *src, int32 src_sample_offset, int32 src_sample_count, 41*ebc67ddeSJérôme Duval void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 42575526ffSbeveloper virtual void float_to_int16 (const void *src, int32 src_sample_offset, int32 src_sample_count, 43575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 44575526ffSbeveloper virtual void float_to_int8 (const void *src, int32 src_sample_offset, int32 src_sample_count, 45575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 46575526ffSbeveloper virtual void float_to_uint8 (const void *src, int32 src_sample_offset, int32 src_sample_count, 47575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain); 48575526ffSbeveloper private: 49575526ffSbeveloper void (Resampler::*fFunc) (const void *, int32, int32, void *, int32, int32, float); 50575526ffSbeveloper }; 51575526ffSbeveloper 52575526ffSbeveloper 53575526ffSbeveloper inline void 54575526ffSbeveloper Resampler::Resample(const void *src, int32 src_sample_offset, int32 src_sample_count, 55575526ffSbeveloper void *dst, int32 dst_sample_offset, int32 dst_sample_count, float gain) 56575526ffSbeveloper { 57575526ffSbeveloper (this->*fFunc)(src, src_sample_offset, src_sample_count, dst, dst_sample_offset, dst_sample_count, gain); 58575526ffSbeveloper } 59575526ffSbeveloper 60575526ffSbeveloper #endif 61