コード例 #1
0
        public override void FormLoad(object sender, EventArgs e)
        {
            PianoNoteRetriever retriever = new PianoNoteRetriever();

            var midiEvents = new InstrumentMidiEventProducer(
                Directory.EnumerateFiles(@"C:\Users\armen_000\Documents\Visual Studio 2013\Projects\Improvisation\Improvisation\bin\Debug\MusicSeperated\RayCharles").Select(x => new Sequence(x)));
            var midi    = midiEvents.GetOrderedMessages(GeneralMidiInstrument.AcousticGrandPiano);
            var accords = Chord.RetrieveChords(midi, retriever);

            //    var mahboyeminem = Chord.RetrieveChords(
            //      new InstrumentMidiEventProducer(Directory.EnumerateFiles("MusicSeperated\\Eminem").Select(x => new Sequence(x))).GetOrderedMessages(GeneralMidiInstrument.AcousticGrandPiano),
            //    retriever);


            var grams = HeterogenousNGrams <Chord> .BuildNGrams(3, 7, accords.ToList());

            this.MarkovGraph = new NGramGraphMarkovChain <Chord>(grams);

            this.wpfContainer.Child = GenerateWpfVisuals(GraphUIHelper.GenerateGraphUI <Chord>(new NGramGraphMarkovChain <Chord>(HomogenousNGrams <Chord> .DirectBuiltUnsafe(new NGram <Chord>().AsEnumerableObject(), 1))));

            this.ZoomControl.ZoomToFill();

            this.GraphArea.GenerateGraph(true);
            this.GraphArea.SetVerticesDrag(true, true);

            this.UpdateThemeListBox();
        }
コード例 #2
0
        private void beginGenerationButton_Click(object sender, EventArgs e)
        {
            try
            {
                var retriever  = new PianoNoteRetriever();
                var midiEvents = new InstrumentMidiEventProducer(this.files.Select(x => new Sequence(x)));
                IReadOnlyList <MidiEvent> midi = midiEvents.GetOrderedMessages(GeneralMidiInstrument.AcousticGrandPiano);

                Chord.AllowForComplexSimplification = this.checkBox1.Checked;
                var accords = Chord.RetrieveChords(midi, retriever);

                INGrams <Chord> grams = null;
                if (this.homogeneous)
                {
                    grams = HomogenousNGrams <Chord> .BuildNGrams((int)this.leftRangeNumericUpDown.Value, accords);
                }
                else
                {
                    grams = HeterogenousNGrams <Chord> .BuildNGrams((int)this.leftRangeNumericUpDown.Value, (int)this.rightRangeNumericUpDown.Value, accords);
                }

                NGramGraphMarkovChain <Chord> graph = new NGramGraphMarkovChain <Chord>(grams);
                this.Save(graph);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
ファイル: NoteGraph.cs プロジェクト: rasmus-z/Improvisation
        public override void FormLoad(object sender, EventArgs e)
        {
            PianoNoteRetriever retriever = new PianoNoteRetriever();

            var midiEvents = new InstrumentMidiEventProducer(Directory.EnumerateFiles("Music").Skip(4).Take(1).Select(x => new Sequence(x)));

            var k       = midiEvents.GetOrderedMessages(GeneralMidiInstrument.AcousticGrandPiano);
            var accords = Chord.RetrieveChords(k, retriever);

            accords.Count();

            var prod = new InstrumentChannelMessengerProducer(Directory.EnumerateFiles("Music").Select(x => new Sequence(x)))
                       .GetOrderedMessages(GeneralMidiInstrument.AcousticGrandPiano)
                       .Where(x => retriever.ValidNoteId(x))
                       .Select(x => new SimplisticPianoNote(x))
                       .ToList();

            var grams = HeterogenousNGrams <SimplisticPianoNote> .BuildNGrams(1, 5, prod);

            this.MarkovGraph = new NGramGraphMarkovChain <SimplisticPianoNote>(grams);

            this.wpfContainer.Child = GenerateWpfVisuals(GraphUIHelper.GenerateGraphUI <SimplisticPianoNote>(this.MarkovGraph));
            this.ZoomControl.ZoomToFill();

            this.GraphArea.GenerateGraph(true);
            this.GraphArea.SetVerticesDrag(true, true);
        }
コード例 #4
0
        public override void FormLoad(object sender, EventArgs e)
        {
            this.DisableButtons();
            this.serachTextBox.ReadOnly = true;
            this.Size = this.Size;
            // List<string> corp = new List<string>() { "a", "b", "c", "a", "e", "f", "g", "h", "e", "f", "h", "b", "b", "c", "h", "g" };
            List <string> corp = TextCorpus.RetrieveAnyCompleteWordCorpus();

            HeterogenousNGrams <string> grams = HeterogenousNGrams <string> .BuildNGrams(1, 3, corp);

            //HomogenousNGrams<string> grams = HomogenousNGrams<string>.BuildNGrams(1, corp);

            //NGramGraphMarkovChain<string> graphHetero = new NGramGraphMarkovChain<string>(heterograms);
            NGramGraphMarkovChain <string> graph = new NGramGraphMarkovChain <string>(grams);

            this.MarkovGraph = graph;

            this.wpfContainer.Child = GenerateWpfVisuals(GraphUIHelper.GenerateGraphUI <string>(NGramGraphMarkovChain <string> .Empty(true)));
            ZoomControl.ZoomToFill();

            this.serachTextBox.ReadOnly = false;
        }