private void beginGenerationButton_Click(object sender, EventArgs e)
        {
            try
            {
                PianoNoteRetriever retriever = new PianoNoteRetriever();
                var midiEvents = new InstrumentMidiEventProducer(this.files.Select(x => new Sequence(x)));
                var 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);
            }
        }
Esempio n. 2
0
 static SimplisticPianoNote()
 {
     SimplisticPianoNote.PianoNoteRetriever = new PianoNoteRetriever();
 }
Esempio n. 3
0
        private void trainingButton_Click(object sender, EventArgs e)
        {
            PianoNoteRetriever retriever = new PianoNoteRetriever();
            var midiEvents = new InstrumentMidiEventProducer(this.files.Select(x => new Sequence(x)));
            var 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();
        }