What is the relationship of the two process function in template anda class?

F

fl

Hi,
I am new to C++. I got the following snippet on the web. It is similar to my project application. I want to continue write with this code for my project. I find that there is process definition in the template. In the class definition, it has also a process definition. Could you explain what is the difference between them?

Thanks,




....................................
template<int UPSAMPLE_RATE, int TAPS_PER_PHASE, int MAX_INPUT_SAMPLE_COUNT>
class polyphase_upsample_fir_c
{
public:
static const int STATE_SAMPLE_COUNT = TAPS_PER_PHASE-1;

private:
const float (&taps)[UPSAMPLE_RATE][TAPS_PER_PHASE]; // These must be stored flipped left-to-right for simplicity
// float taps[UPSAMPLE_RATE][TAPS_PER_PHASE]; // THIS IS 4x FASTER THAN USING THE REFERENCE
cmplx_float_c state_and_input[STATE_SAMPLE_COUNT + MAX_INPUT_SAMPLE_COUNT];

public:
polyphase_upsample_fir_c(const float (&taps)[UPSAMPLE_RATE][TAPS_PER_PHASE]) :
taps(taps)
{
// Initialize the state to zero
for(int index=0; index<STATE_SAMPLE_COUNT; index++)
{
state_and_input[index].set(0, 0);
}
}

void process(int input_sample_count, cmplx_float_c* output);

// Returns a pointer to the first sample past the state memory, this is where the filter input should be placed.
inline cmplx_float_c* get_input_pointer() { return &state_and_input[STATE_SAMPLE_COUNT]; }

};






class polyphase_upsample_fir_24_c
{
public:
static const int UPSAMPLE_RATE = 24;
static const int TAPS_PER_PHASE = 16;
static const int MAX_INPUT_SAMPLE_COUNT = 48;

private:
polyphase_upsample_fir_c<UPSAMPLE_RATE, TAPS_PER_PHASE, MAX_INPUT_SAMPLE_COUNT> filter;
static const float taps[UPSAMPLE_RATE][TAPS_PER_PHASE];

public:
polyphase_upsample_fir_24_c():
filter(taps)
{}

void process(int input_sample_count, cmplx_float_c* output);

inline cmplx_float_c* get_input_pointer() { return filter.get_input_pointer(); }
};
 
J

James Kuyper

Hi,
I am new to C++. I got the following snippet on the web. It is similar to my project application. I want to continue write with this code for my project. I find that there is process definition in the template. In the class definition, it has also a process definition. Could you explain what is the difference between them?

This news group is for discussion of the C programming language; for
discussions of the C++ programming language, go to comp.lang.c++ or
comp.lang.c++.moderated. The unmoderated newsgroup is nearly 10 times as
active as the moderated one, but from past experience with other
newsgroups, I'd expect the extra activity to consist mainly of noise -
I'd recommend trying the moderated group first.

However, the simple answer to your question is that the only difference
between them that's visible in this snippet is that they are members of
different classes. Therefore, they could have wildly different
definitions. However, without providing the actual definitions of those
functions, there's no way to know how they differ. When you repost to an
appropriate C++-oriented forum, I'd recommend searching for and
including the definitions of those two functions in your question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top