Class VoiceRecording
java.lang.Object
fr.dreamin.dreamvoice.api.recording.model.VoiceRecording
Model representing a voice recording session.
Stores timestamped Opus frames and supports slicing and duration calculations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAudio(byte[] opusData) Appends an Opus audio frame to this recording.voidClears the cached decoded PCM samples.@Nullable short[]Retrieves the cached decoded PCM audio samples, if available.floatCalculates the total duration of the recording in seconds.booleanChecks whether this recording session has finished.booleanChecks whether this recording is currently capturing audio.voidsetCachedPcm(short @Nullable [] cachedPcm) Caches decoded PCM audio samples for subsequent playback.slice(long startOffsetMs, long durationMs) Slices an audio segment from a start millisecond offset.Slices an audio segment starting from a specific Instant.sliceLast(long durationMs) Extracts the last duration in milliseconds of the recording.Extracts the last duration segment of the recording.voidstart()Starts or restarts the recording session.voidstop()Stops the active recording session and computes the total duration.
-
Constructor Details
-
VoiceRecording
-
-
Method Details
-
start
public void start()Starts or restarts the recording session. -
stop
public void stop()Stops the active recording session and computes the total duration. -
isRecording
public boolean isRecording()Checks whether this recording is currently capturing audio.- Returns:
trueif actively recording
-
isFinished
public boolean isFinished()Checks whether this recording session has finished.- Returns:
trueif completed
-
addAudio
public void addAudio(byte[] opusData) Appends an Opus audio frame to this recording.- Parameters:
opusData- the raw Opus frame bytes
-
getDurationSeconds
public float getDurationSeconds()Calculates the total duration of the recording in seconds.- Returns:
- duration in seconds
-
slice
public VoiceRecording slice(@NotNull @NotNull Instant timestamp, @NotNull @NotNull Duration duration) Slices an audio segment starting from a specific Instant.- Parameters:
timestamp- the start timestampduration- the length of the slice- Returns:
- a new sliced
VoiceRecording
-
slice
Slices an audio segment from a start millisecond offset.- Parameters:
startOffsetMs- offset in milliseconds from recording startdurationMs- slice duration in milliseconds- Returns:
- a new sliced
VoiceRecording
-
sliceLast
Extracts the last duration segment of the recording.- Parameters:
duration- the duration to extract- Returns:
- a new sliced
VoiceRecording
-
sliceLast
Extracts the last duration in milliseconds of the recording.- Parameters:
durationMs- milliseconds to extract- Returns:
- a new sliced
VoiceRecording
-
getCachedPcm
@Nullable public @Nullable short[] getCachedPcm()Retrieves the cached decoded PCM audio samples, if available.- Returns:
- cached PCM samples, or
nullif not yet decoded or invalidated
-
setCachedPcm
public void setCachedPcm(short @Nullable [] cachedPcm) Caches decoded PCM audio samples for subsequent playback.- Parameters:
cachedPcm- decoded 16-bit 48kHz PCM samples
-
clearCachedPcm
public void clearCachedPcm()Clears the cached decoded PCM samples.
-