コード例 #1
0
        short[] ComputeMean(int idx)
        {
            int       left        = 0;
            int       right       = 0;
            ArrayList listUnmuted = GetUnmutedItems();
            int       num         = listUnmuted.Count;
            double    factorL     = 0;
            double    factorR     = 0;

            for (int i = 0; i < num; i++)
            {
                try
                {
                    WavData item = ((ItemSet)listUnmuted[i]).GetData();
                    left    += item.GetLeft(idx);
                    right   += item.GetRight(idx);
                    factorL += Math.Abs(item.GetFactor(idx, WavData.LEFT));
                    factorR += Math.Abs(item.GetFactor(idx, WavData.RIGHT));
                }
                catch (ArgumentOutOfRangeException)
                {
                    // sometimes thrown when item removed while playing
                    // can be ignored
                }
                catch (NullReferenceException)
                {
                    continue;
                }
            }
            if (factorL == 0 && factorR == 0 && avoidAllMute)
            {
                WavData item = GetLastItem().GetData();
                item.IsDefault = true;
                left           = item.GetLeft(idx);
                right          = item.GetRight(idx);
                item.IsDefault = false;
                factorL        = 1;
                factorR        = 1;
            }
            short newLeft, newRight;

            if (factorL > 1 || normalize)
            {
                newLeft = ToShortDevidedBy(left, factorL);
            }
            else
            {
                newLeft = Convert.ToInt16(left);
            }
            if (factorR > 1 || normalize)
            {
                newRight = ToShortDevidedBy(right, factorR);;
            }
            else
            {
                newRight = Convert.ToInt16(right);
            }
            return(new short[] { newLeft, newRight });
        }
コード例 #2
0
        void PaintMask(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            double[] sumfac  = ic.ComputeFactorSum(true);
            double   factorL = Math.Abs(wd.GetFactor(0, WavData.LEFT));
            double   factorR = Math.Abs(wd.GetFactor(0, WavData.RIGHT));

            int alphaL = FactorToAlpha(factorL / sumfac[0]);
            int alphaR = FactorToAlpha(factorR / sumfac[1]);

            Color color = Color.FromArgb(alphaL, mainPanelBack);
            Brush b     = new SolidBrush(color);

            g.FillRectangle(b, 0, 0, 64, 128);
            color = Color.FromArgb(alphaR, mainPanelBack);
            b     = new SolidBrush(color);
            g.FillRectangle(b, 64, 0, 128, 128);

            Font fnt = new System.Drawing.Font("Meiryo UI", 15, FontStyle.Bold);;

            g.DrawString(myKey.ToString(), fnt, Brushes.Black, 0, 0);
        }