Exemplo n.º 1
0
        private void lvSoundGenerators_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection selectedItems = lvSoundGenerators.SelectedItems;
            if (selectedItems.Count > 0)
            {
                soundGeneratorBeingEdited = new SoundGenerator((SoundGenerator)selectedItems[0].Tag);

                tbSoundGeneratorName.Text          = soundGeneratorBeingEdited.name;
                cbSoundGeneratorDeviceName.Text    = soundGeneratorBeingEdited.deviceName;
                nudSoundGeneratorBaseChannel.Value = soundGeneratorBeingEdited.channelBase + 1;
                nudSoundGeneratorNumChannels.Value = soundGeneratorBeingEdited.nChannels;
                nudVolMin.Value = soundGeneratorBeingEdited.cc7Min;
                nudVolMax.Value = soundGeneratorBeingEdited.cc7Max;

                lbSoundGeneratorPatches.Items.Clear();
                foreach (SoundGeneratorPatch patch in soundGeneratorBeingEdited.soundGeneratorPatchDict.Values)
                {
                    lbSoundGeneratorPatches.Items.Add(patch.name);
                }

                refreshCbSoundGeneratorDeviceName(null);

                bCreatingNewSoundGenerator = false;

                pnlSoundGeneratorEdit.Visible = true;
            }
        }
Exemplo n.º 2
0
        //**************************************************************************
        // Sound Generators tab
        //**************************************************************************

        private void refreshSoundGeneratorsListView()
        {
            lvSoundGenerators.Items.Clear();

            List <String> soundGeneratorNames = new List <String>(mapper.configuration.soundGenerators.Keys);

            soundGeneratorNames.Sort();

            foreach (String soundGeneratorName in soundGeneratorNames)
            {
                SoundGenerator sg = mapper.configuration.soundGenerators[soundGeneratorName];

                ListViewItem item = new ListViewItem(sg.name);
                item.Tag = sg;
                ListViewItem.ListViewSubItem siLogicalOutputDevice = new ListViewItem.ListViewSubItem(item, sg.deviceName);
                item.SubItems.Add(siLogicalOutputDevice);
                ListViewItem.ListViewSubItem siLogicalBaseChannel = new ListViewItem.ListViewSubItem(item, String.Format("{0}", sg.channelBase + 1));
                item.SubItems.Add(siLogicalBaseChannel);
                ListViewItem.ListViewSubItem siNumChannels = new ListViewItem.ListViewSubItem(item, String.Format("{0}", sg.nChannels));
                item.SubItems.Add(siNumChannels);

                lvSoundGenerators.Items.Add(item);
            }

            cbSoundGeneratorPatchCategory.Items.Clear();
            cbSoundGeneratorPatchCategory.Items.AddRange(mapper.configuration.patchCategories.ToArray());
        }
Exemplo n.º 3
0
        // Populates a treeview with either SoundGenerators/SoundGeneratorPatches (mode="SG") or Categories/SoundGeneratorPatches (mode="Cat")
        //  Presently used by both Random Access and Song tabs.
        private void populateTreeViewWithSoundGeneratorsPatchesAndMappings(TreeView tv, String mode, bool bIncludeMappings)
        {
            tv.Nodes.Clear();

            if (mode.Equals("Cat"))
            {
                foreach (KeyValuePair <String, List <SoundGeneratorPatch> > categoryEntry in mapper.configuration.soundGeneratorPatchesByCategory)
                {
                    TreeNode categoryNode = new TreeNode(categoryEntry.Key);
                    foreach (SoundGeneratorPatch patch in categoryEntry.Value)
                    {
                        TreeNode sgPatch = new TreeNode(patch.name + " - " + patch.soundGenerator.name);
                        sgPatch.Tag = patch;
                        categoryNode.Nodes.Add(sgPatch);
                    }
                    tv.Nodes.Add(categoryNode);
                }
            }
            else
            {
                foreach (String soundGeneratorName in mapper.configuration.soundGenerators.Keys)
                {
                    SoundGenerator soundGenerator = mapper.configuration.soundGenerators[soundGeneratorName];
                    TreeNode       sgNode         = new TreeNode(soundGeneratorName);
                    sgNode.Tag = soundGenerator;
                    foreach (String soundGeneratorPatchName in soundGenerator.soundGeneratorPatchDict.Keys)
                    {
                        SoundGeneratorPatch soundGeneratorPatch = soundGenerator.soundGeneratorPatchDict[soundGeneratorPatchName];
                        TreeNode            sgpNode             = new TreeNode(soundGeneratorPatchName);
                        sgpNode.Tag = soundGeneratorPatch;
                        sgNode.Nodes.Add(sgpNode);
                    }
                    tv.Nodes.Add(sgNode);
                }
            }

            // Mappings are optionally added under a single heading. (I'm not categorizing mappings because they may draw together patches from multiple categories.)
            if (bIncludeMappings)
            {
                TreeNode      mappingsNode       = new TreeNode("Mappings");
                List <String> sortedMappingNames = new List <String>(mapper.configuration.mappings.Keys);
                sortedMappingNames.Sort();

                foreach (String mappingName in sortedMappingNames)
                {
                    Mapping  mapping     = mapper.configuration.mappings[mappingName];
                    TreeNode mappingNode = new TreeNode(mappingName);
                    mappingNode.Tag = mapping;
                    mappingsNode.Nodes.Add(mappingNode);
                }
                tv.Nodes.Add(mappingsNode);
            }
        }
Exemplo n.º 4
0
        public SoundGenerator(SoundGenerator original)
        {
            name        = original.name;
            deviceName  = original.deviceName;
            nChannels   = original.nChannels;
            channelBase = original.channelBase;
            cc7Max      = original.cc7Max;
            cc7Min      = original.cc7Min;

            foreach (String patchName in original.soundGeneratorPatchDict.Keys)
            {
                soundGeneratorPatchDict.Add(patchName, new SoundGeneratorPatch(original.soundGeneratorPatchDict[patchName]));
            }
        }
Exemplo n.º 5
0
        public void NoteOn(NoteOnMessage msg)
        {
            // Find the per-device/channel mappings for the message's Device/Channel.  If there's none, nothing to do.
            String deviceKey = Mapping.PerDeviceChannelMapping.createKey(msg.Device.Name, (int)msg.Channel);

            if (!m_perDeviceChannelMappings.ContainsKey(deviceKey))
            {
                return;
            }
            Mapping.PerDeviceChannelMapping perDeviceChannelMapping = m_perDeviceChannelMappings[deviceKey];

            // Iterate over the NoteMappings for this device/channel
            foreach (NoteMapping mapping in perDeviceChannelMapping.noteMappings)
            {
                // See if the note received is in range for the NoteMapping currently under consideration
                if (msg.Pitch >= (Pitch)mapping.lowestNote && msg.Pitch <= (Pitch)mapping.highestNote)
                {
                    // It is.
                    // Create mapped note record
                    MappedNote mappedNoteRecord = new MappedNote();
                    mappedNoteRecord.sourceDeviceName = msg.Device.Name;
                    mappedNoteRecord.sourceChannel    = msg.Channel;
                    mappedNoteRecord.origNote         = msg.Pitch;
                    SoundGenerator soundGenerator = mapping.soundGenerator;
                    mappedNoteRecord.mappedDevice  = soundGenerator.device;
                    mappedNoteRecord.mappedChannel = (Channel)mapping.soundGeneratorPhysicalChannel;
                    mappedNoteRecord.mappedNote    = msg.Pitch + mapping.pitchOffset + masterTranspose;

                    if (mappedNoteRecord.mappedNote < 0 || mappedNoteRecord.mappedNote > (Pitch)127)
                    {
                        continue;
                    }

                    // See if this note is already sounding.  Look it up based on it's unmapped device, channel and note#.
                    MappedNote matchingMappedNoteAlreadySounding = FindMappedNote(mappedNoteRecord);
                    if (matchingMappedNoteAlreadySounding != null)
                    {
                        matchingMappedNoteAlreadySounding.mappedDevice.SendNoteOff(matchingMappedNoteAlreadySounding.mappedChannel, matchingMappedNoteAlreadySounding.mappedNote, 127);
                        m_mappedNotesList.Remove(matchingMappedNoteAlreadySounding);
                    }

                    // Now, play the new mapping of the source note.
                    mappedNoteRecord.mappedDevice.SendNoteOn(mappedNoteRecord.mappedChannel, mappedNoteRecord.mappedNote, msg.Velocity);

                    // And add it to the dictionary of sounding notes.
                    m_mappedNotesList.Add(mappedNoteRecord);
                }
            }
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
        private void btnAddSoundGenerator_Click(object sender, EventArgs e)
        {
            soundGeneratorBeingEdited = new SoundGenerator();

            tbSoundGeneratorName.Text          = "";
            cbSoundGeneratorDeviceName.Text    = "";
            nudSoundGeneratorBaseChannel.Value = 1;
            nudSoundGeneratorNumChannels.Value = 1;
            nudVolMax.Value = 127;
            nudVolMin.Value = 0;
            refreshCbSoundGeneratorDeviceName(null);
            lbSoundGeneratorPatches.Items.Clear();

            bCreatingNewSoundGenerator = true;

            pnlSoundGeneratorEdit.Visible = true;
        }
Exemplo n.º 8
0
        public void createTrialConfiguration()
        {
            dirty = true;

            try
            {
                Mapping.PerDeviceChannelMapping globalPerInputDeviceChannelMapping = new Mapping.PerDeviceChannelMapping();
                globalPerInputDeviceChannelMapping.logicalInputDeviceName = "Input Device 1";
                globalPerInputDeviceChannelMapping.inputDeviceChannel     = 0;

                ControlMapping globalControlMapping = new ControlMapping();
                globalControlMapping.soundGeneratorName            = "Reaper";
                globalControlMapping.soundGeneratorRelativeChannel = 0;
                globalControlMapping.sourceControlNumber           = 75; // Top Left Rotary Knob on Oxygen
                globalControlMapping.mappedControlNumber           = 9;  // I've got Reaper Master Volume mapped to this.
                globalControlMapping.min = 30;                           // This provides a nice workable vol range
                globalControlMapping.max = 91;
                globalPerInputDeviceChannelMapping.controlMappings.Add(globalControlMapping);

                globalControlMappings.Add(globalPerInputDeviceChannelMapping);

                primaryInputDeviceName = "Input Device 1";

                LogicalInputDevice.createTrialConfiguration(logicalInputDeviceDict);

                LogicalOutputDevice.createTrialConfiguration(logicalOutputDeviceDict);

                SoundGenerator.createTrialConfiguration(soundGenerators);

                Mapping.createTrialConfiguration(mappings);

                MidiProgram.createTrialConfiguration(midiPrograms);

                Setlist.createTrialConfiguration(songDict, setlists);
            }
            catch (Exception e)
            {
                MessageBox.Show("Exception creating trial configurations: " + e);
            }
        }
Exemplo n.º 9
0
        public virtual bool bind(Dictionary <String, SoundGenerator> soundGenerators)
        {
            if (soundGenerators.ContainsKey(soundGeneratorName))
            {
                soundGenerator = soundGenerators[soundGeneratorName];

                if (soundGeneratorRelativeChannel >= 0 && soundGeneratorRelativeChannel < soundGenerator.nChannels)
                {
                    soundGeneratorPhysicalChannel = soundGeneratorRelativeChannel + soundGenerator.channelBase;
                    return(true);
                }
                else
                {
                    MessageBox.Show("Illegal soundGeneratorRelativeChannel of " + soundGeneratorRelativeChannel + " in mappping");
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        public static void createTrialConfiguration(Dictionary <String, SoundGenerator> soundGenerators)
        {
            // SoundGenerators
            SoundGenerator soundGenerator = new SoundGenerator();

            soundGenerator.name        = "Proteus VX";
            soundGenerator.deviceName  = "Output Device 1";
            soundGenerator.nChannels   = 2;
            soundGenerator.channelBase = 0;

            SoundGeneratorPatch patch = new SoundGeneratorPatch();

            patch.name = "Dynamic Grand";
            patch.patchCategoryName         = "Pianos";
            patch.soundGeneratorBank        = -1;
            patch.soundGeneratorPatchNumber = 0;
            soundGenerator.soundGeneratorPatchDict.Add(patch.name, patch);

            patch      = new SoundGeneratorPatch();
            patch.name = "EP-3";
            patch.patchCategoryName         = "EPs";
            patch.soundGeneratorBank        = -1;
            patch.soundGeneratorPatchNumber = 62;
            soundGenerator.soundGeneratorPatchDict.Add(patch.name, patch);

            patch      = new SoundGeneratorPatch();
            patch.name = "EP-2";
            patch.patchCategoryName         = "EPs";
            patch.soundGeneratorBank        = -1;
            patch.soundGeneratorPatchNumber = 61;
            soundGenerator.soundGeneratorPatchDict.Add(patch.name, patch);

            patch      = new SoundGeneratorPatch();
            patch.name = "Clavinetti";
            patch.patchCategoryName         = "EPs";
            patch.soundGeneratorBank        = -1;
            patch.soundGeneratorPatchNumber = 19;
            soundGenerator.soundGeneratorPatchDict.Add(patch.name, patch);

            soundGenerators.Add(soundGenerator.name, soundGenerator);

            soundGenerator             = new SoundGenerator();
            soundGenerator.name        = "VB3";
            soundGenerator.deviceName  = "Output Device 1";
            soundGenerator.nChannels   = 2;
            soundGenerator.channelBase = 2;

            patch      = new SoundGeneratorPatch();
            patch.name = "Rock Organ 1";
            patch.patchCategoryName         = "Organs";
            patch.soundGeneratorBank        = -1;
            patch.soundGeneratorPatchNumber = 0;
            soundGenerator.soundGeneratorPatchDict.Add(patch.name, patch);

            soundGenerators.Add(soundGenerator.name, soundGenerator);

            soundGenerator             = new SoundGenerator();
            soundGenerator.name        = "SuperWave P8";
            soundGenerator.deviceName  = "Output Device 1";
            soundGenerator.nChannels   = 1;
            soundGenerator.channelBase = 4;

            patch      = new SoundGeneratorPatch();
            patch.name = "Vintage Vince";
            patch.patchCategoryName         = "Polysynths";
            patch.soundGeneratorBank        = -1;
            patch.soundGeneratorPatchNumber = 39;
            soundGenerator.soundGeneratorPatchDict.Add(patch.name, patch);

            soundGenerators.Add(soundGenerator.name, soundGenerator);


            // For controlling VST Host
            soundGenerator             = new SoundGenerator();
            soundGenerator.name        = "Reaper";
            soundGenerator.deviceName  = "Output Device 1";
            soundGenerator.nChannels   = 1;
            soundGenerator.channelBase = 15;

            soundGenerators.Add(soundGenerator.name, soundGenerator);
        }
Exemplo n.º 12
0
 public bool Equals(SoundGenerator other)
 {
     return(name.Equals(other.name));
 }
Exemplo n.º 13
0
 public void bind(SoundGenerator _soundGenerator)
 {
     soundGenerator = _soundGenerator;
 }