View Single Post
Old 08-13-2015, 02:52 PM   #10
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

Well, if you want to test your mid/side processing just temporarily set mono = 0.0, and your width to 1.0. This will leave only the sides, so if you feed it a mono signal you should get silence, but if you feed it a stereo signal you should get some output.

BTW, you don't need to declare all variables in your class, variables that are only used by a single method are probably better declared locally to that method. I would also suggest to prefix member variables with m (or m_), so it is easier to distinguish between local and member variables. E.g.:

Code:
class StereoWidth
{
public:
  // Init coef to sensible default, in case we forget to call setWidth().
  StereoWidth(): mCoef_S(0) {}

  void process(double in_left, double in_right, double* out_left, double* out_right)
  {
    double mono = (in_left + in_right) * 0.5;
    double stereo = (in_right - in_left ) * mCoef_S;

    *out_left  = mono - stereo;
    *out_right = mono + stereo;
  }

  inline void setWidth(double newWidth)
  {
    mCoef_S = newWidth * 0.5;
  }

private:
  double mCoef_S;
};
Tale is offline   Reply With Quote