Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions PortAudioSharp/Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ IntPtr userData // Originally `void *`
[return: MarshalAs(UnmanagedType.I4)]
public static extern ErrorCode Pa_IsStreamActive(IntPtr stream); // `PaStream *`

[DllImport(PortAudioDLL)]
public static extern double Pa_GetStreamTime(IntPtr stream); // `PaStream *`

[DllImport(PortAudioDLL)]
public static extern double Pa_GetStreamCpuLoad(IntPtr stream); // `PaStream *`
}
Expand Down Expand Up @@ -388,6 +391,28 @@ public bool IsActive
}
}

/// <summary>
/// Returns the current time in seconds for a stream according to the same clock
/// used to generate callback PaStreamCallbackTimeInfo timestamps. The time values
/// are monotonically increasing and have unspecified origin.
///
/// Pa_GetStreamTime returns valid time values for the entire life of the stream,
/// from when the stream is opened until it is closed. Starting and stopping the
/// stream does not affect the passage of time returned by Pa_GetStreamTime.
///
/// This time may be used for synchronizing other events to the audio stream,
/// for example synchronizing audio to MIDI.
///
/// @return
/// The stream's current time in seconds, or 0 if an error occurred.
///
/// @see PaTime, PaStreamCallback, PaStreamCallbackTimeInfo
/// </summary>
public double Time
{
get => Native.Pa_GetStreamTime(streamPtr);
}

/// <summary>
/// Retrieve CPU usage information for the specified stream.
/// The "CPU Load" is a fraction of total CPU time consumed by a callback stream's
Expand Down