Super class: AVAudioNodeMBS
|Type||Topic||Plugin||Version||macOS||Windows||Linux||Console & Web||iOS|
|class||AVFoundationNode||MBS AVFoundation Plugin||15.3||Yes||No||No||Yes, macOS only||No|
AVAudioPlayerNode supports scheduling the playback of AVAudioBuffer instances, or segments of audio files opened via AVAudioFile. Buffers and segments may be scheduled at specific points in time, or to play immediately following preceding segments.
Normally, you will want to configure the node’s output format with the same number of channels as are in the files and buffers to be played. Otherwise, channels will be dropped or added as required. It is usually better to use an AVAudioMixerNode to do this.
Similarly, when playing file segments, the node will sample rate convert if necessary, but it is often preferable to configure the node’s output sample rate to match that of the file(s) and use a mixer to perform the rate conversion.
When playing buffers, there is an implicit assumption that the buffers are at the same sample rate as the node’s output format.
This class overrides the AVAudioNode method reset and unschedules all previously scheduled buffers and file segments, and also returns the player timeline to sample time 0.
The usual AVAudioNode sample times (as observed by lastRenderTime ) have an arbitrary zero point. AVAudioPlayerNode superimposes a second “player timeline” on top of this, to reflect when the player was started, and intervals during which it was paused. The methods nodeTimeForPlayerTime and playerTimeForNodeTime convert between the two.
Scheduling Playback Time
The scheduleBuffer, scheduleFile, and scheduleSegment methods take an AVAudioTime when parameter. This is interpreted as follows:
If the when parameter is nil:
- If there have been previous commands, the new one is played immediately following the last one.
- Otherwise, if the node is playing, the event is played in the very near future.
- Otherwise, the command is played at sample time 0.
- If the when parameter is a sample time, the parameter is interpreted as such.
- If the when parameter is a host time it is ignored unless sample time not valid.
The scheduling methods will fail if:
- A buffer's channel count does not match that of the node's output format.
- A file can't be accessed.
- An AVAudioTime specifies neither a valid sample time or host time.
- A segment's start frame or frame count is negative.
- 3 events
- event scheduleBufferCompleted(buffer as AVAudioPCMBufferMBS, time as AVAudioTimeMBS, options as Integer, tag as Variant)
- event scheduleFileCompleted(file as AVAudioFileMBS, time as AVAudioTimeMBS, tag as Variant)
- event scheduleSegmentCompleted(file as AVAudioFileMBS, startFrame as Int64, frameCount as Int64, time as AVAudioTimeMBS, tag as Variant)
- 9 properties
- 12 methods
- method Constructor
- method nodeTimeForPlayerTime(playerTime as AVAudioTimeMBS) as AVAudioTimeMBS
- method pause
- method play
- method playAtTime(time as AVAudioTimeMBS = nil)
- method playerTimeForNodeTime(nodeTime as AVAudioTimeMBS) as AVAudioTimeMBS
- method prepareWithFrameCount(frameCount as UInt32)
- method scheduleBuffer(buffer as AVAudioPCMBufferMBS, tag as Variant = nil)
- method scheduleBuffer(buffer as AVAudioPCMBufferMBS, time as AVAudioTimeMBS, options as Integer, tag as Variant = nil)
- method scheduleFile(file as AVAudioFileMBS, time as AVAudioTimeMBS, tag as Variant = nil)
- method scheduleSegment(file as AVAudioFileMBS, time as AVAudioTimeMBS, startFrame as Int64, frameCount as Int64, tag as Variant = nil)
- method stop
- 3 constants
Options controlling buffer scheduling
The buffer interrupts any buffer already playing.
The buffer interrupts any buffer already playing, at its loop point.
The buffer loops indefinitely.
Super class AVAudioNodeMBS
- event Tap(bus as Integer, bufferSize as UInt32, format as AVAudioFormatMBS, buffer as AVAudioPCMBufferMBS, time as AVAudioTimeMBS, tag as Variant)
- 5 properties
- 8 methods
- method Constructor
- method inputFormatForBus(busIndex as Integer) as AVAudioFormatMBS
- method installTapOnBus(busIndex as Integer, bufferSize as UInt32 = 0, format as AVAudioFormatMBS = nil, tag as Variant = nil)
- method nameForInputBus(busIndex as Integer) as string
- method nameForOutputBus(busIndex as Integer) as string
- method outputFormatForBus(busIndex as Integer) as AVAudioFormatMBS
- method removeTapOnBus(busIndex as Integer)
- method reset
- shared method available as boolean
This class has no sub classes.
Some examples which use this class:
- /AVFoundation/AVAudioEngine/Player with AudioUnit for Level Meter
The items on this page are in the following plugins: MBS AVFoundation Plugin.
MBS FileMaker Plugins