Ejemplo n.º 1
0
        static VirtualPieses()
        {
            #region KARTOSHKA

            var mVirtialStateSequence = new List <AccordeonState>();

            var pause    = new AccordeonState(100, 0, AccordeonRightKeys.None, 0);
            var pauseEnd = new AccordeonState(5000, 0, AccordeonRightKeys.None, 0);

            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(0, 70, AccordeonRightKeys.O4_C, 0));
            for (int i = 0; i < 100; i++)
            {
                mVirtialStateSequence.Add(new AccordeonState(5, (byte)(i * 127 / 100), AccordeonRightKeys.O4_C, 0));
            }
            mVirtialStateSequence.Add(pause);
            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_C, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_D, 0));
            mVirtialStateSequence.Add(pause);
            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_D, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_E, 0));
            mVirtialStateSequence.Add(pause);
            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_E, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(1000, 127, AccordeonRightKeys.O4_F, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_E, 0));
            mVirtialStateSequence.Add(pause);
            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_E, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_D, 0));
            mVirtialStateSequence.Add(pause);
            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_D, 0));
            mVirtialStateSequence.Add(pause);


            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_C, 0));
            mVirtialStateSequence.Add(pause);
            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_C, 0));
            mVirtialStateSequence.Add(pause);


            mVirtialStateSequence.Add(new AccordeonState(1000, 127, AccordeonRightKeys.O4_C, 0));

            mVirtialStateSequence.Add(pause);
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(1000, 127, AccordeonRightKeys.O4_E, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(1000, 127, AccordeonRightKeys.O4_D, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_E, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_E, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(1000, 127, AccordeonRightKeys.O4_F, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_E, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_E, 0));
            mVirtialStateSequence.Add(pause);


            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_D, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_D, 0));
            mVirtialStateSequence.Add(pause);


            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_C, 0));
            mVirtialStateSequence.Add(pause);
            mVirtialStateSequence.Add(new AccordeonState(500, 127, AccordeonRightKeys.O4_C, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(new AccordeonState(1000, 127, AccordeonRightKeys.O4_C, 0));
            mVirtialStateSequence.Add(pause);

            mVirtialStateSequence.Add(pauseEnd);

            DefaultPiese = new VirtualPieseInfo("Картошка", mVirtialStateSequence.ToArray());

            #endregion
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
 public void HandleKeys(AccordeonState state)
 {
     HandleKeys(state.PressureCode, state.RightKeysState, state.LeftVoicesState);
 }