Example #1
0
        private void btnSoundGeneratorEditOK_Click(object sender, EventArgs e)
        {
            // Complete any in-progress patch editing
            if (pnlSoundGeneratorPatchEdit.Visible)
            {
                btnSoundGeneratorPatchEditOK_Click(sender, e);
            }

            if (bCreatingNewSoundGenerator == true)
            {
                soundGeneratorBeingEdited.name = tbSoundGeneratorName.Text;
            }
            soundGeneratorBeingEdited.deviceName  = cbSoundGeneratorDeviceName.Text;
            soundGeneratorBeingEdited.channelBase = (int)nudSoundGeneratorBaseChannel.Value - 1;
            soundGeneratorBeingEdited.nChannels   = (int)nudSoundGeneratorNumChannels.Value;
            soundGeneratorBeingEdited.cc7Min      = (int)nudVolMin.Value;
            soundGeneratorBeingEdited.cc7Max      = (int)nudVolMax.Value;

            if (bCreatingNewSoundGenerator == true)
            {
                soundGeneratorBeingEdited.bind(mapper.configuration.logicalOutputDeviceDict);
                mapper.configuration.soundGenerators.Add(soundGeneratorBeingEdited.name, soundGeneratorBeingEdited);
                mapper.configuration.dirty = true;
            }
            else
            {
                SoundGenerator soundGeneratorToModify = mapper.configuration.soundGenerators[soundGeneratorBeingEdited.name];
                soundGeneratorToModify.deviceName  = cbSoundGeneratorDeviceName.Text;
                soundGeneratorToModify.channelBase = (int)nudSoundGeneratorBaseChannel.Value - 1;
                soundGeneratorToModify.nChannels   = (int)nudSoundGeneratorNumChannels.Value;
                soundGeneratorToModify.cc7Min      = (int)nudVolMin.Value;
                soundGeneratorToModify.cc7Max      = (int)nudVolMax.Value;
                soundGeneratorToModify.soundGeneratorPatchDict.Clear();
                foreach (String patchName in soundGeneratorBeingEdited.soundGeneratorPatchDict.Keys)
                {
                    SoundGeneratorPatch patch = soundGeneratorBeingEdited.soundGeneratorPatchDict[patchName];
                    soundGeneratorToModify.soundGeneratorPatchDict.Add(patch.name, patch);
                }
                soundGeneratorToModify.bind(mapper.configuration.logicalOutputDeviceDict);
                mapper.configuration.dirty = true;
            }
            refreshSoundGeneratorsListView();
            populateTreeViewWithSoundGeneratorsPatchesAndMappings(tvProgramPatches, soundGenTreeViewMode, true);

            bCreatingNewSoundGenerator         = false;
            pnlSoundGeneratorEdit.Visible      = false;
            pnlSoundGeneratorPatchEdit.Visible = false;
        }
Example #2
0
        public bool bind()
        {
            foreach (String key in logicalInputDeviceDict.Keys)
            {
                LogicalInputDevice device = logicalInputDeviceDict[key];
                if (device.bind() == false)
                {
                    return(false);
                }
            }

            // Resolve the Primary Input Device.  (If non defined, pick the first on in the dict.)
            if (primaryInputDeviceName == null && logicalInputDeviceDict.Count > 0)
            {
                primaryInputDeviceName = logicalInputDeviceDict.Keys.First <String>();
                dirty = true;
            }

            if (logicalInputDeviceDict.ContainsKey(primaryInputDeviceName))
            {
                primaryInputDevice = logicalInputDeviceDict[primaryInputDeviceName];
            }
            else
            {
                MessageBox.Show("Cannot find primary logical input device by configured name " + primaryInputDeviceName);
                return(false);
            }

            foreach (String key in logicalOutputDeviceDict.Keys)
            {
                LogicalOutputDevice device = logicalOutputDeviceDict[key];
                if (device.bind() == false)
                {
                    return(false);
                }
            }

            foreach (String key in soundGenerators.Keys)
            {
                SoundGenerator soundGenerator = soundGenerators[key];
                if (soundGenerator.bind(logicalOutputDeviceDict) == false)
                {
                    return(false);
                }
            }

            foreach (Mapping.PerDeviceChannelMapping perDeviceChannelMapping in globalControlMappings)
            {
                perDeviceChannelMapping.bind(logicalInputDeviceDict, soundGenerators);
            }

            foreach (String key in mappings.Keys)
            {
                Mapping mapping = mappings[key];
                if (mapping.bind(logicalInputDeviceDict, soundGenerators) == false)
                {
                    return(false);
                }
            }

            foreach (int bankAndProgram in midiPrograms.Keys)
            {
                MidiProgram midiProgram = midiPrograms[bankAndProgram];
                midiProgram.bind(logicalInputDeviceDict, soundGenerators, mappings, primaryInputDevice);
            }

            // Drop up any non-bound midiPrograms (ie, that point to mappings or SoundGeneratorPatches that no longer exist)
            List <MidiProgram> midiProgramListClone = midiPrograms.Values.ToList <MidiProgram>();

            foreach (MidiProgram midiProgram in midiProgramListClone)
            {
                if (midiProgram.mapping == null)
                {
                    midiPrograms.Remove(midiProgram.key);
                }
            }

            foreach (String songTitle in songDict.Keys)
            {
                Song song = songDict[songTitle];
                song.bind(logicalInputDeviceDict, soundGenerators, mappings, primaryInputDevice);
            }

            foreach (Setlist setlist in setlists)
            {
                setlist.bind(songDict, logicalInputDeviceDict, soundGenerators, mappings, primaryInputDevice);
            }


            if (primaryControllerButtonProgramNumbers.Count == 0)
            {
                int[] casioPx3Buttons = new int[8] {
                    0x0, 0x4, 0x5, 0x7, 0x12, 0x30, 0x19, 0x3D
                };
                primaryControllerButtonProgramNumbers.Add("CASIO USB-MIDI", casioPx3Buttons);
            }

            if (primaryControllerButtonProgramNumbers.ContainsKey(primaryInputDevice.device.Name))
            {
                currentPrimaryControllerButtonProgramNumbers = primaryControllerButtonProgramNumbers[primaryInputDevice.device.Name];
            }
            else
            {
                currentPrimaryControllerButtonProgramNumbers = new int[8] {
                    -1, -1, -1, -1, -1, -1, -1, -1
                };
            }

            return(true);
        }