Class NativeMiniAudioBackend
java.lang.Object
org.episteme.nativ.media.audio.backends.NativeMiniAudioBackend
- All Implemented Interfaces:
AudioAlgorithmProvider<AudioBuffer>, AudioBackend, AlgorithmProvider, Backend, ComputeBackend, CPUBackend, NativeBackend
@AutoService({Backend.class,ComputeBackend.class,AudioBackend.class,NativeBackend.class,CPUBackend.class,AudioAlgorithmProvider.class})
public class NativeMiniAudioBackend
extends Object
implements AudioBackend, NativeBackend, CPUBackend
Native Audio Backend using standalone miniaudio library (via Panama FFM).
This backend provides direct access to audio hardware.
- Since:
- 1.2
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates an execution context for running operations.Returns the type of hardware accelerator used by this backend.Returns the unique category of the algorithm.Returns the friendly name of this backend instance.Returns a description of the backend.doublegetId()Returns the unique identifier for this backend (e.g., "javafx", "jmol", "cuda").getName()Returns the display name for UI presentation.Returns the name of the native library this backend depends on.intReturns the priority for auto-selection (higher = preferred).float[]Returns the current frequency spectrum.Returns a human-readable status message for this backend.doublegetTime()getType()Returns the backend type category (e.g., "plotting", "molecular", "tensor", "math").booleanChecks if this backend is currently available (libraries loaded, etc.).booleanisLoaded()Checks if the native library is loaded and available.voidLoads an audio resource.voidpause()voidplay()voidstop()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AlgorithmProvider
description, getMetadata, scoreMethods inherited from interface AudioBackend
apply, createAudio, createBackend, shutdownMethods inherited from interface Backend
getAlgorithmProviders, isExplicitlyDisabledMethods inherited from interface CPUBackend
supportsComplexNumbers, supportsFloatingPoint, supportsParallelOps
-
Constructor Details
-
NativeMiniAudioBackend
public NativeMiniAudioBackend()
-
-
Method Details
-
isAvailable
public boolean isAvailable()Description copied from interface:BackendChecks if this backend is currently available (libraries loaded, etc.).Default implementation checks
Backend.isExplicitlyDisabled()and returns false if it is.- Specified by:
isAvailablein interfaceAlgorithmProvider- Specified by:
isAvailablein interfaceAudioBackend- Specified by:
isAvailablein interfaceBackend
-
getStatusMessage
Description copied from interface:BackendReturns a human-readable status message for this backend. Useful for debugging "Unavailable" states.- Specified by:
getStatusMessagein interfaceBackend- Returns:
- status message (e.g., "Ready", "Native library missing", etc.)
-
getType
Description copied from interface:BackendReturns the backend type category (e.g., "plotting", "molecular", "tensor", "math").- Specified by:
getTypein interfaceAudioBackend- Specified by:
getTypein interfaceBackend- Specified by:
getTypein interfaceComputeBackend- Specified by:
getTypein interfaceCPUBackend
-
getId
Description copied from interface:BackendReturns the unique identifier for this backend (e.g., "javafx", "jmol", "cuda").- Specified by:
getIdin interfaceAudioBackend- Specified by:
getIdin interfaceBackend- Specified by:
getIdin interfaceComputeBackend
-
getDescription
Description copied from interface:BackendReturns a description of the backend.- Specified by:
getDescriptionin interfaceAudioBackend- Specified by:
getDescriptionin interfaceBackend- Specified by:
getDescriptionin interfaceComputeBackend
-
getPriority
public int getPriority()Description copied from interface:BackendReturns the priority for auto-selection (higher = preferred). Used when multiple backends are available.- Specified by:
getPriorityin interfaceAlgorithmProvider- Specified by:
getPriorityin interfaceAudioBackend- Specified by:
getPriorityin interfaceBackend
-
getAlgorithmType
Description copied from interface:AlgorithmProviderReturns the unique category of the algorithm.- Specified by:
getAlgorithmTypein interfaceAlgorithmProvider- Specified by:
getAlgorithmTypein interfaceAudioAlgorithmProvider<AudioBuffer>
-
isLoaded
public boolean isLoaded()Description copied from interface:NativeBackendChecks if the native library is loaded and available.- Specified by:
isLoadedin interfaceNativeBackend- Returns:
- true if the native library has been successfully loaded
-
getNativeLibraryName
Description copied from interface:NativeBackendReturns the name of the native library this backend depends on.- Specified by:
getNativeLibraryNamein interfaceNativeBackend- Returns:
- library name (e.g., "openblas", "cuda", "fftw3")
-
createContext
Description copied from interface:ComputeBackendCreates an execution context for running operations.The context should be used within a try-with-resources block to ensure proper cleanup of resources.
- Specified by:
createContextin interfaceAudioBackend- Specified by:
createContextin interfaceComputeBackend- Returns:
- new execution context
-
getAcceleratorType
Description copied from interface:ComputeBackendReturns the type of hardware accelerator used by this backend.- Specified by:
getAcceleratorTypein interfaceAudioBackend- Specified by:
getAcceleratorTypein interfaceComputeBackend- Specified by:
getAcceleratorTypein interfaceCPUBackend- Returns:
- the accelerator type
-
getName
Description copied from interface:BackendReturns the display name for UI presentation.- Specified by:
getNamein interfaceAlgorithmProvider- Specified by:
getNamein interfaceAudioAlgorithmProvider<AudioBuffer>- Specified by:
getNamein interfaceAudioBackend- Specified by:
getNamein interfaceBackend
-
getBackendName
Description copied from interface:AudioBackendReturns the friendly name of this backend instance.- Specified by:
getBackendNamein interfaceAudioBackend
-
load
Description copied from interface:AudioBackendLoads an audio resource.- Specified by:
loadin interfaceAudioBackend- Parameters:
path- File path or URL- Throws:
Exception
-
play
public void play()- Specified by:
playin interfaceAudioBackend
-
pause
public void pause()- Specified by:
pausein interfaceAudioBackend
-
stop
public void stop()- Specified by:
stopin interfaceAudioBackend
-
getTime
public double getTime()- Specified by:
getTimein interfaceAudioBackend
-
getDuration
public double getDuration()- Specified by:
getDurationin interfaceAudioBackend
-
getSpectrum
public float[] getSpectrum()Description copied from interface:AudioBackendReturns the current frequency spectrum.- Specified by:
getSpectrumin interfaceAudioBackend- Returns:
- Array of magnitudes (usually 128 or 256 bands)
-