public static void createTrialConfiguration(Dictionary <String, Mapping> mappings) { Mapping mapping = new Mapping(); mapping.name = "Rock Organ 1"; PerDeviceChannelMapping perDeviceChannelMapping = new PerDeviceChannelMapping(); perDeviceChannelMapping.logicalInputDeviceName = "Input Device 1"; perDeviceChannelMapping.inputDeviceChannel = 0; NoteMapping.createTrialConfiguration(2, perDeviceChannelMapping.noteMappings); MappingPatch.createTrialConfiguration(2, perDeviceChannelMapping.mappingPatches); PitchBendMapping.createTrialConfiguration(2, perDeviceChannelMapping.pitchBendMappings); ControlMapping.createTrialConfiguration(2, perDeviceChannelMapping.controlMappings); mapping.perDeviceChannelMappings.Add(perDeviceChannelMapping.key, perDeviceChannelMapping); mappings.Add(mapping.name, mapping); mapping = new Mapping(); mapping.name = "Vintage Vince"; perDeviceChannelMapping = new PerDeviceChannelMapping(); perDeviceChannelMapping.logicalInputDeviceName = "Input Device 1"; perDeviceChannelMapping.inputDeviceChannel = 0; NoteMapping.createTrialConfiguration(3, perDeviceChannelMapping.noteMappings); MappingPatch.createTrialConfiguration(3, perDeviceChannelMapping.mappingPatches); PitchBendMapping.createTrialConfiguration(3, perDeviceChannelMapping.pitchBendMappings); ControlMapping.createTrialConfiguration(3, perDeviceChannelMapping.controlMappings); mapping.perDeviceChannelMappings.Add(perDeviceChannelMapping.key, perDeviceChannelMapping); mappings.Add(mapping.name, mapping); }
public static void createTrialConfiguration(int whichMappingToCreate, List <MappingPatch> mappingPatches) { MappingPatch mappingPatch = new MappingPatch(); switch (whichMappingToCreate) { case 2: mappingPatch.soundGeneratorName = "VB3"; mappingPatch.soundGeneratorRelativeChannel = 0; mappingPatch.patchName = "Rock Organ 1"; mappingPatches.Add(mappingPatch); break; case 3: mappingPatch.soundGeneratorName = "SuperWave P8"; mappingPatch.soundGeneratorRelativeChannel = 0; mappingPatch.patchName = "Vintage Vince"; mappingPatches.Add(mappingPatch); break; default: MessageBox.Show("Unknown trial configuration mappingPatch requested: " + whichMappingToCreate); break; } }
virtual public bool bind(Dictionary <String, LogicalInputDevice> logicalInputDeviceDict, Dictionary <String, SoundGenerator> soundGenerators, Dictionary <String, Mapping> mappings, LogicalInputDevice primaryInputDevice) { // Find or create a Mapping for this MidiProgram that it will point to if (bSingle == false) // If it's not a single, then it's a mapping, so just find the one named. { if (mappings.ContainsKey(this.MappingName)) { mapping = mappings[this.MappingName]; return(true); } else { MessageBox.Show("MidiProgram Mapping " + this.MappingName + " not defined in this configuration."); return(false); } } else { // If it's a single, then we create a mapping on the fly for it. mapping = new Mapping(); String candidateName = "(S) " + this.SinglePatchName; if (mappings.ContainsKey(candidateName)) { // Patch Name alone isn't a unique mapping name. Fully qualify it with the SG name too. candidateName = "(S) " + this.SingleSoundGeneratorName + " - " + this.SinglePatchName; } mapping.name = candidateName; // Create a single mapping with some settings values on the fly Mapping.PerDeviceChannelMapping perDeviceChannelMapping = new Mapping.PerDeviceChannelMapping(); perDeviceChannelMapping.logicalInputDeviceName = primaryInputDevice.logicalDeviceName; perDeviceChannelMapping.inputDeviceChannel = 0; NoteMapping noteMapping = new NoteMapping(); noteMapping.soundGeneratorName = this.SingleSoundGeneratorName; noteMapping.soundGeneratorRelativeChannel = 0; noteMapping.lowestNote = 0; noteMapping.highestNote = 127; noteMapping.pitchOffset = 0; perDeviceChannelMapping.noteMappings.Add(noteMapping); MappingPatch mappingPatch = new MappingPatch(); mappingPatch.soundGeneratorName = this.SingleSoundGeneratorName; mappingPatch.soundGeneratorRelativeChannel = 0; mappingPatch.patchName = this.SinglePatchName; perDeviceChannelMapping.mappingPatches.Add(mappingPatch); PitchBendMapping pitchBendMapping = new PitchBendMapping(); pitchBendMapping.soundGeneratorName = this.SingleSoundGeneratorName; pitchBendMapping.soundGeneratorRelativeChannel = 0; pitchBendMapping.scale = 1.0; perDeviceChannelMapping.pitchBendMappings.Add(pitchBendMapping); ControlMapping controlMapping = new ControlMapping(); controlMapping.soundGeneratorName = this.SingleSoundGeneratorName; controlMapping.soundGeneratorRelativeChannel = 0; controlMapping.sourceControlNumber = 1; // Mod Wheel controlMapping.mappedControlNumber = 1; controlMapping.min = 0; controlMapping.max = 127; controlMapping.initialValue = -1; perDeviceChannelMapping.controlMappings.Add(controlMapping); controlMapping = new ControlMapping(); controlMapping.soundGeneratorName = this.SingleSoundGeneratorName; controlMapping.soundGeneratorRelativeChannel = 0; controlMapping.sourceControlNumber = -1; controlMapping.mappedControlNumber = 7; // Vol controlMapping.min = 0; controlMapping.max = 127; controlMapping.initialValue = 127; perDeviceChannelMapping.controlMappings.Add(controlMapping); controlMapping = new ControlMapping(); controlMapping.soundGeneratorName = this.SingleSoundGeneratorName; controlMapping.soundGeneratorRelativeChannel = 0; controlMapping.sourceControlNumber = 64; // Damper controlMapping.mappedControlNumber = 64; controlMapping.min = 0; controlMapping.max = 127; controlMapping.initialValue = -1; perDeviceChannelMapping.controlMappings.Add(controlMapping); // Kurzweil Artis Variation Button... controlMapping = new ControlMapping(); controlMapping.soundGeneratorName = this.SingleSoundGeneratorName; controlMapping.soundGeneratorRelativeChannel = 0; controlMapping.sourceControlNumber = 0x1D; controlMapping.mappedControlNumber = 0x1D; controlMapping.min = 0; controlMapping.max = 127; controlMapping.initialValue = -1; perDeviceChannelMapping.controlMappings.Add(controlMapping); mapping.perDeviceChannelMappings.Add(perDeviceChannelMapping.key, perDeviceChannelMapping); return(mapping.bind(logicalInputDeviceDict, soundGenerators)); } }
override public bool bind(Dictionary <String, LogicalInputDevice> logicalInputDeviceDict, Dictionary <String, SoundGenerator> soundGenerators) { // Builds out an actual Mapping based on the SimpleMapping. Dictionary <String, int> soundGeneratorChannelAssignments = new Dictionary <string, int>(); perDeviceChannelMappings.Clear(); foreach (PerDeviceSimpleMapping perDeviceSimpleMapping in perDeviceSimpleMappings) { Mapping.PerDeviceChannelMapping perDeviceChannelMapping = new Mapping.PerDeviceChannelMapping(perDeviceSimpleMapping.inputDeviceName, perDeviceSimpleMapping.inputDeviceChannel); foreach (SimpleMappingDefinition simpleMappingDefinition in perDeviceSimpleMapping.simpleMappingDefinitions) { NoteMapping noteMapping = new NoteMapping(); String soundGeneratorName = simpleMappingDefinition.soundGeneratorName; noteMapping.soundGeneratorName = soundGeneratorName; int soundGeneratorRelativeChannel = 0; if (soundGeneratorChannelAssignments.ContainsKey(soundGeneratorName)) { soundGeneratorRelativeChannel = soundGeneratorChannelAssignments[soundGeneratorName] + 1; soundGeneratorChannelAssignments[soundGeneratorName] = soundGeneratorRelativeChannel; } else { soundGeneratorRelativeChannel = 0; soundGeneratorChannelAssignments.Add(soundGeneratorName, 0); } noteMapping.soundGeneratorRelativeChannel = soundGeneratorRelativeChannel; if (perDeviceSimpleMapping.splitPoint == -1) { noteMapping.highestNote = 127; noteMapping.lowestNote = 0; } else if (simpleMappingDefinition.bLower == true) { noteMapping.highestNote = perDeviceSimpleMapping.splitPoint - 1; noteMapping.lowestNote = 0; } else { noteMapping.highestNote = 127; noteMapping.lowestNote = perDeviceSimpleMapping.splitPoint; } noteMapping.pitchOffset = simpleMappingDefinition.transpose; perDeviceChannelMapping.noteMappings.Add(noteMapping); MappingPatch mappingPatch = new MappingPatch(); mappingPatch.patchName = simpleMappingDefinition.programName; mappingPatch.soundGeneratorName = soundGeneratorName; mappingPatch.soundGeneratorRelativeChannel = soundGeneratorRelativeChannel; perDeviceChannelMapping.mappingPatches.Add(mappingPatch); if (simpleMappingDefinition.pbScale != 0) { PitchBendMapping pitchBendMapping = new PitchBendMapping(); pitchBendMapping.soundGeneratorName = soundGeneratorName; pitchBendMapping.soundGeneratorRelativeChannel = soundGeneratorRelativeChannel; pitchBendMapping.scale = simpleMappingDefinition.pbScale; perDeviceChannelMapping.pitchBendMappings.Add(pitchBendMapping); } if (simpleMappingDefinition.bEnaVolControl == true || simpleMappingDefinition.initialVolume >= 0) { // This may be a mapping only, it may be an initial value setting only, or it may be both ControlMapping ctlMapping = new ControlMapping(); ctlMapping.soundGeneratorName = soundGeneratorName; ctlMapping.soundGeneratorRelativeChannel = soundGeneratorRelativeChannel; ctlMapping.sourceControlNumber = (simpleMappingDefinition.bEnaVolControl == true) ? 7 : -1; ctlMapping.mappedControlNumber = 7; ctlMapping.initialValue = (simpleMappingDefinition.initialVolume >= 0) ? simpleMappingDefinition.initialVolume : 127; perDeviceChannelMapping.controlMappings.Add(ctlMapping); } if (simpleMappingDefinition.bEnaModControl == true) { ControlMapping ctlMapping = new ControlMapping(); ctlMapping.soundGeneratorName = soundGeneratorName; ctlMapping.soundGeneratorRelativeChannel = soundGeneratorRelativeChannel; ctlMapping.sourceControlNumber = 1; ctlMapping.mappedControlNumber = 1; ctlMapping.initialValue = 0; perDeviceChannelMapping.controlMappings.Add(ctlMapping); } if (simpleMappingDefinition.bEnaDamperControl == true) { ControlMapping ctlMapping = new ControlMapping(); ctlMapping.soundGeneratorName = soundGeneratorName; ctlMapping.soundGeneratorRelativeChannel = soundGeneratorRelativeChannel; ctlMapping.sourceControlNumber = 64; ctlMapping.mappedControlNumber = simpleMappingDefinition.damperRemap; ctlMapping.bToggle = simpleMappingDefinition.bDamplerToggle; // Special option for damper: toggle mode: ie for Leslie ctl. ctlMapping.initialValue = 0; perDeviceChannelMapping.controlMappings.Add(ctlMapping); } { // Kurzweil Artis Variation Button ControlMapping ctlMapping = new ControlMapping(); ctlMapping.soundGeneratorName = soundGeneratorName; ctlMapping.soundGeneratorRelativeChannel = soundGeneratorRelativeChannel; ctlMapping.sourceControlNumber = 0x1D; ctlMapping.mappedControlNumber = 0x1D; ctlMapping.initialValue = 0; perDeviceChannelMapping.controlMappings.Add(ctlMapping); } } perDeviceChannelMappings.Add(perDeviceChannelMapping.key, perDeviceChannelMapping); } return(base.bind(logicalInputDeviceDict, soundGenerators)); }