Пример #1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ChannelMatrix" /> class.
        /// </summary>
        /// <param name="inputMask">The <see cref="ChannelMask" /> of the input signal.</param>
        /// <param name="outputMask">The <see cref="ChannelMask" /> of the output signal.</param>
        /// <exception cref="ArgumentException">Invalid <paramref name="inputMask" />/<paramref name="outputMask" />.</exception>
        public ChannelMatrix(ChannelMask inputMask, ChannelMask outputMask)
        {
            _inputMask  = inputMask;
            _outputMask = outputMask;

            if ((int)inputMask <= 0)
            {
                throw new ArgumentException("Invalid inputMask");
            }
            if ((int)outputMask <= 0)
            {
                throw new ArgumentException("Invalid outputMask");
            }

            _matrix =
                new ChannelMatrixElement[GetValuesOfChannelMask(inputMask).Length,
                                         GetValuesOfChannelMask(outputMask).Length];
            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    _matrix[y, x] = new ChannelMatrixElement(GetValuesOfChannelMask(inputMask)[y],
                                                             GetValuesOfChannelMask(outputMask)[x]);
                }
            }
        }
Пример #2
0
        /// <summary>
        ///     Flips the axis of the matrix and returns the new matrix with the flipped axis.
        /// </summary>
        /// <returns>A matrix with flipped axis.</returns>
        /// <remarks>
        ///     This could be typically used in the following scenario: There is a
        ///     5.1 to stereo matrix. By using the <see cref="Flip" /> method the 5.1 to stereo matrix can be
        ///     converted into a stereo to 5.1 matrix.
        /// </remarks>
        public ChannelMatrix Flip()
        {
            var result = new ChannelMatrix(OutputMask, InputMask);

            for (int x = 0; x < OutputChannelCount; x++)
            {
                for (int y = 0; y < InputChannelCount; y++)
                {
                    ChannelMatrixElement input = this[y, x];
                    result[x, y] = new ChannelMatrixElement(input.OutputChannel, input.InputChannel)
                    {
                        Value = input.Value
                    };
                }
            }
            return(result);
        }
Пример #3
0
        public ChannelMatrix(ChannelMask inputMask, ChannelMask outputMask)
        {
            _inputMask = inputMask;
            _outputMask = outputMask;

            if ((int)inputMask <= 0)
                throw new ArgumentException("Invalid inputMask");
            if ((int)outputMask <= 0)
                throw new ArgumentException("Invalid outputMask");

            _matrix = new ChannelMatrixElement[GetValuesOfChannelMask(inputMask).Length, GetValuesOfChannelMask(outputMask).Length];
            for (int x = 0; x < _matrix.GetLength(0); x++)
            {
                for (int y = 0; y < _matrix.GetLength(1); y++)
                {
                    _matrix[x, y] = new ChannelMatrixElement(GetValuesOfChannelMask(inputMask)[x], GetValuesOfChannelMask(outputMask)[y]);
                }
            }
        }
Пример #4
0
 /// <summary>
 ///     Flips the axis of the matrix and returns the new matrix with the flipped axis.
 /// </summary>
 /// <returns>A matrix with flipped axis.</returns>
 /// <remarks>
 ///     This could be typically used in the following scenario: There is a
 ///     5.1 to stereo matrix. By using the <see cref="Flip" /> method the 5.1 to stereo matrix can be
 ///     converted into a stereo to 5.1 matrix.
 /// </remarks>
 public ChannelMatrix Flip()
 {
     var result = new ChannelMatrix(OutputMask, InputMask);
     for (int x = 0; x < OutputChannelCount; x++)
     {
         for (int y = 0; y < InputChannelCount; y++)
         {
             ChannelMatrixElement input = this[y, x];
             result[x, y] = new ChannelMatrixElement(input.OutputChannel, input.InputChannel)
             {
                 Value = input.Value
             };
         }
     }
     return result;
 }