Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

InternalAudioResample< input_t, output_t > Class Template Reference

#include <frame.h>

Inheritance diagram for InternalAudioResample< input_t, output_t >:

Inheritance graph
[legend]
Collaboration diagram for InternalAudioResample< input_t, output_t >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 InternalAudioResample ()
 InternalAudioResample (double output_rate)
virtual ~InternalAudioResample ()
void Resample (input_t *input, double input_rate, int channels, int samples)
 Simple up and down resampler for people unable to handle 48khz audio.

template<class input_t, class output_t>
class InternalAudioResample< input_t, output_t >


Constructor & Destructor Documentation

template<class input_t, class output_t>
InternalAudioResample< input_t, output_t >::InternalAudioResample  )  [inline]
 

Definition at line 271 of file frame.h.

00271                              : AudioResample<input_t,output_t>( 0 )
00272     { }

template<class input_t, class output_t>
InternalAudioResample< input_t, output_t >::InternalAudioResample double  output_rate  )  [inline]
 

Definition at line 273 of file frame.h.

template<class input_t, class output_t>
virtual InternalAudioResample< input_t, output_t >::~InternalAudioResample  )  [inline, virtual]
 

Definition at line 275 of file frame.h.

00276     { }


Member Function Documentation

template<class input_t, class output_t>
void InternalAudioResample< input_t, output_t >::Resample input_t *  input,
double  input_rate,
int  channels,
int  samples
[inline, virtual]
 

Simple up and down resampler for people unable to handle 48khz audio.

Also fixes mixed projects with 32khz and 48khz audio sampling (yippee!).

Reimplemented from AudioResample< input_t, output_t >.

Definition at line 281 of file frame.h.

References AudioResample< input_t, output_t >::output, AudioResample< input_t, output_t >::output_rate, and AudioResample< input_t, output_t >::size.

00282     {
00283         float ratio = ( float ) this->output_rate / ( float ) input_rate;
00284         this->size = ( int ) ( ( float ) samples * ratio );
00285 
00286         int rounding = 1 << 15;
00287         unsigned int xfactor = ( samples << 16 ) / this->size;
00288         unsigned int xmax = xfactor * this->size;
00289         unsigned int i = 0;
00290         unsigned int o = 0;
00291         this->size *= sizeof(output_t) * channels;
00292 
00293         for ( unsigned int xft = 0; xft < xmax; xft += xfactor )
00294         {
00295             i = ( ( xft + rounding ) >> 16 ) * channels;
00296             for (int c=0; c < channels; c++)
00297                 this->output[o+c] = input[i+c];
00298             o += channels;
00299         }
00300 
00301     }


The documentation for this class was generated from the following file:
Generated on Sun Mar 11 22:13:07 2007 for Kino by  doxygen 1.4.2