Exemplo n.º 1
0
        private void HandleRest(MidiEvent midiEvent)
        {
            double lengthOfNote       = CalculatePartOfBar(_previousNoteAbsoluteTicks, midiEvent.AbsoluteTicks);
            double availableLengthBar = EasyTimeSignature.Top - _notesOfBarReached;

            while (lengthOfNote > 0)
            {
                RestBuilder restBuilder = new RestBuilder();

                // Get duration
                int  duration;
                int  dots;
                bool isTied;
                HandleDuration(lengthOfNote, availableLengthBar, out lengthOfNote, out availableLengthBar, out duration, out dots, out isTied);

                // Create rest and add
                restBuilder.Duration((DurationType)duration);
                restBuilder.IsDotted(dots);
                AddToPiece(restBuilder.Build());

                // Check bar
                if (availableLengthBar == 0)
                {
                    availableLengthBar = EasyTimeSignature.Top;
                }

                _notesOfBarReached = EasyTimeSignature.Top - availableLengthBar;
            }

            _previousNoteAbsoluteTicks = midiEvent.AbsoluteTicks;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a RestBuilder instance to build the connection command
        /// </summary>
        /// <param name="properties">Rest properties action</param>
        /// <returns></returns>
        public static RestBuilder Build(Action <RestProperties> properties)
        {
            RestBuilder restClient = new RestBuilder()
            {
            };

            properties(restClient.Properties);
            return(restClient);
        }
Exemplo n.º 3
0
        private MusicElement CreateMusicElement(string token)
        {
            NoteType noteType;

            Enum.TryParse(token.Substring(0, 1).ToUpper(), out noteType);

            var dots         = token.Count(c => c == '.');
            var number       = int.Parse(Regex.Match(token, @"\d+").Value);
            var durationType = (DurationType)number;

            if (new Regex(@"[a-g][,'eis]*[0-9]+[.]*").IsMatch(token))
            {
                var builder = new NoteBuilder(noteType);

                // Octave
                var increaseOctaves = token.Count(c => c == '\'');
                var decreaseOctaves = token.Count(c => c == ',') * -1;
                builder.ChangeOctave(increaseOctaves + decreaseOctaves);

                // Sharp or flat
                if (token.Contains("is"))
                {
                    builder = builder.Sharp();
                }
                else if (token.Contains("token"))
                {
                    builder = builder.Flat();
                }

                if (token.Contains("~"))
                {
                    builder = builder.IsTied();
                }

                builder.AddDots(dots).Duration(durationType);

                return(builder.Build());
            }

            if (new Regex(@"r.*?[0-9][.]*").IsMatch(token))
            {
                var builder = new RestBuilder();

                builder.AddDots(dots).Duration(durationType);

                return(builder.Build());
            }

            return(null);
        }
Exemplo n.º 4
0
        private void RestSampleCode()
        {
            var serializer = new JsonSerializer();

            var _builder = new RestBuilder("https://jsonplaceholder.typicode.com/users/1");


            PostsRestClient client = new PostsRestClient(new CacheService(), serializer);

            var response = client.GetByID(1);


            CustomRestClient customRestClient = new CustomRestClient(new CacheService(), serializer, "https://jsonplaceholder.typicode.com/users/1");

            var request = _builder
                          .SetFormat(DataFormat.Json)
                          .SetMethod(Method.GET)
                          .Create();

            var userResponse = customRestClient.Get <UserModel>(request);

            //serializer.Deserialize<>
        }