private void updateState() { statusLabel.Text = state.ToString(); }
public void StartStream() { if (StreamState != StreamState.Open) { throw new Exception("Trying to Start a stream that does not have State: Open. State is " + StreamState.ToString()); } var err = PortAudio.Pa_StartStream(Config.Stream); if (err != PortAudio.PaError.paNoError) { throw new Exception(PortAudio.Pa_GetErrorText(err)); } StreamState = StreamState.Started; }
public void CloseStream() { if (StreamState != StreamState.Stopped) { throw new Exception("Trying to Close a stream that does not have State: Stopped. State is " + StreamState.ToString()); } if (Config == null) { return; } var err = PortAudio.Pa_CloseStream(Config.Stream); if (err != PortAudio.PaError.paNoError) { throw new Exception(PortAudio.Pa_GetErrorText(err)); } StreamState = StreamState.Closed; }
public void OpenStream() { if (Config == null) { throw new Exception("Configuration settings have not been applied. You must first configure the host"); } if (StreamState != StreamState.Closed) { throw new Exception("Trying to Open a stream that does not have State: Closed. State is " + StreamState.ToString()); } callbackDelegate = RealtimeCallback; streamFinishedDelegate = StreamFinished; var err = PortAudio.Pa_OpenStream( out Config.Stream, ref Config.inputParameters, ref Config.outputParameters, Samplerate, BufferSize, (PortAudio.PaStreamFlags.paClipOff | PortAudio.PaStreamFlags.paDitherOff), callbackDelegate, new IntPtr(0) ); if (err != PortAudio.PaError.paNoError) { throw new Exception(PortAudio.Pa_GetErrorText(err)); } err = PortAudio.Pa_SetStreamFinishedCallback(Config.Stream, streamFinishedDelegate); if (err != PortAudio.PaError.paNoError) { throw new Exception(PortAudio.Pa_GetErrorText(err)); } StreamState = StreamState.Open; }