Exemplo n.º 1
0
        private List<ModulationNode> GetModulationNodeList()
        {
            //InputKrystal xInputKrystal, InputKrystal yInputKrystal
            List<ModulationNode> modulationNodeList = new List<ModulationNode>();

            InputKrystal master, slave;
            if(_xInputKrystal.Level > _yInputKrystal.Level)
            {
                master = _xInputKrystal;
                slave = _yInputKrystal;
            }
            else
            {
                slave = _xInputKrystal;
                master = _yInputKrystal;
            }

            int[] alignedSlaveValues = slave.AlignedValues(master);
            // first construct a flat list of modulation nodes (the leaf nodes of the final tree)
            int momentIndex = 0;
            foreach(LeveledValue leveledValue in master.LeveledValues)
            {
                int level = leveledValue.level;
                int mVal = leveledValue.value;
                if(mVal == 0 || alignedSlaveValues[momentIndex] == 0)
                {
                    string msg = "Error: An input krystal contained a value of zero.";
                    throw new ApplicationException(msg);
                }
                ModulationNode mn;
                if(master == _xInputKrystal)
                    mn = new ModulationNode(momentIndex + 1, level, mVal, alignedSlaveValues[momentIndex]);
                else
                    mn = new ModulationNode(momentIndex + 1, level, alignedSlaveValues[momentIndex], mVal);
                modulationNodeList.Add(mn);
                momentIndex++;
            }
            return modulationNodeList;
        }