kwave  18.07.70
MixerMatrix.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  MixerMatrix.cpp - channel mixer matrix
3  -------------------
4  begin : 2012-05-11
5  copyright : (C) 2012 by Thomas Eschenbacher
6  email : Thomas Eschenbacher <Thomas.Eschenbacher@gmx.de>
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #include "config.h"
20 
21 #include "libkwave/MixerMatrix.h"
22 
23 //***************************************************************************
24 Kwave::MixerMatrix::MixerMatrix(unsigned int inputs, unsigned int outputs)
25  :Kwave::Matrix<double>(inputs, outputs)
26 {
27  for (unsigned int y = 0; y < outputs; y++) {
28  unsigned int m1, m2;
29 
30  m1 = y * inputs;
31  m2 = (y + 1) * inputs;
32 
33  for (unsigned int x = 0; x < inputs; x++) {
34  unsigned int n1, n2;
35  n1 = x * outputs;
36  n2 = n1 + outputs;
37 
38  // get the common area of [n1..n2] and [m1..m2]
39  unsigned int l = (n1 > m1) ? n1 : m1;
40  unsigned int r = (n2 < m2) ? n2 : m2;
41 
42  (*this)[x][y] = (r > l) ? static_cast<double>(r - l) /
43  static_cast<double>(inputs) : 0.0;
44  }
45  }
46 }
47 
48 //***************************************************************************
50 {
51 }
52 
53 //***************************************************************************
54 //***************************************************************************
Definition: App.h:33
virtual ~MixerMatrix()
Definition: MixerMatrix.cpp:49
MixerMatrix(unsigned int inputs, unsigned int outputs)
Definition: MixerMatrix.cpp:24