Пример #1
0
        private void incDecCC(MappingViewModel mapping, int step)
        {
            var oldBinding = mapping.MidiBinding as ControlChangeMidiDefinition;

            var oldCC = oldBinding.Cc;
            var newCC = oldCC + step;

            var new_CC_def = new ControlChangeMidiDefinition(oldBinding.Type, oldBinding.Channel, newCC);

            mapping.SetBinding(new_CC_def);
        }
Пример #2
0
        private static Dictionary <string, AMidiDefinition> createGenericMidiDefinitions(MappingType type)
        {
            Dictionary <string, AMidiDefinition> result = new Dictionary <string, AMidiDefinition>();

            KeyConverter keyConverter = new KeyConverter();

            int numChannels = 16;
            int num         = 128;

            for (int i = 1; i <= numChannels; i++)
            {
                for (int j = 0; j < num; j++)
                {
                    var cc = new ControlChangeMidiDefinition(type, i, j);
                    result.Add(cc.Note, cc);
                    var note = new NoteMidiDefinition(type, i, keyConverter.GetKeyTextIPN(j));
                    result.Add(note.Note, note);
                }

                var pitch = new PitchBendMidiDefinition(type, i);
                result.Add(pitch.Note, pitch);
            }
            return(result);
        }
Пример #3
0
        ////////////


        private void applyMidiRange()
        {
            var templateBinding = _mappings.First().MidiBinding as AGenericMidiDefinition;

            var isCC = templateBinding is ControlChangeMidiDefinition;

            var keyConverter = new MidiLib.Utils.KeyConverter();

            int number = isCC ? (templateBinding as ControlChangeMidiDefinition).Cc : keyConverter.ToKeyIPN((templateBinding as NoteMidiDefinition).KeyText);

            AGenericMidiDefinition newBinding;

            foreach (var m in _mappings)
            {
                if (m.MidiBinding != null && m.MidiBinding.Equals(templateBinding))
                {
                    continue;
                }

                number++;

                if (isCC)
                {
                    newBinding = new ControlChangeMidiDefinition(templateBinding.Type, templateBinding.Channel, number);
                }
                else
                {
                    newBinding = new NoteMidiDefinition(templateBinding.Type, templateBinding.Channel, keyConverter.GetKeyTextIPN(number));
                }

                m.SetBinding(newBinding);
            }

            analyzeSelection();
            updateMenus();
        }