Example #1
0
        private static IEnumerable <FillSection> FillChain(Func <MarkovChainNodeFunc <FillSection>, MarkovChainNodeFunc <FillSection> > filterFunc, double fillLengthInBeats)
        {
            var chains = new List <FillSection>();
            var chain  = Chain;

            do
            {
                var section = MarkovChainNodeFunc <FillSection> .Choose(chain, filterFunc);

                if (section != null)
                {
                    chains.Add(section.Data);
                    chain = section.ChildNodes.Select(n => n()).ToList();
                }
            } while (chain != null && chain.Count > 0 && chains.Sum(c => c.Length) < fillLengthInBeats);

            return(chains);
        }
Example #2
0
        private IEnumerable <SectionType> FillChain(SongInfo songInfo, Func <MarkovChainNodeFunc <SectionType>, MarkovChainNodeFunc <SectionType> > filterFunc)
        {
            _idealMeasures = songInfo.Tempo * (songInfo.LengthInSeconds / 60) / songInfo.TimeSignature.BeatCount;

            var sections = new List <SectionType>();
            var chain    = Chain;

            do
            {
                var section = MarkovChainNodeFunc <SectionType> .Choose(chain, filterFunc);

                if (section != null)
                {
                    sections.Add(section.Data);
                    _estimatedMeasures += 16;
                    chain = section.ChildNodes.Select(n => n()).ToList();
                }
            } while (chain != null && chain.Count > 0 && sections.Last() != SectionType.Outro);

            return(sections);
        }