Esempio n. 1
0
		public void Rewind()
		{
			var asf = new AsfFile(filepath);
			asf.Open();
			soundStream = new AsfAudio(new AsfStream(asf, AsfStreamType.asfAudio, 0)).GetWaveStream();
			asf.Close();
		}
Esempio n. 2
0
		public void Rewind()
		{
			Dispose();
			asf = new AsfFile(filepath);
			var audioStream = new AsfStream(asf, AsfStreamType.asfAudio, 0);
			soundStream = new AsfAudio(audioStream).GetWaveStream();
			video = new AsfImageLoader(asf);
		}
Esempio n. 3
0
        /// <summary>
        /// Sets the end offset of the wave stream and returns the stream
        /// </summary>
        public WaveMemoryStream To(double offset)
        {
            if (StartOffset == null)
            {
                throw new ArgumentException("Must have a valid start offset");
            }

            EndOffset = offset;
            return(WaveMemoryStream.FromFile(FileName, StartOffset.Value, EndOffset.Value));
        }
Esempio n. 4
0
		public void Dispose()
		{
			if (soundStream != null)
				soundStream.Dispose();
			soundStream = null;
			if (video != null)
				video.Dispose();
			video = null;
			if (asf != null)
				asf.Dispose();
			asf = null;
		}
Esempio n. 5
0
        /// <summary>
        /// Get the PCM Wave memory stream for the extracted audio data
        /// </summary>
        public WaveMemoryStream GetWaveStream()
        {
            MemoryStream ms = new MemoryStream();

            WriteTo(ms);
            ms.Position = 0;
            WaveMemoryStream waveMemoryStream = new WaveMemoryStream(ms,
                                                                     (int)_asfStream.Configuration.AudioSampleRate,
                                                                     _asfStream.Configuration.AudioBitsPerSample,
                                                                     _asfStream.Configuration.AudioChannels);

            return(waveMemoryStream);
        }
        private void WaveFormPlayButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                double timeInSeconds = (double)startTimeOffset / 1000;
                using(AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, ViewModelLocator.MainStatic.FileName, timeInSeconds))
                using (AsfAudio asfAudio = new AsfAudio(asfStream))
                {
                    //play a two second sample
                    byte[] data = asfAudio.GetSampleBytes(2 * (int)  asfStream.Configuration.AudioSampleRate  * asfStream.Configuration.AudioChannels);

                    WaveMemoryStream mwav = new WaveMemoryStream(data, (int)asfStream.Configuration.AudioSampleRate, asfStream.Configuration.AudioBitsPerSample, asfStream.Configuration.AudioChannels);
                    SoundPlayer sp = new SoundPlayer(mwav);
                    sp.Play();
                }
            }
            catch (AsfStreamException) { }
        }
Esempio n. 7
0
		public void Dispose()
		{
			soundStream.Dispose();
			soundStream = null;
		}
Esempio n. 8
0
 /// <summary>
 /// Get the PCM Wave memory stream for the extracted audio data
 /// </summary>
 public WaveMemoryStream GetWaveStream()
 {
     MemoryStream ms = new MemoryStream();
     WriteTo(ms);
     ms.Position = 0;
     WaveMemoryStream waveMemoryStream = new WaveMemoryStream(ms,
                                                              (int)_asfStream.Configuration.AudioSampleRate,
                                                              _asfStream.Configuration.AudioBitsPerSample,
                                                              _asfStream.Configuration.AudioChannels);
     return waveMemoryStream;
 }