public void Play(Streamable stream) { Stop(); this.stream = stream; if (!stream.IsReady()) { return; } if (SaveFile) { InitializeRecorder(); } m_secondaryBufferWritePosition = 0; position = 0; progressSoFar = 0; SetBufferAndWave(); SetInterval(); SetSecondaryBuffer(); isDoing = true; mThread = new Thread(new ThreadStart(OutputEventTask)); mThread.Name = "DataTransferThread"; //mThread.IsBackground = true; mThread.Start(); isPlaying = true; //TransferBuffer(); buffer.Play(0, BufferPlayFlags.Looping); }
public static IStreamable ToStreamable(this IEnumerable <Stream> source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } return(Streamable.Create(() => new CompositeStream(source.GetEnumerator()))); }
public static async Task <StringTable> Open(Streamable source, StringType stringType = StringType.NullTerminated) { using var stream = source.OpenStream(); var headerBytes = new byte[Header.SizeInBytes]; await stream.ReadAsync(headerBytes); var header = new Header(headerBytes); var tableBytes = new byte[DictionaryEntry.SizeInBytes * header.count]; await stream.ReadAsync(tableBytes); var stringOffsetByID = Enumerable .Range(0, (int)header.count) .Select(index => new DictionaryEntry(tableBytes, index * DictionaryEntry.SizeInBytes)) .AsParallel() .ToDictionary(entry => entry.id, entry => (int)entry.stringOffset); var dataBytes = new byte[stream.Length - stream.Position]; await stream.ReadAsync(dataBytes); Func <byte[], int, string> stringParsingMethod = stringType switch { StringType.LengthPrefixed => ReadLengthPrefixedString, StringType.NullTerminated => ReadNullTerminatedString, _ => throw new NotImplementedException() }; var stringLengthByID = stringOffsetByID .ToDictionary( entry => entry.Key, entry => Encoding.UTF8.GetByteCount(stringParsingMethod(dataBytes, entry.Value)) ); return(new StringTable() { stringOffsetByID = stringOffsetByID, stringLengthByID = stringLengthByID, stringType = stringType, source = source }); }
void playButton_Clicked(object sender, EventArgs e) { if (playButton.Text == "Play") { playButton.Text = "Pause"; Streamable stream = wp.GetCurrentStream(); if (wd.Equals(stream)) { wp.Resume(); } else { Play(); } } else if (playButton.Text == "Pause") { playButton.Text = "Play"; wp.Pause(); } titleText.Focus(); }
public static IStreamable MapText(this IStreamable streamable, Encoding outputEncoding, Func <string, string> mapper) { if (streamable == null) { throw new ArgumentNullException(nameof(streamable)); } if (outputEncoding == null) { throw new ArgumentNullException(nameof(outputEncoding)); } if (mapper == null) { throw new ArgumentNullException(nameof(mapper)); } return(Streamable.Create(() => { var mapped = mapper(streamable.ReadText()); return new MemoryStream(outputEncoding.GetBytes(mapped)); })); }
/// <summary> /// Provides streamable sequence of frames processed by the application of the given <paramref name="processor"/>. /// </summary> /// <typeparam name="TValue"></typeparam> /// <param name="processor"></param> /// <returns></returns> public IStreamable <Microsoft.StreamProcessing.Empty, TValue> GetStreamable <TValue>(FrameProcessor <TValue> processor) { var observable = Observable.Create(GetSubscriber(new TickFrameProcessor <TValue>(processor).Invoke)).Select(x => new StreamEvent <TValue>(x.Ticks, x.Ticks + 1, x.Value)); return(Streamable.ToStreamable(observable)); }
public ConversionInformation(Streamable @base, string artist, string album) { Base = @base; Artist = artist; Album = album; }