public SoundGeneratorPatch(SoundGeneratorPatch orig) { name = orig.name; patchCategoryName = orig.patchCategoryName; soundGeneratorBank = orig.soundGeneratorBank; soundGeneratorPatchNumber = orig.soundGeneratorPatchNumber; }
private void lbMappingDevicePatches_DragDrop(object sender, DragEventArgs e) { Console.WriteLine("btnRandAccessCol DragDrop: " + e); if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { TreeNode droppedNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); if (droppedNode.Tag is SoundGeneratorPatch) { SoundGeneratorPatch soundGeneratorPatch = (SoundGeneratorPatch)droppedNode.Tag; if (sender is ListBox) { ListBox receivingListBox = (ListBox)sender; // The list boxes are not populated with SoundGeneratorPatches, but with SimpleMappingDefinitions derived from them. SimpleMapping.SimpleMappingDefinition mappingDefinition = new SimpleMapping.SimpleMappingDefinition(); mappingDefinition.programName = soundGeneratorPatch.name; mappingDefinition.soundGeneratorName = soundGeneratorPatch.soundGenerator.name; mappingDefinition.transpose = 0; mappingDefinition.pbScale = 1.0F; mappingDefinition.bLower = receivingListBox.Name.Contains("Lower"); receivingListBox.Items.Add(mappingDefinition); } } } }
private void btnSoundGeneratorPatchEditOK_Click(object sender, EventArgs e) { SoundGeneratorPatch patch = new SoundGeneratorPatch(); patch.name = tbSoundGeneratorPatchName.Text; patch.patchCategoryName = cbSoundGeneratorPatchCategory.Text; patch.soundGeneratorBank = (int)nudSoundGeneratorPatchBankNo.Value; patch.soundGeneratorPatchNumber = (int)nudSoundGeneratorPatchProgramNo.Value; if (creatingNewSoundGeneratorPatch == true && soundGeneratorBeingEdited.soundGeneratorPatchDict.ContainsKey(patch.name)) { MessageBox.Show("Patch Name " + patch.name + " already in use in this Sound Generator"); return; } if (creatingNewSoundGeneratorPatch == true) { soundGeneratorBeingEdited.soundGeneratorPatchDict.Add(patch.name, patch); } else { soundGeneratorBeingEdited.soundGeneratorPatchDict[patch.name] = patch; } refreshLbSoundGeneratorPatches(); pnlSoundGeneratorPatchEdit.Visible = false; }
// 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); } }
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; }
private void lbSoundGeneratorPatches_SelectedIndexChanged(object sender, EventArgs e) { if (lbSoundGeneratorPatches.SelectedItem != null) { String selectedSoundGeneratorPatchName = (String)lbSoundGeneratorPatches.SelectedItem; SoundGeneratorPatch patch = soundGeneratorBeingEdited.soundGeneratorPatchDict[selectedSoundGeneratorPatchName]; tbSoundGeneratorPatchName.Text = patch.name; tbSoundGeneratorPatchName.Enabled = false; cbSoundGeneratorPatchCategory.Text = patch.patchCategoryName; nudSoundGeneratorPatchBankNo.Value = patch.soundGeneratorBank; nudSoundGeneratorPatchProgramNo.Value = patch.soundGeneratorPatchNumber; pnlSoundGeneratorPatchEdit.Visible = true; creatingNewSoundGeneratorPatch = false; } }
public override bool bind(Dictionary <String, SoundGenerator> soundGenerators) { if (base.bind(soundGenerators) == false) { return(false); } if (soundGenerator.soundGeneratorPatchDict.ContainsKey(patchName)) { SoundGeneratorPatch soundGeneratorPatch = soundGenerator.soundGeneratorPatchDict[patchName]; bank = soundGeneratorPatch.soundGeneratorBank; patchNumber = soundGeneratorPatch.soundGeneratorPatchNumber; return(true); } else { return(false); } }
public bool bind(Dictionary <String, LogicalOutputDevice> logicalOutputDeviceDict) { cc7Scale = ((double)cc7Max - (double)cc7Min) / (double)127; // The portion of 127 of the actual output range if (logicalOutputDeviceDict.ContainsKey(deviceName)) { this.device = logicalOutputDeviceDict[deviceName].device; foreach (String key in soundGeneratorPatchDict.Keys) { SoundGeneratorPatch patch = soundGeneratorPatchDict[key]; patch.bind(this); } return(true); } else { this.device = null; return(false); } }
//-------------------------------------------------------------------------------- // When you click on a program in the Programs treeview that program is activated. //-------------------------------------------------------------------------------- private void tvProgramPatches_Click(object sender, EventArgs e) { TreeNode node = tvProgramPatches.SelectedNode; if (node != null) { if (node.Tag is SoundGenerator) { // Route out to this SG, but send no program change... // Allows user to select an SG and then set sound directly from it. Useful during configuration. } else if (node.Tag is SoundGeneratorPatch) { // Create an MidiProgram that won't be assigned to any buttons. Use it to formulate a Mapping and make that the current Mapping. SoundGeneratorPatch soundGeneratorPatch = (SoundGeneratorPatch)node.Tag; MidiProgram midiProgram = new MidiProgram(); midiProgram.bSingle = true; midiProgram.SingleSoundGeneratorName = soundGeneratorPatch.soundGenerator.name; midiProgram.SinglePatchName = soundGeneratorPatch.name; // Determine the input device for this midiProgram: the tab's currently selected input device LogicalInputDevice deviceForThisMidiProgram = mapper.configuration.primaryInputDevice; if (tabControl1.SelectedTab.Tag != null && tabControl1.SelectedTab.Tag is LogicalInputDevice) { deviceForThisMidiProgram = (LogicalInputDevice)tabControl1.SelectedTab.Tag; } // Have the midiProgram flesh out its inner details midiProgram.bind(mapper.configuration.logicalInputDeviceDict, mapper.configuration.soundGenerators, mapper.configuration.mappings, deviceForThisMidiProgram); mapper.SetMapping(midiProgram.mapping); } else if (node.Tag is Mapping) { Mapping mapping = (Mapping)node.Tag; mapper.SetMapping(mapping); } } }
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); }
public MidiProgram(SoundGeneratorPatch patch) { bSingle = true; SinglePatchName = patch.name; SingleSoundGeneratorName = patch.soundGenerator.name; }
private void btnPatchEditOK_Click(object sender, EventArgs e) { TreeNode node = tvSongPatchPatches.SelectedNode; if (node == null) { MessageBox.Show("You must pick a patch"); return; } songProgramBeingEdited.part = tbSongPatchPart.Text; songProgramBeingEdited.myBankNumber = (int)nudSongPatchBank.Value; songProgramBeingEdited.myPatchNumber = (int)nudSongPatchProgramNo.Value; Object patchOrMapping = node.Tag; if (patchOrMapping is SoundGeneratorPatch) { songProgramBeingEdited.bSingle = true; SoundGeneratorPatch patch = (SoundGeneratorPatch)patchOrMapping; songProgramBeingEdited.SinglePatchName = patch.name; TreeNode parent = node.Parent; if (parent == null) { MessageBox.Show("Bug: Null Sound Generator in Tree View"); } songProgramBeingEdited.SingleSoundGeneratorName = ((SoundGenerator)parent.Tag).name; songProgramBeingEdited.MappingName = null; } else if (patchOrMapping is Mapping) { songProgramBeingEdited.bSingle = false; Mapping mapping = (Mapping)patchOrMapping; songProgramBeingEdited.MappingName = mapping.name; songProgramBeingEdited.SinglePatchName = null; songProgramBeingEdited.SingleSoundGeneratorName = null; } else { MessageBox.Show("You've picked a Sound Generator. Instead, pick one of its patches"); return; } songProgramBeingEdited.bind(mapper.configuration.logicalInputDeviceDict, mapper.configuration.soundGenerators, mapper.configuration.mappings, mapper.configuration.primaryInputDevice); if (creatingNewSongProgram == true) { songBeingEdited.programs.Add(songProgramBeingEdited); } else { songBeingEdited.programs[originalSongProgramIndex] = songProgramBeingEdited; } refreshLbSongPatches(); pnlSongEdit.Enabled = true; pnlPatchEdit.Visible = false; }