Package com.vivoka.vsdk.audio.producers
Class File
java.lang.Object
com.vivoka.vsdk.audio.ProducerModule
com.vivoka.vsdk.audio.producers.File
File producer module that reads audio data from a raw file and dispatches it as buffers.
It supports real-time streaming and acceleration rate adjustments.
This producer module supports both synchronous and asynchronous pipeline operations
including pausing and resuming.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vivoka.vsdk.audio.ProducerModule
ProducerModule.State -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCloses the producer module.protected voidopenImpl()Opens the producer module.protected voidPauses the producer module.protected voidResumes the producer module.protected voidrunImpl()Runs the producer module in a blocking manner.voidsetAccelerationRate(double rate) Sets the acceleration rate for the audio processing.voidsetRealTimeStreamingEnabled(boolean enabled) Enables or disables real-time streaming.protected voidStarts the producer module in a non-blocking manner.protected voidstopImpl()Stops the producer module.Methods inherited from class com.vivoka.vsdk.audio.ProducerModule
dispatchAudio, dispatchBuffer, getLastError, getState, isBusy, isClosed, isIdle, isOpened, isPaused, isRunning, isStarted, setLastError, setState, setStateChanedCallback, subscribeFirst, subscribeLast, unsubscribe
-
Constructor Details
-
File
Constructs a File producer module with the specified parameters.- Parameters:
path- The path to the raw audio file to be read.sampleRate- The sample rate of the audio in Hz (e.g., 16000).channelCount- The number of audio channels (e.g., 1 for mono, 2 for stereo).bufferSize- The size of the audio buffer to be processed in bytes.
-
-
Method Details
-
setRealTimeStreamingEnabled
public void setRealTimeStreamingEnabled(boolean enabled) Enables or disables real-time streaming. When enabled, the module will attempt to stream audio data in real-time. When disabled, it will read the entire file and dispatch buffers as quickly as possible.- Parameters:
enabled- True to enable real-time streaming, false to disable it.
-
setAccelerationRate
Sets the acceleration rate for the audio processing. The acceleration rate must be greater than or equal to 1.0. A rate of 1.0 means normal speed, while higher values speed up the processing. Ignored if real-time streaming is disabled.- Parameters:
rate- The acceleration rate to set.- Throws:
Exception- If the acceleration rate is less than 1.0.
-
runImpl
Description copied from class:ProducerModuleRuns the producer module in a blocking manner. The producer state must beOPENED. When calling run pipeline, this method will be called after theopenmethod. The state remains RUNNING until the end and then becomes OPENED.- Overrides:
runImplin classProducerModule- Throws:
Exception- If the producer is not opened or an error occurs during running.
-
openImpl
Description copied from class:ProducerModuleOpens the producer module. This method prepares the module for processing audio data. This method is called by the pipeline before starting or running the producer.- Overrides:
openImplin classProducerModule- Throws:
Exception- If the producer is already opened or an error occurs during opening.
-
startImpl
Description copied from class:ProducerModuleStarts the producer module in a non-blocking manner. The producer state must beOPENED. When calling start pipeline, this method will be called after theopenmethod. startImpl() should initiate the producer and return immediately without waiting for processing to complete and update the state to STARTED when it is done.- Overrides:
startImplin classProducerModule- Throws:
Exception- If an error occurs during starting.
-
stopImpl
Description copied from class:ProducerModuleStops the producer module. The producer state must beSTARTED. When calling stop pipeline, this method will be called. It should initiate the stopping process and return immediately without waiting for it to complete. It should make sure that the state is updated to OPENED when it is done.- Overrides:
stopImplin classProducerModule- Throws:
Exception- If an error occurs during stopping.
-
closeImpl
Description copied from class:ProducerModuleCloses the producer module. The producer state must beOPENEDorIDLE. When calling stop pipeline, this method will be called after thecloseImplmethod. When calling run pipeline, this method will be called after therunImplmethod. If the closeImpl is asynchronous, the closeImpl should wait until the producer is OPENED.- Overrides:
closeImplin classProducerModule- Throws:
Exception- If an error occurs during closing.
-
pauseImpl
Description copied from class:ProducerModulePauses the producer module. The producer state must beSTARTED. When calling pause pipeline, this method will be called. It should initiate the pausing process and return immediately without waiting for it to complete. It should make sure that the state is updated to PAUSED when it is done.- Overrides:
pauseImplin classProducerModule- Throws:
Exception- If an error occurs during pausing.
-
resumeImpl
Description copied from class:ProducerModuleResumes the producer module. The producer state must bePAUSED. When the producer is resumed, the child class needs to update the state to STARTED. When calling resume pipeline, this method will be called. It should initiate the resuming process and return immediately without waiting for it to complete. It should make sure that the state is updated to OPENED when it is done.- Overrides:
resumeImplin classProducerModule- Throws:
Exception- If an error occurs during resuming.
-