Пример #1
0
        public Form1()
        {
            InitializeComponent();
            stream = new OutputStream(0);
            stream.StartPlaying();
            clock       = new MidiInternalClock();
            clock.Tick += new EventHandler(calculateOutputs);
            clock.Tempo = 1000000; // 60 bpm

            initializeNetworks();

            // start evolutionary algorithm thread
            UpdateMessage("Starting evolutionary thread.");
            evoObject = new NeatMusicEvoThread();
            evoThread = new Thread(evoObject.doWork);
            evoThread.Start(); // WARN reenable this two lines to activate the evolution thread
            while (!evoThread.IsAlive)
            {
                ;
            }

            // start timer thread to change target phrase for fitness
            UpdateMessage("Starting timer for changing fitness target; set to " + SECONDS_TO_CHANGE + "");
            timerObject = new ChangeFitnessThread(SECONDS_TO_CHANGE, this);
            timerThread = new Thread(timerObject.doWork);
            timerThread.Start();
            while (!timerThread.IsAlive)
            {
                ;
            }
        }
Пример #2
0
        private void onTick(object sender, EventArgs args)
        {
            MidiInternalClock obj    = (MidiInternalClock)sender;
            float             seqPos = (float)sequencer1.Position;

            PgBar.SetValue(seqPos);
        }
Пример #3
0
        private void PrepareClock()
        {
            //if (_clock != null) _clock.Dispose();

            _clock = new MidiInternalClock();

            //Pulses per quarter note... 24 sounds reasonable.
            //Trade off between accuracy and CPU
            _clock.Ppqn = 24;

            //clock tempo in microseconds per beat. Song in bpm
            _clock.Tempo = LengthOfBeatInMicroSeconds(_songCopy.Tempo);

            // Setup clock tick event handling
            _clock.Tick += HandleClockTick;
        }