protected IMappingEntry Factory_IMappingEntry_MapsIdenticalMidiMsgRanges( MssMsgType msgType, int chanRangeBottom, int chanRamgeTop, int paramRangeBottom, int paramRangeTop) { MssMsgRange inMsgRange = new MssMsgRange(); inMsgRange.InitPublicMembers(msgType, chanRangeBottom, chanRamgeTop, paramRangeBottom, paramRangeTop); MssMsgRange outMsgRange = new MssMsgRange(); outMsgRange.InitPublicMembers(msgType, chanRangeBottom, chanRamgeTop, paramRangeBottom, paramRangeTop); IMappingEntry mapEntry = new MappingEntry(); mapEntry.InMssMsgRange = inMsgRange; mapEntry.OutMssMsgRange = outMsgRange; mapEntry.OverrideDuplicates = DEFAULT_OVERRIDE_DUPLICATES; CurveShapeInfo curveInfo = new CurveShapeInfo(); curveInfo.InitWithDefaultValues(); mapEntry.CurveShapeInfo = curveInfo; return(mapEntry); }
/// <summary> /// populate mappingEntry's members based on the information in genInfo /// </summary> protected void InitializeEntryFromGenInfo(GenEntryConfigInfo genInfo, int id, IGeneratorMappingEntry mappingEntry) { //Sets mappingEntry.Id mappingEntry.Id = id; //Sets mappingEntry.GeneratorInfo mappingEntry.GenConfigInfo = genInfo; //Sets mappingEntry.inMsgRange IMssMsgRange inMsgRange = new MssMsgRange(); switch (genInfo.PeriodType) { case GenPeriodType.Bars: case GenPeriodType.BeatSynced: inMsgRange.InitPublicMembers(MssMsgType.RelBarPeriodPos, id, MssMsgUtil.UNUSED_MSS_MSG_DATA); break; case GenPeriodType.Time: inMsgRange.InitPublicMembers(MssMsgType.RelTimePeriodPos, id, MssMsgUtil.UNUSED_MSS_MSG_DATA); break; default: //Unknown period type Debug.Assert(false); break; } mappingEntry.InMssMsgRange = inMsgRange; //Sets mappingEntry.outMsgRange IMssMsgRange outMsgRange = new MssMsgRange(); outMsgRange.InitPublicMembers(MssMsgType.Generator, id, MssMsgUtil.UNUSED_MSS_MSG_DATA); mappingEntry.OutMssMsgRange = outMsgRange; //Sets mappingEntry.OverrideDuplicates mappingEntry.OverrideDuplicates = false; //Sets mappingEntry.CurveShapeInfo. This function is also used to reinitialize //mappingEntry so sometimes CurveShapeInfo will already be initialized. if (mappingEntry.CurveShapeInfo == null) { mappingEntry.CurveShapeInfo = new CurveShapeInfo(); mappingEntry.CurveShapeInfo.InitWithDefaultValues(); } }
protected IMappingEntry Factory_IMappingEntry( MssMsgType inMsgType, int inData1Bottom, int inData1Top, int inData2Bottom, int inData2Top, MssMsgType outMsgType, int outData1Bottom, int outData1Top, int outData2Bottom, int outData2Top) { MssMsgRange inMsgRange = new MssMsgRange(); inMsgRange.InitPublicMembers(inMsgType, inData1Bottom, inData1Top, inData2Bottom, inData2Top); MssMsgRange outMsgRange = new MssMsgRange(); outMsgRange.InitPublicMembers(outMsgType, outData1Bottom, outData1Top, outData2Bottom, outData2Top); IMappingEntry mappingEntry = new MappingEntry(); mappingEntry.InitAllMembers(inMsgRange, outMsgRange, false, DEFAULT_CURVE_SHAPE_INFO); return(mappingEntry); }
/// <summary> /// Event handler for MssEvents coming /// </summary> /// <param name="dryMssEvent"></param> protected void dryMssEventOutputPort_DryMssEventRecieved(MssEvent dryMssEvent) { if (this.InvokeRequired) { this.BeginInvoke(new Action<MssEvent>(dryMssEventOutputPort_DryMssEventRecieved), dryMssEvent); return; } MssMsg curMsg = dryMssEvent.mssMsg; if (this.learnMode != LearnMode.Off && curMsg.Type != MssMsgType.NoteOff && curMsg.Type != MssMsgType.Generator) { if (curMsg.Type == MssMsgType.NoteOn) { curMsg.Type = MssMsgType.Note; } ComboBox curTypeCombo = null; if (this.learnMode == LearnMode.In) { curTypeCombo = this.inTypeCombo; } else if (this.learnMode == LearnMode.Out) { curTypeCombo = this.outTypeCombo; } else { //Unknown learn mode Debug.Assert(false); return; } string newTypeName = MssMsg.MssMsgTypeNames[(int)curMsg.Type]; //Ensure that the type of the message recieved can be assigned to the current type combo box. if (curTypeCombo.FindStringExact(newTypeName) != -1) { //This will trigger the corresponding MsgMetadata to be regenerated. curTypeCombo.Text = newTypeName; } else { return; } MssMsgRangeEntryMetadata curEntryMetadata; if(this.learnMode == LearnMode.In) { curEntryMetadata = this.inMsgMetadata; } else //(this.learnMode == LearnMode.Out) { curEntryMetadata = this.outMsgMetadata; } IMssMsgRange learnedRange = new MssMsgRange(); learnedRange.MsgType = curMsg.Type; //If the type is the same as the last message and either data1 or data2 has changed //then treat this as a range of notes. if (this.lastMsgReceived != null && this.lastMsgReceived.Type == curMsg.Type && (this.lastMsgReceived.Data1 != curMsg.Data1 || this.lastMsgReceived.Data2 != curMsg.Data2)) { learnedRange.Data1RangeBottom = Math.Min(this.lastMsgReceived.Data1, curMsg.Data1); learnedRange.Data1RangeTop = Math.Max(this.lastMsgReceived.Data1, curMsg.Data1); learnedRange.Data2RangeBottom = Math.Min(this.lastMsgReceived.Data2, curMsg.Data2); learnedRange.Data2RangeTop = Math.Max(this.lastMsgReceived.Data2, curMsg.Data2); } else { learnedRange.Data1RangeBottom = curMsg.Data1; learnedRange.Data1RangeTop = curMsg.Data1; learnedRange.Data2RangeBottom = curMsg.Data2; learnedRange.Data2RangeTop = curMsg.Data2; } curEntryMetadata.UseExistingMsgRange(learnedRange); if (this.learnMode == LearnMode.In) { inMsgMetadata.ValidateEntryField1(); inMsgMetadata.ValidateEntryField2(); } else //(this.learnMode == LearnMode.Out) { outMsgMetadata.ValidateEntryField1(); outMsgMetadata.ValidateEntryField2(); } this.lastMsgReceived = curMsg; } }
/// <summary> /// Event handler for MssEvents coming /// </summary> /// <param name="dryMssEvent"></param> protected void dryMssEventOutputPort_DryMssEventRecieved(MssEvent dryMssEvent) { if (this.InvokeRequired) { this.BeginInvoke(new Action <MssEvent>(dryMssEventOutputPort_DryMssEventRecieved), dryMssEvent); return; } MssMsg curMsg = dryMssEvent.mssMsg; if (this.learnMode != LearnMode.Off && curMsg.Type != MssMsgType.NoteOff && curMsg.Type != MssMsgType.Generator) { if (curMsg.Type == MssMsgType.NoteOn) { curMsg.Type = MssMsgType.Note; } ComboBox curTypeCombo = null; if (this.learnMode == LearnMode.In) { curTypeCombo = this.inTypeCombo; } else if (this.learnMode == LearnMode.Out) { curTypeCombo = this.outTypeCombo; } else { //Unknown learn mode Debug.Assert(false); return; } string newTypeName = MssMsg.MssMsgTypeNames[(int)curMsg.Type]; //Ensure that the type of the message recieved can be assigned to the current type combo box. if (curTypeCombo.FindStringExact(newTypeName) != -1) { //This will trigger the corresponding MsgMetadata to be regenerated. curTypeCombo.Text = newTypeName; } else { return; } MssMsgRangeEntryMetadata curEntryMetadata; if (this.learnMode == LearnMode.In) { curEntryMetadata = this.inMsgMetadata; } else //(this.learnMode == LearnMode.Out) { curEntryMetadata = this.outMsgMetadata; } IMssMsgRange learnedRange = new MssMsgRange(); learnedRange.MsgType = curMsg.Type; //If the type is the same as the last message and either data1 or data2 has changed //then treat this as a range of notes. if (this.lastMsgReceived != null && this.lastMsgReceived.Type == curMsg.Type && (this.lastMsgReceived.Data1 != curMsg.Data1 || this.lastMsgReceived.Data2 != curMsg.Data2)) { learnedRange.Data1RangeBottom = Math.Min(this.lastMsgReceived.Data1, curMsg.Data1); learnedRange.Data1RangeTop = Math.Max(this.lastMsgReceived.Data1, curMsg.Data1); learnedRange.Data2RangeBottom = Math.Min(this.lastMsgReceived.Data2, curMsg.Data2); learnedRange.Data2RangeTop = Math.Max(this.lastMsgReceived.Data2, curMsg.Data2); } else { learnedRange.Data1RangeBottom = curMsg.Data1; learnedRange.Data1RangeTop = curMsg.Data1; learnedRange.Data2RangeBottom = curMsg.Data2; learnedRange.Data2RangeTop = curMsg.Data2; } curEntryMetadata.UseExistingMsgRange(learnedRange); if (this.learnMode == LearnMode.In) { inMsgMetadata.ValidateEntryField1(); inMsgMetadata.ValidateEntryField2(); } else //(this.learnMode == LearnMode.Out) { outMsgMetadata.ValidateEntryField1(); outMsgMetadata.ValidateEntryField2(); } this.lastMsgReceived = curMsg; } }