Пример #1
0
        public IActionResult ChordBlock(Key key, Alteration alteration)
        {
            var viewModel = new ChordBlockViewModel();

            viewModel.Chords = _chordService.GetChords(new Note(key, alteration), _chordQualityService.GetAll()).ToList();
            return(PartialView("_ChordBlock", viewModel));
        }
Пример #2
0
        public ChordSelectorViewModel GetChordSelectorViewModel()
        {
            var chordSelectorViewModel = new ChordSelectorViewModel();

            chordSelectorViewModel.Keys           = _keyService.GetAll();
            chordSelectorViewModel.Alterations    = _alterationService.GetAllAvailableForChord();
            chordSelectorViewModel.ChordQualities = _chordQualityService.GetAll();

            return(chordSelectorViewModel);
        }
Пример #3
0
        public IEnumerable <Chord> GetChordsStrict(Note n1, Note n2, Note n3, List <ChordQuality> allChordQualities = null)
        {
            allChordQualities = allChordQualities ?? _chordQualityService.GetAll().ToList();

            if (Math.Abs((int)n1.Alteration) < 2)
            {
                var intervalsN1 = from a in _noteService.GetIntervalsBetween2Notes(n1, n2)
                                  from b in _noteService.GetIntervalsBetween2Notes(n1, n3)
                                  select new[] { a, b };

                foreach (var intervals in intervalsN1)
                {
                    var chordQualities = allChordQualities.Where(cq =>
                                                                 cq.ChordQualityIntervals.Select(cqi => cqi.Interval).Contains(intervals[0]) &&
                                                                 cq.ChordQualityIntervals.Select(cqi => cqi.Interval).Contains(intervals[1]));

                    foreach (var chordQuality in chordQualities)
                    {
                        yield return(GetChord(n1, chordQuality));
                    }
                }
            }

            if (Math.Abs((int)n2.Alteration) < 2)
            {
                var intervalsN2 = from a in _noteService.GetIntervalsBetween2Notes(n2, n1)
                                  from b in _noteService.GetIntervalsBetween2Notes(n2, n3)
                                  select new[] { a, b };

                foreach (var intervals in intervalsN2)
                {
                    var chordQualities = allChordQualities.Where(cq =>
                                                                 cq.ChordQualityIntervals.Select(cqi => cqi.Interval).Contains(intervals[0]) &&
                                                                 cq.ChordQualityIntervals.Select(cqi => cqi.Interval).Contains(intervals[1]));

                    foreach (var chordQuality in chordQualities)
                    {
                        yield return(GetChord(n2, chordQuality));
                    }
                }
            }

            if (Math.Abs((int)n3.Alteration) < 2)
            {
                var intervalsN3 = from a in _noteService.GetIntervalsBetween2Notes(n3, n1)
                                  from b in _noteService.GetIntervalsBetween2Notes(n3, n2)
                                  select new[] { a, b };

                foreach (var intervals in intervalsN3)
                {
                    var chordQualities = allChordQualities.Where(cq =>
                                                                 cq.ChordQualityIntervals.Select(cqi => cqi.Interval).Contains(intervals[0]) &&
                                                                 cq.ChordQualityIntervals.Select(cqi => cqi.Interval).Contains(intervals[1]));

                    foreach (var chordQuality in chordQualities)
                    {
                        yield return(GetChord(n3, chordQuality));
                    }
                }
            }
        }