private bool LoadAudio(string path)
        {
            DisposeSource();

            //Get audio stream
            _sourceStream = WAV.FromFile(path);

            _audioSource = path;

            //Create buffer for stream
            _buffer = _provider.CreateBuffer(_sourceStream);
            _buffer.Loop = chkLoop.Checked;

            //Set controls
            _sampleTime = new DateTime((long)_sourceStream.Samples * 10000000 / _sourceStream.Frequency);

            txtPath.Text = path;
            lblFrequency.Text = String.Format("{0} Hz", _sourceStream.Frequency);
            lblSamples.Text = String.Format("{0}", _sourceStream.Samples);

            customTrackBar1.Value = 0;
            customTrackBar1.TickStyle = TickStyle.None;
            customTrackBar1.Maximum = _sourceStream.Samples;
            customTrackBar1.TickFrequency = _sourceStream.Samples / 8;
            customTrackBar1.TickStyle = TickStyle.BottomRight;

            numLoopStart.Value = 0;
            numLoopStart.Maximum = numLoopEnd.Maximum = _sourceStream.Samples;
            numLoopEnd.Value = _sourceStream.Samples;

            pnlLoopStart.Width = 0;
            pnlLoopEnd.Width = 0;

            btnOkay.Enabled = true;

            if (_type == 0)
                chkLoopEnable.Checked = true;

            UpdateTimeDisplay();

            return true;
        }
 public AudioInfo(AudioBuffer buffer, IAudioStream stream)
 {
     _buffer = buffer;
     _stream = stream;
 }
        private void DisposeSource()
        {
            //Stop playback
            Stop();

            //Dispose buffer
            if (_buffer != null)
            {
                _buffer.Dispose();
                _buffer = null;
            }

            //Dispose stream
            if (_sourceStream != null)
            {
                _sourceStream.Dispose();
                _sourceStream = null;
            }

            chkLoopEnable.Checked = chkLoop.Checked = chkLoop.Enabled = false;
            btnOkay.Enabled = false;
        }
        private void TargetChanged(THPNode newTarget)
        {
            if (_targetSource == newTarget)
                return;

            Close();

            if ((_targetSource = newTarget) == null)
                return;

            previewPanel1.RenderingTarget = _targetSource;

            IAudioStream s = _targetSource._audio;

            //Create provider
            if (_provider == null && s != null)
            {
                _provider = AudioProvider.Create(null);
                _provider.Attach(this);
            }

            chkLoop.Checked = false;

            //Create buffer for stream
            if (s != null)
                _buffer = _provider.CreateBuffer(s);

            if (_targetSource.FrameRate > 0)
                _frameTime = new DateTime((long)((float)_targetSource.NumFrames * 10000000.0f / _targetSource.FrameRate));

            trackBar1.Value = 0;
            trackBar1.TickStyle = TickStyle.None;
            trackBar1.Maximum = (int)_targetSource.NumFrames;
            trackBar1.TickFrequency = (int)_targetSource.NumFrames;
            trackBar1.TickStyle = TickStyle.BottomRight;

            if (_targetSource.FrameRate > 0)
                UpdateTimeDisplay();

            Enabled = _targetSource.NumFrames > 0;
        }