/***************************************************************** file: mixer.h Description: Subroutines to implement a (real) mixer. Multiple subroutine calls are used to create a signal y(n) = x(n)c(n) where x(n) is the nth input sample, and the values of c(n) obtained from a (circularly accessed) array of fixed values. (Typically, the array c(n) is initialize to give samples of a cosine or sine function.) Implementation: Mixers are implemented using three functions: init_mixer() is called once, and is used to initialize the array of mixer samples c(n), allocate any required memory, and perform any other required initialization. calc_mixer() is called multiple times -- once for every input sample. It returns the mixer output sample y(n). destroy_mixer() is called once at the end of the program, and is used to de-allocate any memory. Function Prototypes and parameters: #include "mixer.h" MIXER_STRUCT *init_mixer(int *mixer_coefs, int n_coef); Inputs: mixer_coefs pointer to the array of values for c(n) The mixer_coefs array is NOT modified by init_mixer(), calc_mixer(), or destroy_mixer(). Coefficients are assumed to be stored using a fixed point representation, with the least-significant 14 bits of the data word representing the fractional part. n_coef Number of samples in the array Returned: The function returns a pointer to a "MIXER_STRUCT" data type (which is defined in "mixer.h") int calc_mixer(MIXER_STRUCT *s, int x ); Inputs: s pointer to MIXER_STRUCT, as provided by init_mixer() x Input sample value Sample values are assumed to be stored using a fixed point representation, with the least-significant 14 bits of the data word representing the fractional part. Returned: The function returns the mixer output sample, x*c(n), where c(n) is obtained from the mixer_coefs array of values. Each call to calc_mixer accesses the next sample in the array. When the end of the array is reached, the index is reset to the beginning of the array. The return value is represented as a fixed point integer, with the least-significant 14 bits of the data word representing its fractional part. void destroy_mixer(MIXER_STRUCT *s); Inputs: s pointer to MIXER_STRUCT, as provided by init_mixer() No value is returned. *******************************************************************/ #ifndef ECE486_MIXER #define ECE486_MIXER /******* ECE486 STUDENTS MODIFY THIS *******/ #endif