/** @method init @abstract Initialize a new engine. @discussion 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:`. */ public init() /** @method attachNode: @abstract Take ownership of a new node. @param node The node to be attached to the engine. @discussion 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];*/ open func attach(_ node: AVAudioNode) /** @method detachNode: @abstract Detach a node previously attached to the engine. @discussion If necessary, the engine will safely disconnect the node before detaching it. */ open func detach(_ node: AVAudioNode) /** @method connect:to:fromBus:toBus:format: @abstract Establish a connection between two nodes. @param node1 The source node @param node2 The destination node @param bus1 The output bus on the source node @param bus2 The input bus on the destination node @param 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 destination node's input bus is set to match that of the source node's output bus. @discussion 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. */ open func connect(_ node1: AVAudioNode, to node2: AVAudioNode, fromBus bus1: AVAudioNodeBus, toBus bus2: AVAudioNodeBus, format: AVAudioFormat?) /** @method connect:to:format: @abstract Establish a connection between two nodes @discussion 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. */ open func connect(_ node1: AVAudioNode, to node2: AVAudioNode, format: AVAudioFormat?) /** @method connect:toConnectionPoints:fromBus:format: @abstract Establish connections between a source node and multiple destination nodes. @param sourceNode The source node @param destNodes An array of AVAudioConnectionPoint objects specifying destination nodes and busses @param sourceBus The output bus on source node @param 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 destination nodes' input bus is set to match that of the source node's output bus @discussion 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 */ @available(OSX 10.11, *) open func connect(_ sourceNode: AVAudioNode, to destNodes: [AVAudioConnectionPoint], fromBus sourceBus: AVAudioNodeBus, format: AVAudioFormat?) /** @method disconnectNodeInput:bus: @abstract Remove a connection between two nodes. @param node The node whose input is to be disconnected @param bus The destination's input bus to disconnect */ open func disconnectNodeInput(_ node: AVAudioNode, bus: AVAudioNodeBus) /** @method disconnectNodeInput: @abstract Remove a connection between two nodes. @param node The node whose inputs are to be disconnected @discussion Connections are broken on each of the node's input busses. */ open func disconnectNodeInput(_ node: AVAudioNode) /** @method disconnectNodeOutput:bus: @abstract Remove a connection between two nodes. @param node The node whose output is to be disconnected @param bus The source's output bus to disconnect */ open func disconnectNodeOutput(_ node: AVAudioNode, bus: AVAudioNodeBus) /** @method disconnectNodeOutput: @abstract Remove a connection between two nodes. @param node The node whose outputs are to be disconnected @discussion Connections are broken on each of the node's output busses. */ open func disconnectNodeOutput(_ node: AVAudioNode) /** @method prepare @abstract Prepare the engine for starting. @discussion 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. */ open func prepare() /** @method startAndReturnError: @abstract Start the engine. @return YES for success @discussion 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. */ open func start() throws /** @method pause @abstract Pause the engine. @discussion 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. */ open func pause() /** @method reset @abstract reset Reset all of the nodes in the engine. @discussion 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. */ open func reset() /** @method stop @abstract 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. */ open func stop() /** @method inputConnectionPointForNode:inputBus: @abstract Get connection information on a node's input bus. @param node The node whose input connection is being queried. @param bus The node's input bus on which the connection is being queried. @return An AVAudioConnectionPoint object with connection information on the node's specified input bus. @discussion 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. */ @available(OSX 10.11, *) open func inputConnectionPoint(for node: AVAudioNode, inputBus bus: AVAudioNodeBus) -> AVAudioConnectionPoint? /** @method outputConnectionPointsForNode:outputBus: @abstract Get connection information on a node's output bus. @param node The node whose output connections are being queried. @param bus The node's output bus on which connections are being queried. @return An array of AVAudioConnectionPoint objects with connection information on the node's specified output bus. @discussion 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. */ @available(OSX 10.11, *) open func outputConnectionPoints(for node: AVAudioNode, outputBus bus: AVAudioNodeBus) -> [AVAudioConnectionPoint] /** @property musicSequence @abstract The MusicSequence previously attached to the engine (if any). */ open var musicSequence: MusicSequence? /** @property outputNode @abstract The engine's singleton output node. @discussion 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:`. */ open var outputNode: AVAudioOutputNode { get } /** @property inputNode @abstract The engine's singleton input node. @discussion 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:)`. */ @available(OSX 10.10, *) open var inputNode: AVAudioInputNode { get } /** @property mainMixerNode @abstract The engine's optional singleton main mixer node. @discussion 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. 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. */ open var mainMixerNode: AVAudioMixerNode { get } /** @property running @abstract The engine's running state. */ open var isRunning: Bool { get } /** @property autoShutdownEnabled @abstract 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. @discussion 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. */ @available(OSX 10.13, *) open var isAutoShutdownEnabled: Bool /** @property attachedNodes @abstract Set of all nodes attached to the engine. */ @available(OSX 10.15, *) open var attachedNodes: Set