Beispiel #1
0
        private void ThreadHandler()
        {
            float last = 0;

            _tickCount = 0;

            _playback.Load(_sequence);

            _stopWatch = new Stopwatch();
            _stopWatch.Start();

            _playback.Start();

            _playing = true;

            while (_playing)
            {
                // if we hit our interval
                if ((_stopWatch.ElapsedMilliseconds - last) >= _sequence.Interval)
                {
                    // make sure we're still inside the bounds of the song
                    if (_tickCount >= _sequence.Channels[0].Data.Length)
                    {
                        // dump out and let anyone listening know it's all over
                        Thread.Sleep(100);
                        _stopWatch.Stop();
                        _playback.Stop();
                        OnSequenceStopped(new EventArgs());
                        return;
                    }

                    // every time we tick, set the output port for the current channel on or off
                    foreach (Channel c in _sequence.Channels)
                    {
                        if (PhidgetHandler.IFKits[c.SerialNumber].outputs[c.OutputIndex] != c.Data[_tickCount])
                        {
                            PhidgetHandler.IFKits[c.SerialNumber].outputs[c.OutputIndex] = c.Data[_tickCount];
                        }
                    }

                    _tickCount++;
                    last = (_stopWatch.ElapsedMilliseconds - ((_stopWatch.ElapsedMilliseconds - last) - _sequence.Interval));
                }
                else
                {
                    Thread.Sleep((int)(_stopWatch.ElapsedMilliseconds - last));                         // give the CPU a break until it's time to act again
                }
            }
            Thread.Sleep(100);
            _stopWatch.Stop();
            _playback.Stop();
        }
Beispiel #2
0
        public SequencePlayerV1(Sequence s)
        {
            _sequence = s;

            // V1 sequence only knows about the MCI engine
            _playback = new MCIPlayback();

            // close any open music files
            _playback.Unload();

            _playback.Load(s);

            tmrTimer          = new Timer();
            tmrTimer.Interval = (int)_sequence.Interval;
            tmrTimer.Tick    += new EventHandler(tmrTimer_Tick);
        }
Beispiel #3
0
        private void RecordThread()
        {
            float     last = 0;
            Stopwatch s    = new Stopwatch();

            _playback.Load(_sequence);

            s.Start();
            _playback.Start();

            _playing = true;

            while (_playing)
            {
                // if we've elapsed enough time, process keys
                if ((s.ElapsedMilliseconds - last) > _sequence.Interval)
                {
                    // if we're at the end, bail out
                    if (_tickCount >= _channels[0].Data.Length)
                    {
                        btnStart.PerformClick();
                    }

                    // for each channel, set the ticks on and off as keys are pressed
                    for (int i = 0; i < _channels.Count; i++)
                    {
                        if (_on[i])
                        {
                            _tempData[i][_tickCount] = _on[i];
                        }

                        // every time we tick, set the output port for the current channel on or off
                        if (chkPlay.Checked && !_on[i])
                        {
                            PhidgetHandler.IFKits[_channels[i].SerialNumber].outputs[_channels[i].OutputIndex] = _channels[i].Data[_tickCount];
                        }
                    }
                    _tickCount++;

                    // maintain the last time we did this
                    last = (s.ElapsedMilliseconds - ((s.ElapsedMilliseconds - last) - _sequence.Interval));
                }
            }

            _playback.Stop();
        }
Beispiel #4
0
        public SequencePlayerV2(Sequence s)
        {
            _sequence = s;

            switch (_sequence.MusicType)
            {
            case MusicType.Sample:
                _playback = new MCIPlayback();
                break;

            case MusicType.MIDI:
                _playback = new MIDIPlayback();
                break;
            }

            // close any open music files
            _playback.Unload();

            _playback.Load(s);
        }
Beispiel #5
0
 public static int Load(string media, bool loop = false, bool prescan = false, EAudioEffect effekt = EAudioEffect.None)
 {
     return(_Playback.Load(media, loop, prescan, effekt));
 }
Beispiel #6
0
 public static int Load(string Media)
 {
     return(_Playback.Load(Media));
 }
Beispiel #7
0
 public override void Load()
 {
     _playback.Load(_sequence);
 }