Example #1
0
        private bool[] GetSelectedChannel10Keys(MidiFileReader.MidiSource source)
        {
            var keys = new bool[MidiFileReader.MidiDrumKeyNames.Length];

            for (int i = 0; i < MidiFileReader.MidiDrumKeyNames.Length; i++)
            {
                keys[i] = (((1ul << i) & source.keys) != 0);
            }

            return(keys);
        }
Example #2
0
        private void Properties_PropertyChanged(PropertyPage props, int idx, object value)
        {
            if (idx == 0)
            {
                var expansion       = ExpansionType.GetValueForName((string)value);
                var newChannelCount = Channel.GetChannelCountForExpansion(expansion);
                var oldChannelCount = channelSources.Length;

                var maxChannelIndex = 3;
                for (int i = 0; i < oldChannelCount; i++)
                {
                    if (channelSources[i].type == MidiSourceType.Channel && channelSources[i].index != 9)
                    {
                        maxChannelIndex = Math.Max(maxChannelIndex, channelSources[i].index);
                    }
                }

                Array.Resize(ref channelSources, newChannelCount);

                for (int i = oldChannelCount; i < newChannelCount; i++)
                {
                    channelSources[i] = new MidiFileReader.MidiSource()
                    {
                        index = maxChannelIndex++
                    };
                }

                UpdateListView();

                bool allowPal = expansion == ExpansionType.None;
                dialog.Properties.SetPropertyEnabled(4, allowPal);
                if (!allowPal)
                {
                    dialog.Properties.SetPropertyValue(4, false);
                }
            }
        }
Example #3
0
        private void Properties_PropertyChanged(PropertyPage props, int propIdx, int rowIdx, int colIdx, object value)
        {
            if (propIdx == 4)
            {
                var expansionMask   = GetExpansionMask(props.GetPropertyValue <bool[]>(4));
                var newChannelCount = Channel.GetChannelCountForExpansionMask(expansionMask, 8);
                var oldChannelCount = channelSources.Length;

                var maxChannelIndex = 2;
                for (int i = 0; i < oldChannelCount; i++)
                {
                    if (channelSources[i].type == MidiSourceType.Channel && channelSources[i].index != 9)
                    {
                        maxChannelIndex = Math.Max(maxChannelIndex, channelSources[i].index);
                    }
                }

                Array.Resize(ref channelSources, newChannelCount);

                for (int i = oldChannelCount; i < newChannelCount; i++)
                {
                    maxChannelIndex = Math.Min(maxChannelIndex + 1, 15);
                    if (maxChannelIndex == 9)
                    {
                        maxChannelIndex++;
                    }
                    channelSources[i] = new MidiFileReader.MidiSource()
                    {
                        index = maxChannelIndex
                    };
                }

                UpdateListView();

                bool allowPal = expansionMask == ExpansionType.NoneMask;
                dialog.Properties.SetPropertyEnabled(3, allowPal);
                if (!allowPal)
                {
                    dialog.Properties.SetPropertyValue(3, false);
                }
            }
            else if (propIdx == 6)
            {
                Debug.Assert(colIdx == 1);

                var src = channelSources[rowIdx];
                var str = (string)value;

                if (str.StartsWith("Track"))
                {
                    src.type  = MidiSourceType.Track;
                    src.index = Utils.ParseIntWithTrailingGarbage(str.Substring(6)) - 1;
                }
                else if (str.StartsWith("Channel"))
                {
                    src.type  = MidiSourceType.Channel;
                    src.index = Utils.ParseIntWithTrailingGarbage(str.Substring(8)) - 1;
                }
                else
                {
                    src.type  = MidiSourceType.None;
                    src.index = 0;
                }

                UpdateListView();
            }
        }