annotate Plugins/Input/console/Dual_Resampler.h @ 1343:c81fa4bb2872 trunk

[svn] User did not test his submission. Fix based on reports by fluxinator on #audacious.
author chainsaw
date Wed, 28 Jun 2006 06:29:38 -0700
parents c04dff121e1d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
493
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
1
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
2 // Combination of Fir_Resampler and Blip_Buffer mixing. Used by Sega FM emulators.
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
3
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
4 // Game_Music_Emu 0.3.0
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
5
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
6 #ifndef DUAL_RESAMPLER_H
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
7 #define DUAL_RESAMPLER_H
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
8
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
9 #include "Fir_Resampler.h"
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
10 #include "Blip_Buffer.h"
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
11
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
12 class Dual_Resampler {
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
13 public:
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
14 Dual_Resampler();
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
15 virtual ~Dual_Resampler();
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
16
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
17 typedef short sample_t;
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
18
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
19 double setup( double oversample, double rolloff, double gain );
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
20 blargg_err_t resize( int pairs );
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
21 void clear();
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
22
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
23 void play( long count, sample_t* out, Blip_Buffer& );
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
24
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
25 protected:
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
26 virtual int play_frame( blip_time_t, int pcm_count, sample_t* pcm_out ) = 0;
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
27 private:
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
28
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
29 blargg_vector<sample_t> sample_buf;
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
30 int oversamples_per_frame;
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
31 int buf_pos;
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
32 Fir_Resampler<12> resampler;
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
33 void mix_samples( Blip_Buffer&, sample_t* );
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
34 void play_frame_( Blip_Buffer&, sample_t* );
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
35 };
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
36
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
37 inline double Dual_Resampler::setup( double oversample, double rolloff, double gain )
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
38 {
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
39 return resampler.time_ratio( oversample, rolloff, gain * 0.5 );
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
40 }
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
41
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
42 inline void Dual_Resampler::clear()
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
43 {
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
44 buf_pos = sample_buf.size();
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
45 resampler.clear();
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
46 }
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
47
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
48 #endif
c04dff121e1d [svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff changeset
49