コード例 #1
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);
            }
        }
コード例 #2
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);
        }
コード例 #3
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();
        }
コード例 #4
0
        private void trainingButton_Click(object sender, EventArgs e)
        {
            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.checkBox.Checked;
            var accords = Chord.RetrieveChords(midi, retriever);

            DiscreteDataRetriever data = new DiscreteDataRetriever(accords.ToList());

            DiscreteNeuralNetworkByChord.OkayWeight      = (double)this.okayWeight.Value;
            DiscreteNeuralNetworkByChord.HiddenLayerSize = (int)hiddelLayerSize.Value;

            if (this.okayFiles != null)
            {
                var midiEvents1 = new InstrumentMidiEventProducer(this.okayFiles.Select(x => new Sequence(x)));
                var midi1       = midiEvents1.GetOrderedMessages(GeneralMidiInstrument.AcousticGrandPiano);
                Chord.AllowForComplexSimplification = this.checkBox.Checked;
                var accords1 = Chord.RetrieveChords(midi1, retriever);
                DiscreteDataRetriever data1 = new DiscreteDataRetriever(accords1.ToList());

                this.nnByChord = new DiscreteNeuralNetworkByChord(data.Good, data1.Good, data.Bad.Union(data1.Bad).Take(data.Bad.Count).ToList(),
                                                                  new AForge.Neuro.BipolarSigmoidFunction());
            }
            else
            {
                this.nnByChord = new DiscreteNeuralNetworkByChord(data.Good, data.Okay, data.Bad, new AForge.Neuro.SigmoidFunction());
            }

            foreach (var item in this.Controls.OfType <Control>())
            {
                item.Enabled = false;
            }

            threadTrain = new Thread(Start);
            threadTrain.Start();
        }