public EAccordeon() { mMidiHelper = new MidiHelper(); mMidiController = new MidiControllerSerial(this); mRightRegisters = new RegisterInfo[] { new RegisterInfo("Основная октава", new int[] { 0 }), new RegisterInfo("Основная октава, +1", new int[] { 0, 1 }), new RegisterInfo("Основная октава, -1", new int[] { 0, -1 }), new RegisterInfo("Основная октава, -1, +1", new int[] { 0, -1, +1 }), }; try { SelectedRightRegister = mRightRegisters[Properties.Settings.Default.SelectedRightRegisterId]; } catch { SelectedRightRegister = mRightRegisters[0]; } mActualPressurePercents_ExpFilterAlpha = Properties.Settings.Default.PressureFilter; mChannelIdForRightSide = Properties.Settings.Default.ChannelIdForRightSide; mChannelIdForLeftSide = Properties.Settings.Default.ChannelIdForLeftSide; mTransformPressureMethod = (TransformPressureMethod)Properties.Settings.Default.TransformPressureMethod; mPressureSensonUpperLimit = Properties.Settings.Default.PressureSensonUpperLimit; mKeystrokeForce = Properties.Settings.Default.KeystrokeForce; mRightHandOctaveShift = Properties.Settings.Default.RightHandOctaveShift; bassRegisters = BassRegister.GetRegisters(); try { selectedBassRegister = bassRegisters[Properties.Settings.Default.SelectedLeftRegisterId]; } catch { selectedBassRegister = bassRegisters.FirstOrDefault(); } }
public static AccordeonState[] CreateSequenceFromBeepString(string src) { var pause = new AccordeonState(30, 0, AccordeonRightKeys.None, 0); var pauseEnd = new AccordeonState(5000, 0, AccordeonRightKeys.None, 0); List <AccordeonState> result = new List <AccordeonState>(); var srcList = src.Split(new char[] { ' ', '\t', '\n', '\r', '\\' }, StringSplitOptions.RemoveEmptyEntries); AccordeonState state = new AccordeonState(); state.PressureCode = 127; bool lastNoteWasUserPause = false; foreach (var i in srcList) { if (i.StartsWith("-n")) { result.Add(state); if (lastNoteWasUserPause == false) { result.Add(pause); } lastNoteWasUserPause = false; continue; } if (i.StartsWith("-d")) { var duration = (int)double.Parse(i.Substring(2, i.Length - 2), CultureInfo.InvariantCulture); var p = new AccordeonState(duration, 0, AccordeonRightKeys.None, 0); result.Add(p); lastNoteWasUserPause = true; continue; } if (i.StartsWith("-D")) { var duration = (int)double.Parse(i.Substring(2, i.Length - 2), CultureInfo.InvariantCulture); pause.Duration_ms = duration; result.Add(pause); lastNoteWasUserPause = true; continue; } if (i.StartsWith("-f")) { var freq = double.Parse(i.Substring(2, i.Length - 2), CultureInfo.InvariantCulture); var noteId = MidiHelper.FrequencyToMidiNoteNumber(freq); if (noteId < 53) { noteId = 53; } if (noteId > 93) { noteId = 93; } int noteShift = 23 + noteId - 53; state.RightKeysState = (AccordeonRightKeys)(1UL << noteShift); continue; } if (i.StartsWith("-l")) { var duration = double.Parse(i.Substring(2, i.Length - 2), CultureInfo.InvariantCulture); state.Duration_ms = (int)duration; continue; } } result.Add(state); result.Add(pauseEnd); return(result.ToArray()); }