Package apple.avfoundation
Class AVAudioEngine
- java.lang.Object
-
- org.moe.natj.general.NativeObject
-
- org.moe.natj.objc.ObjCObject
-
- apple.NSObject
-
- apple.avfoundation.AVAudioEngine
-
- All Implemented Interfaces:
NSObject
public class AVAudioEngine extends NSObject
AVAudioEngine An AVAudioEngine contains a group of connected AVAudioNodes ("nodes"), each of which performs an audio signal generation, processing, or input/output task. Nodes are created separately and attached to the engine. The engine supports dynamic connection, disconnection and removal of nodes while running, with only minor limitations: - all dynamic reconnections must occur upstream of a mixer - while removals of effects will normally result in the automatic connection of the adjacent nodes, removal of a node which has differing input vs. output channel counts, or which is a mixer, is likely to result in a broken graph. By default, the engine is connected to an audio device and automatically renders in realtime. It can also be configured to operate in manual rendering mode, i.e. not connected to an audio device and rendering in response to requests from the client, normally at or faster than realtime rate.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceAVAudioEngine.Block_connectMIDIToFormatBlockstatic interfaceAVAudioEngine.Block_connectMIDIToNodesFormatBlockstatic interfaceAVAudioEngine.Block_manualRenderingBlock_ret-
Nested classes/interfaces inherited from class apple.NSObject
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAVAudioEngine(org.moe.natj.general.Pointer peer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanaccessInstanceVariablesDirectly()static AVAudioEnginealloc()static java.lang.ObjectallocWithZone(org.moe.natj.general.ptr.VoidPtr zone)NSSet<? extends AVAudioNode>attachedNodes()[@property] attachedNodes Set of all nodes attached to the engine.voidattachNode(AVAudioNode node)attachNode: Take ownership of a new node.static booleanautomaticallyNotifiesObserversForKey(java.lang.String key)static voidcancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)static voidcancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)static NSArray<java.lang.String>classFallbacksForKeyedArchiver()static org.moe.natj.objc.ClassclassForKeyedUnarchiver()voidconnectMIDIToFormatBlock(AVAudioNode sourceNode, AVAudioNode destinationNode, AVAudioFormat format, AVAudioEngine.Block_connectMIDIToFormatBlock tapBlock)connectMIDI:to:format:block: Establish a MIDI only connection between two nodes.voidconnectMIDIToNodesFormatBlock(AVAudioNode sourceNode, NSArray<? extends AVAudioNode> destinationNodes, AVAudioFormat format, AVAudioEngine.Block_connectMIDIToNodesFormatBlock tapBlock)connectMIDI:toNodes:format:block: Establish a MIDI only connection between a source node and multiple destination nodes.voidconnectToConnectionPointsFromBusFormat(AVAudioNode sourceNode, NSArray<? extends AVAudioConnectionPoint> destNodes, long sourceBus, AVAudioFormat format)connect:toConnectionPoints:fromBus:format: Establish connections between a source node and multiple destination nodes.voidconnectToFormat(AVAudioNode node1, AVAudioNode node2, AVAudioFormat format)connect:to:format: Establish a connection between two nodes This calls connect:to:fromBus:toBus:format: using bus 0 on the source node, and bus 0 on the destination node, except in the case of a destination which is a mixer, in which case the destination is the mixer's nextAvailableInputBus.voidconnectToFromBusToBusFormat(AVAudioNode node1, AVAudioNode node2, long bus1, long bus2, AVAudioFormat format)connect:to:fromBus:toBus:format: Establish a connection between two nodes.static java.lang.StringdebugDescription_static()static java.lang.Stringdescription_static()voiddetachNode(AVAudioNode node)detachNode: Detach a node previously attached to the engine.voiddisableManualRenderingMode()disableManualRenderingMode Set the engine to render to/from an audio device.voiddisconnectMIDIFrom(AVAudioNode sourceNode, AVAudioNode destinationNode)disconnectMIDI:from: Remove a MIDI connection between two nodes.voiddisconnectMIDIFromNodes(AVAudioNode sourceNode, NSArray<? extends AVAudioNode> destinationNodes)disconnectMIDI:fromNodes: Remove a MIDI connection between one source node and multiple destination nodes.voiddisconnectMIDIInput(AVAudioNode node)disconnectMIDIInput: Disconnects all input MIDI connections of this node.voiddisconnectMIDIOutput(AVAudioNode node)disconnectMIDIOutput: Disconnects all output MIDI connections of this node.voiddisconnectNodeInput(AVAudioNode node)disconnectNodeInput: Remove a connection between two nodes.voiddisconnectNodeInputBus(AVAudioNode node, long bus)disconnectNodeInput:bus: Remove a connection between two nodes.voiddisconnectNodeOutput(AVAudioNode node)disconnectNodeOutput: Remove a connection between two nodes.voiddisconnectNodeOutputBus(AVAudioNode node, long bus)disconnectNodeOutput:bus: Remove a connection between two nodes.booleanenableManualRenderingModeFormatMaximumFrameCountError(long mode, AVAudioFormat pcmFormat, int maximumFrameCount, org.moe.natj.general.ptr.Ptr<NSError> outError)enableManualRenderingMode:format:maximumFrameCount:error: Set the engine to operate in a manual rendering mode with the specified render format and maximum frame count.static longhash_static()AVAudioEngineinit()init Initialize a new engine.AVAudioConnectionPointinputConnectionPointForNodeInputBus(AVAudioNode node, long bus)inputConnectionPointForNode:inputBus: Get connection information on a node's input bus.AVAudioInputNodeinputNode()[@property] inputNode The engine's singleton input node.static NSObject.Function_instanceMethodForSelector_retinstanceMethodForSelector(org.moe.natj.objc.SEL aSelector)static NSMethodSignatureinstanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)static booleaninstancesRespondToSelector(org.moe.natj.objc.SEL aSelector)booleanisAutoShutdownEnabled()[@property] autoShutdownEnabled When auto shutdown is enabled, the engine can start and stop the audio hardware dynamically, to conserve power.booleanisInManualRenderingMode()[@property] isInManualRenderingMode Whether or not the engine is operating in manual rendering mode, i.e. not connected to an audio device and rendering in response to the requests from the clientbooleanisRunning()[@property] running The engine's running state.static booleanisSubclassOfClass(org.moe.natj.objc.Class aClass)static NSSet<java.lang.String>keyPathsForValuesAffectingValueForKey(java.lang.String key)AVAudioMixerNodemainMixerNode()[@property] mainMixerNode The engine's optional singleton main mixer node.AVAudioEngine.Block_manualRenderingBlock_retmanualRenderingBlock()[@property] manualRenderingBlock Block to render the engine operating in manual rendering mode This block based render call must be used to render the engine when operating in `AVAudioEngineManualRenderingModeRealtime`.AVAudioFormatmanualRenderingFormat()[@property] manualRenderingFormat The render format of the engine in manual rendering mode.intmanualRenderingMaximumFrameCount()[@property] manualRenderingMaximumFrameCount The maximum number of PCM sample frames the engine can produce in any single render call in the manual rendering mode.longmanualRenderingMode()[@property] manualRenderingMode The manual rendering mode configured on the engine This property is meaningful only when the engine is operating in manual rendering mode, i.e. when `isInManualRenderingMode` returns true.longmanualRenderingSampleTime()[@property] manualRenderingSampleTime Indicates where the engine is on its render timeline in manual rendering mode.MusicSequencemusicSequence()[@property] musicSequence The MusicSequence previously attached to the engine (if any).static java.lang.Objectnew_objc()NSArray<? extends AVAudioConnectionPoint>outputConnectionPointsForNodeOutputBus(AVAudioNode node, long bus)outputConnectionPointsForNode:outputBus: Get connection information on a node's output bus.AVAudioOutputNodeoutputNode()[@property] outputNode The engine's singleton output node.voidpause()pause Pause the engine.voidprepare()prepare Prepare the engine for starting.longrenderOfflineToBufferError(int numberOfFrames, AVAudioPCMBuffer buffer, org.moe.natj.general.ptr.Ptr<NSError> outError)renderOffline:toBuffer:error: Render call to the engine operating in the offline manual rendering modevoidreset()reset reset Reset all of the nodes in the engine.static booleanresolveClassMethod(org.moe.natj.objc.SEL sel)static booleanresolveInstanceMethod(org.moe.natj.objc.SEL sel)voidsetAutoShutdownEnabled(boolean value)[@property] autoShutdownEnabled When auto shutdown is enabled, the engine can start and stop the audio hardware dynamically, to conserve power.voidsetMusicSequence(MusicSequence value)[@property] musicSequence The MusicSequence previously attached to the engine (if any).static voidsetVersion_static(long aVersion)booleanstartAndReturnError(org.moe.natj.general.ptr.Ptr<NSError> outError)startAndReturnError: Start the engine.voidstop()stop When the engine is rendering to/from an audio device, stops the audio hardware and the engine.static org.moe.natj.objc.Classsuperclass_static()static longversion_static()-
Methods inherited from class apple.NSObject
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKey
-
-
-
-
Method Detail
-
accessInstanceVariablesDirectly
public static boolean accessInstanceVariablesDirectly()
-
alloc
public static AVAudioEngine alloc()
-
allocWithZone
public static java.lang.Object allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
-
automaticallyNotifiesObserversForKey
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
-
cancelPreviousPerformRequestsWithTarget
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
-
cancelPreviousPerformRequestsWithTargetSelectorObject
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)
-
classFallbacksForKeyedArchiver
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
-
classForKeyedUnarchiver
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
-
debugDescription_static
public static java.lang.String debugDescription_static()
-
description_static
public static java.lang.String description_static()
-
hash_static
public static long hash_static()
-
instanceMethodForSelector
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
-
instanceMethodSignatureForSelector
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
-
instancesRespondToSelector
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
-
isSubclassOfClass
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
-
keyPathsForValuesAffectingValueForKey
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
-
new_objc
public static java.lang.Object new_objc()
-
resolveClassMethod
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
-
resolveInstanceMethod
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
-
setVersion_static
public static void setVersion_static(long aVersion)
-
superclass_static
public static org.moe.natj.objc.Class superclass_static()
-
version_static
public static long version_static()
-
attachNode
public void attachNode(AVAudioNode node)
attachNode: Take ownership of a new node.- Parameters:
node- The node to be attached to the engine. To support the instantiation of arbitrary AVAudioNode subclasses, instances are created externally to the engine, but are not usable until they are attached to the engine via this method. Thus the idiom, without ARC, is: ``` // when building engine: AVAudioNode *_player; // member of controller class (for example) ... _player = [[AVAudioPlayerNode alloc] init]; [engine attachNode: _player]; ... // when destroying engine (without ARC) [_player release]; ```
-
connectToFormat
public void connectToFormat(AVAudioNode node1, AVAudioNode node2, AVAudioFormat format)
connect:to:format: Establish a connection between two nodes This calls connect:to:fromBus:toBus:format: using bus 0 on the source node, and bus 0 on the destination node, except in the case of a destination which is a mixer, in which case the destination is the mixer's nextAvailableInputBus.
-
connectToFromBusToBusFormat
public void connectToFromBusToBusFormat(AVAudioNode node1, AVAudioNode node2, long bus1, long bus2, AVAudioFormat format)
connect:to:fromBus:toBus:format: Establish a connection between two nodes.- Parameters:
node1- The source nodenode2- The destination nodebus1- The output bus on the source nodebus2- The input bus on the destination nodeformat- If non-nil, the format of the source node's output bus is set to this format. In all cases, the format of the destination node's input bus is set to match that of the source node's output bus. Nodes have input and output buses (AVAudioNodeBus). Use this method to establish one-to-one connections betweeen nodes. Connections made using this method are always one-to-one, never one-to-many or many-to-one. Note that any pre-existing connection(s) involving the source's output bus or the destination's input bus will be broken.
-
connectToConnectionPointsFromBusFormat
public void connectToConnectionPointsFromBusFormat(AVAudioNode sourceNode, NSArray<? extends AVAudioConnectionPoint> destNodes, long sourceBus, AVAudioFormat format)
connect:toConnectionPoints:fromBus:format: Establish connections between a source node and multiple destination nodes.- Parameters:
sourceNode- The source nodedestNodes- An array of AVAudioConnectionPoint objects specifying destination nodes and bussessourceBus- The output bus on source nodeformat- If non-nil, the format of the source node's output bus is set to this format. In all cases, the format of the destination nodes' input bus is set to match that of the source node's output bus Use this method to establish connections from a source node to multiple destination nodes. Connections made using this method are either one-to-one (when a single destination connection is specified) or one-to-many (when multiple connections are specified), but never many-to-one. To incrementally add a new connection to a source node, use this method with an array of AVAudioConnectionPoint objects comprising of pre-existing connections (obtained from `outputConnectionPointsForNode:outputBus:`) and the new connection. Note that any pre-existing connection involving the destination's input bus will be broken. And, any pre-existing connection on source node which is not a part of the specified destination connection array will also be broken. Also note that when the output of a node is split into multiple paths, all the paths must render at the same rate until they reach a common mixer. In other words, starting from the split node until the common mixer node where all split paths terminate, you cannot have: - any AVAudioUnitTimeEffect - any sample rate conversion
-
detachNode
public void detachNode(AVAudioNode node)
detachNode: Detach a node previously attached to the engine. If necessary, the engine will safely disconnect the node before detaching it.
-
disconnectNodeInput
public void disconnectNodeInput(AVAudioNode node)
disconnectNodeInput: Remove a connection between two nodes.- Parameters:
node- The node whose inputs are to be disconnected Connections are broken on each of the node's input busses.
-
disconnectNodeInputBus
public void disconnectNodeInputBus(AVAudioNode node, long bus)
disconnectNodeInput:bus: Remove a connection between two nodes.- Parameters:
node- The node whose input is to be disconnectedbus- The destination's input bus to disconnect
-
disconnectNodeOutput
public void disconnectNodeOutput(AVAudioNode node)
disconnectNodeOutput: Remove a connection between two nodes.- Parameters:
node- The node whose outputs are to be disconnected Connections are broken on each of the node's output busses.
-
disconnectNodeOutputBus
public void disconnectNodeOutputBus(AVAudioNode node, long bus)
disconnectNodeOutput:bus: Remove a connection between two nodes.- Parameters:
node- The node whose output is to be disconnectedbus- The source's output bus to disconnect
-
init
public AVAudioEngine init()
init Initialize a new engine. On creation, the engine is by default connected to an audio device and automatically renders in realtime. It can be configured to operate in manual rendering mode through `enableManualRenderingMode:format:maximumFrameCount:error:`.
-
inputConnectionPointForNodeInputBus
public AVAudioConnectionPoint inputConnectionPointForNodeInputBus(AVAudioNode node, long bus)
inputConnectionPointForNode:inputBus: Get connection information on a node's input bus.- Parameters:
node- The node whose input connection is being queried.bus- The node's input bus on which the connection is being queried.- Returns:
- An AVAudioConnectionPoint object with connection information on the node's specified input bus. Connections are always one-to-one or one-to-many, never many-to-one. Returns nil if there is no connection on the node's specified input bus.
-
inputNode
public AVAudioInputNode inputNode()
[@property] inputNode The engine's singleton input node. Audio input is performed via an input node. The engine creates a singleton on demand when this property is first accessed. To receive input, connect another node from the output of the input node, or create a recording tap on it. When the engine is rendering to/from an audio device, the AVAudioSesssion category and/or availability of hardware determine whether an app can perform input (e.g. input hardware is not available on tvos). Check for the input node's input format (i.e. hardware format) for non-zero sample rate and channel count to see if input is enabled. Trying to perform input through the input node when it is not enabled or available will cause the engine to throw an error (when possible) or an exception. In manual rendering mode, the input node can be used to synchronously supply data to the engine while it is rendering (see `AVAudioInputNode(setManualRenderingInputPCMFormat:inputBlock:)`.
-
isRunning
public boolean isRunning()
[@property] running The engine's running state.
-
mainMixerNode
public AVAudioMixerNode mainMixerNode()
[@property] mainMixerNode The engine's optional singleton main mixer node. The engine will construct a singleton main mixer and connect it to the outputNode on demand, when this property is first accessed. You can then connect additional nodes to the mixer. If the client has never explicitly set the connection format between the mainMixerNode and the outputNode, the engine will always set/update the format to track the format of the outputNode on (re)start, even after an AVAudioEngineConfigurationChangeNotification. Otherwise, it's the client's responsibility to set/update this connection format after an AVAudioEngineConfigurationChangeNotification. By default, the mixer's output format (sample rate and channel count) will track the format of the output node. You may however make the connection explicitly with a different format.
-
musicSequence
public MusicSequence musicSequence()
[@property] musicSequence The MusicSequence previously attached to the engine (if any).
-
outputConnectionPointsForNodeOutputBus
public NSArray<? extends AVAudioConnectionPoint> outputConnectionPointsForNodeOutputBus(AVAudioNode node, long bus)
outputConnectionPointsForNode:outputBus: Get connection information on a node's output bus.- Parameters:
node- The node whose output connections are being queried.bus- The node's output bus on which connections are being queried.- Returns:
- An array of AVAudioConnectionPoint objects with connection information on the node's specified output bus. Connections are always one-to-one or one-to-many, never many-to-one. Returns an empty array if there are no connections on the node's specified output bus.
-
outputNode
public AVAudioOutputNode outputNode()
[@property] outputNode The engine's singleton output node. Audio output is performed via an output node. The engine creates a singleton on demand when this property is first accessed. Connect another node to the input of the output node, or obtain a mixer that is connected there by default, using the "mainMixerNode" property. When the engine is rendering to/from an audio device, the AVAudioSesssion category and/or availability of hardware determine whether an app can perform output. Check the output format of output node (i.e. hardware format) for non-zero sample rate and channel count to see if output is enabled. Trying to perform output through the output node when it is not enabled or available will cause the engine to throw an error (when possible) or an exception. In manual rendering mode, the output format of the output node will determine the render format of the engine. It can be changed through `enableManualRenderingMode:format:maximumFrameCount:error:`.
-
pause
public void pause()
pause Pause the engine. When the engine is rendering to/from an audio device, stops the audio hardware and the flow of audio through the engine. When operating in this mode, it is recommended that the engine be paused or stopped (as applicable) when not in use, to minimize power consumption. Pausing the engine does not deallocate the resources allocated by prepare. Resume the engine by invoking start again.
-
prepare
public void prepare()
prepare Prepare the engine for starting. This method preallocates many of the resources the engine requires in order to start. It can be used to be able to start more responsively.
-
reset
public void reset()
reset reset Reset all of the nodes in the engine. This will reset all of the nodes in the engine. This is useful, for example, for silencing reverb and delay tails. In manual rendering mode, the render timeline is reset to a sample time of zero.
-
setMusicSequence
public void setMusicSequence(MusicSequence value)
[@property] musicSequence The MusicSequence previously attached to the engine (if any).
-
startAndReturnError
public boolean startAndReturnError(org.moe.natj.general.ptr.Ptr<NSError> outError)
startAndReturnError: Start the engine.- Returns:
- YES for success Calls prepare if it has not already been called since stop. When the engine is rendering to/from an audio device, starts the audio hardware via the AVAudioInputNode and/or AVAudioOutputNode instances in the engine. Audio begins to flow through the engine. Reasons for potential failure to start in this mode include: 1. There is problem in the structure of the graph. Input can't be routed to output or to a recording tap through converter type nodes. 2. An AVAudioSession error. 3. The driver failed to start the hardware. In manual rendering mode, prepares the engine to render when requested by the client.
-
stop
public void stop()
stop When the engine is rendering to/from an audio device, stops the audio hardware and the engine. When operating in this mode, it is recommended that the engine be paused or stopped (as applicable) when not in use, to minimize power consumption. Stopping the engine releases the resources allocated by prepare.
-
disableManualRenderingMode
public void disableManualRenderingMode()
disableManualRenderingMode Set the engine to render to/from an audio device. When disabling the manual rendering mode, the engine: 1. Stops and resets itself (see `stop` and `reset`). 2. Switches the output/input nodes to render to/from an audio device. Their input and output formats may change. 3. Removes any taps previously installed on the input and output nodes. 4. Maintains all the engine connections as is. Calling this method when the engine is already rendering to/from an audio device has no effect.
-
enableManualRenderingModeFormatMaximumFrameCountError
public boolean enableManualRenderingModeFormatMaximumFrameCountError(long mode, AVAudioFormat pcmFormat, int maximumFrameCount, org.moe.natj.general.ptr.Ptr<NSError> outError)enableManualRenderingMode:format:maximumFrameCount:error: Set the engine to operate in a manual rendering mode with the specified render format and maximum frame count.- Parameters:
mode- The manual rendering mode to use.pcmFormat- The format of the output PCM audio data from the engine.maximumFrameCount- The maximum number of PCM sample frames the engine will be asked to produce in any single render call.outError- On exit, if the engine cannot switch to the manual rendering mode, a description of the error (see `AVAudioEngineManualRenderingError` for the possible errors).- Returns:
- YES for success. Use this method to configure the engine to render in response to requests from the client. The engine must be in a stopped state before calling this method. The render format must be a PCM format and match the format of the buffer to which the engine is asked to render (see `renderOffline:toBuffer:error:`). It is advised to enable manual rendering mode soon after the engine is created, and before accessing any of mainMixerNode, inputNode or outputNode of the engine. Otherwise, accessing or interacting with the engine before enabling manual rendering mode could have the unintended side-effect of configuring the hardware for device-rendering mode. The input data in manual rendering mode can be supplied through the source nodes, e.g. `AVAudioPlayerNode`, `AVAudioInputNode` etc. When switching to manual rendering mode, the engine: 1. Switches the input and output nodes to manual rendering mode. Their input and output formats may change. 2. Removes any taps previously installed on the input and output nodes. 3. Maintains all the engine connections as is. Reasons for potential failure when switching to manual rendering mode include: - Engine is not in a stopped state.
-
isAutoShutdownEnabled
public boolean isAutoShutdownEnabled()
[@property] autoShutdownEnabled When auto shutdown is enabled, the engine can start and stop the audio hardware dynamically, to conserve power. This is the enforced behavior on watchOS and can be optionally enabled on other platforms. To conserve power, it is advised that the client pause/stop the engine when not in use. But when auto shutdown is enabled, the engine will stop the audio hardware if it was running idle for a certain duration, and restart it later when required. Note that, because this operation is dynamic, it may affect the start times of the source nodes (e.g. `AVAudioPlayerNode`), if the engine has to resume from its shutdown state. On watchOS, auto shutdown is always enabled. On other platforms, it is disabled by default, but the client can enable it if needed. This property is applicable only when the engine is rendering to/from an audio device. If the value is changed when the engine is in manual rendering mode, it will take effect whenever the engine is switched to render to/from the audio device.
-
isInManualRenderingMode
public boolean isInManualRenderingMode()
[@property] isInManualRenderingMode Whether or not the engine is operating in manual rendering mode, i.e. not connected to an audio device and rendering in response to the requests from the client
-
manualRenderingBlock
public AVAudioEngine.Block_manualRenderingBlock_ret manualRenderingBlock()
[@property] manualRenderingBlock Block to render the engine operating in manual rendering mode This block based render call must be used to render the engine when operating in `AVAudioEngineManualRenderingModeRealtime`. In this mode, the engine operates under realtime constraints and will not make any blocking call (e.g. calling libdispatch, blocking on a mutex, allocating memory etc.) while rendering. Before invoking the rendering functionality, client must fetch this block and cache the result. The block can then be called from a realtime context, without any possibility of blocking. When rendering in `AVAudioEngineManualRenderingModeOffline`, either this block based render call or `renderOffline:toBuffer:error:` ObjC method can be used. All the rules outlined in `renderOffline:toBuffer:error:` are applicable here as well.
-
manualRenderingFormat
public AVAudioFormat manualRenderingFormat()
[@property] manualRenderingFormat The render format of the engine in manual rendering mode. Querying this property when the engine is not in manual rendering mode will return an invalid format, with zero sample rate and channel count.
-
manualRenderingMaximumFrameCount
public int manualRenderingMaximumFrameCount()
[@property] manualRenderingMaximumFrameCount The maximum number of PCM sample frames the engine can produce in any single render call in the manual rendering mode. Querying this property when the engine is not in manual rendering mode will return zero.
-
manualRenderingMode
public long manualRenderingMode()
[@property] manualRenderingMode The manual rendering mode configured on the engine This property is meaningful only when the engine is operating in manual rendering mode, i.e. when `isInManualRenderingMode` returns true.
-
manualRenderingSampleTime
public long manualRenderingSampleTime()
[@property] manualRenderingSampleTime Indicates where the engine is on its render timeline in manual rendering mode. The timeline in manual rendering mode starts at a sample time of zero, and is in terms of the render format's sample rate. Resetting the engine (see `reset`) will reset the timeline back to zero.
-
renderOfflineToBufferError
public long renderOfflineToBufferError(int numberOfFrames, AVAudioPCMBuffer buffer, org.moe.natj.general.ptr.Ptr<NSError> outError)renderOffline:toBuffer:error: Render call to the engine operating in the offline manual rendering mode- Parameters:
numberOfFrames- The number of PCM sample frames to be renderedbuffer- The PCM buffer to which the engine must render the audiooutError- On exit, if an error occurs during rendering, a description of the error (see `AVAudioEngineManualRenderingError` for the possible errors)- Returns:
- One of the status codes from `AVAudioEngineManualRenderingStatus`. Irrespective of the returned status code, on exit, the output buffer's frameLength will indicate the number of PCM samples rendered by the engine The engine must be in the offline manual rendering mode (`AVAudioEngineManualRenderingModeOffline`) and started before calling this method. The format of the buffer must match the render format set through `enableManualRenderingMode:format:maximumFrameCount:error:`. The buffer capacity must be greater than or equal to the number of samples asked to render. On exit, the buffer's frameLength will indicate the number of PCM samples rendered by the engine. The engine's timeline in manual rendering mode starts at a sample time of zero, and is in terms of the render format's sample rate. Resetting the engine (see `reset`) will reset the timeline back to zero. When rendering in `AVAudioEngineManualRenderingModeRealtime`, this ObjC render method must not be used, an error is returned otherwise. Use the block based render call (`manualRenderingBlock`) in that mode instead.
-
setAutoShutdownEnabled
public void setAutoShutdownEnabled(boolean value)
[@property] autoShutdownEnabled When auto shutdown is enabled, the engine can start and stop the audio hardware dynamically, to conserve power. This is the enforced behavior on watchOS and can be optionally enabled on other platforms. To conserve power, it is advised that the client pause/stop the engine when not in use. But when auto shutdown is enabled, the engine will stop the audio hardware if it was running idle for a certain duration, and restart it later when required. Note that, because this operation is dynamic, it may affect the start times of the source nodes (e.g. `AVAudioPlayerNode`), if the engine has to resume from its shutdown state. On watchOS, auto shutdown is always enabled. On other platforms, it is disabled by default, but the client can enable it if needed. This property is applicable only when the engine is rendering to/from an audio device. If the value is changed when the engine is in manual rendering mode, it will take effect whenever the engine is switched to render to/from the audio device.
-
attachedNodes
public NSSet<? extends AVAudioNode> attachedNodes()
[@property] attachedNodes Set of all nodes attached to the engine.
-
connectMIDIToFormatBlock
public void connectMIDIToFormatBlock(AVAudioNode sourceNode, AVAudioNode destinationNode, AVAudioFormat format, AVAudioEngine.Block_connectMIDIToFormatBlock tapBlock)
connectMIDI:to:format:block: Establish a MIDI only connection between two nodes.- Parameters:
sourceNode- The source node.destinationNode- The destination node.format- If non-nil, the format of the source node's output bus is set to this format. In all cases, the format of the source nodes' output bus has to match with the destination nodes' output bus format. Although the output bus of the source is not in use, the format needs to be set in order to be able to use the sample rate for MIDI event timing calculations.tapBlock- If non-nil, this block is called from the source node's `AUMIDIOutputEventBlock` on the realtime thread. The host can tap the MIDI data of the source node through this block. May be nil. Use this method to establish a MIDI only connection between a source node and a destination node that has MIDI input capability. The source node can only be a AVAudioUnit node of type `kAudioUnitType_MIDIProcessor`. The destination node types can be `kAudioUnitType_MusicDevice`, `kAudioUnitType_MusicEffect` or `kAudioUnitType_MIDIProcessor`. Note that any pre-existing MIDI connection involving the destination will be broken. Any client installed block on the source node's audio unit `AUMIDIOutputEventBlock` will be overwritten when making the MIDI connection.
-
connectMIDIToNodesFormatBlock
public void connectMIDIToNodesFormatBlock(AVAudioNode sourceNode, NSArray<? extends AVAudioNode> destinationNodes, AVAudioFormat format, AVAudioEngine.Block_connectMIDIToNodesFormatBlock tapBlock)
connectMIDI:toNodes:format:block: Establish a MIDI only connection between a source node and multiple destination nodes.- Parameters:
sourceNode- The source node.destinationNodes- An array of AVAudioNodes specifying destination nodes.format- If non-nil, the format of the source node's output bus is set to this format. In all cases, the format of the source nodes' output bus has to match with the destination nodes' output bus format. Although the output bus of the source is not in use, the format needs to be set in order to be able to use the sample rate for MIDI event timing calculations.tapBlock- If non-nil, this block is called from the source node's `AUMIDIOutputEventBlock` on the realtime thread. The host can tap the MIDI data of the source node through this block. May be nil. Use this method to establish a MIDI only connection between a source node and multiple destination nodes. The source node can only be a AVAudioUnit node of type `kAudioUnitType_MIDIProcessor`. The destination node types can be `kAudioUnitType_MusicDevice`, `kAudioUnitType_MusicEffect` or `kAudioUnitType_MIDIProcessor`. MIDI connections made using this method are either one-to-one (when a single destination connection is specified) or one-to-many (when multiple connections are specified), but never many-to-one. Note that any pre-existing connection involving the destination will be broken. Any client installed block on the source node's audio unit `AUMIDIOutputEventBlock` will be overwritten when making the MIDI connection.
-
disconnectMIDIFrom
public void disconnectMIDIFrom(AVAudioNode sourceNode, AVAudioNode destinationNode)
disconnectMIDI:from: Remove a MIDI connection between two nodes.- Parameters:
sourceNode- The node whose MIDI output is to be disconnected.destinationNode- The node whose MIDI input is to be disconnected. If a tap block is installed on the source node, it will be removed when the last connection from the source node is removed.
-
disconnectMIDIFromNodes
public void disconnectMIDIFromNodes(AVAudioNode sourceNode, NSArray<? extends AVAudioNode> destinationNodes)
disconnectMIDI:fromNodes: Remove a MIDI connection between one source node and multiple destination nodes.- Parameters:
sourceNode- The node whose MIDI output is to be disconnected.destinationNodes- An array of AVAudioNodes specifying nodes whose MIDI input is to be disconnected. If a tap block is installed on the source node, it will be removed when the last connection from the source node is removed.
-
disconnectMIDIInput
public void disconnectMIDIInput(AVAudioNode node)
disconnectMIDIInput: Disconnects all input MIDI connections of this node.- Parameters:
node- The node whose MIDI input is to be disconnected.
-
disconnectMIDIOutput
public void disconnectMIDIOutput(AVAudioNode node)
disconnectMIDIOutput: Disconnects all output MIDI connections of this node.- Parameters:
node- The node whose MIDI outputs are to be disconnected.
-
-