Skip to content

Latest commit

 

History

History
345 lines (334 loc) · 53.1 KB

AVFAudio.md

File metadata and controls

345 lines (334 loc) · 53.1 KB

AVFAudio

Symbols: 73.7% of Apple's iOS API (1040 of 1412, exact) · Rows: 15: 13 ✅ 2 ❌ · iOS: 14.5+

Area: Media · Apple: AVFAudio · Issues: area:media

How isim implements it

  • Adapted: implemented inside isim's AVFoundation overlay (AVAudioEngine.swift, AVFoundation.swift): the audio graph, players, recorders, sessions and speech synthesis (espeak-ng). Rows for the classes: AVFoundation.
  • Module: import AVFAudio is a module that re-exports AVFoundation (isim/swift/overlays/AVFAudio.swift): on iOS AVFoundation re-exports AVFAudio, in isim both names reach the same classes.
  • Objective-C: <AVFAudio/AVFAudio.h> imports AVFoundation's header, and AVFAudio.framework re-exports AVFoundation.framework (isim/sdk-src/Frameworks/AVFAudio). Since #553 its headers (AVAudioFormat.h, AVAudioBuffer.h, AVAudioConverter.h, AVAudioFile.h, AVAudioEngine.h, AVAudioNode.h and the node and unit headers, AVAudioPlayer.h, AVAudioRecorder.h, …) declare the engine, nodes, formats, buffers, converter, file, player and recorder over the overlay's classes, which are @objc(AVAudio…) with Apple's selectors. Swift-only members (enums, option sets, the AVAudio3D… structs) have internal Objective-C entry points (AVFAudioObjC.swift) and categories in AVFoundation.framework. The MIDI playback classes (#389) are in AVAudioUnitMIDIInstrument.h, AVAudioUnitSampler.h, AVMIDIPlayer.h, AVAudioSequencer.h and AVMusicEvents.h; AVBeatRange, the load options and the beat-range methods go through the _isim_ entry points of AVMIDI.swift.

API

API / feature Status iOS Notes
import AVFAudio ✅ 14.5 adapted: re-exports isim's AVFoundation, so it brings AVFoundation's other names too. Tested (HelloAudioModules)
#import <AVFAudio/AVFAudio.h>, -framework AVFAudio ✅ 14.5 adapted: AVFoundation's Objective-C header (AVAudioSession and the rest of what isim declares there). Tested (AudioHeadersTest)
Objective-C: AVAudioFormat, AVAudioChannelLayout, AVAudioTime, AVAudioPCMBuffer, AVAudioCompressedBuffer, AVAudioConverter (buffer to buffer, input block, prime method / info), AVAudioFile, AVAudioEngine (connections, manual rendering and its block), AVAudioNode and its subclasses (player, mixer, input / output, source, sink, environment with the AVAudio3D… structs, the unit effects and time effects, generator), AVAudioMixing, AVAudioPlayer, AVAudioRecorder and their delegates, the settings keys, AVAudioEngineConfigurationChangeNotification ✅ ≤17 adapted: the Swift classes under Apple's Objective-C names and selectors (AVFAudioObjC.swift, frameworks/AVFoundation/AVFoundation.m); the classes are not subclassable from Objective-C. Tested (AVFAudioObjCTest: formats, conversion and AAC, a WAV file, an offline engine with EQ / reverb / source / 3D environment nodes, a player and a recorder with their delegates)
AVAudioConverter: init(from:to:), convert(to:from:), convert(to:error:withInputFrom:) (AVAudioConverterInputBlock, AVAudioConverterInputStatus, AVAudioConverterOutputStatus), reset, channelMap, downmix, dither, sampleRateConverterQuality / Algorithm, primeMethod / primeInfo, magicCookie, bitRate, bitRateStrategy, maximumOutputPacketSize, the available / applicable encode bit rates, sample rates and channel layout tags ✅ ≤17 adapted on AudioToolbox's AudioConverter: linear PCM (sample format, interleaving, channels, sample rate) in Swift, AAC encoding and AAC / MP3 decoding passthrough to the host's libavcodec; convert(to:from:) does not resample (as on iOS); noDataNow gives inputRanDry and the next call continues; dither, priming and the resampler's quality / algorithm are kept but not applied (one resampler); AAC encodes at a constant bit rate; tested (HelloAudio -engine: Int16 interleaved, downmix, channel map, 48 → 24 kHz, no data now, AAC round trip)
AVAudioCompressedBuffer (packetCapacity, packetCount, maximumPacketSize, data, byteCapacity, byteLength, packetDescriptions), AVAudioBuffer.audioBufferList / mutableAudioBufferList, AVAudioFormat for compressed formats (init(settings:) with AVFormatIDKey, init(streamDescription:), magicCookie, formatDescription, init(cmAudioFormatDescription:)) ✅ ≤17 packets with their descriptions, as the converter fills and reads them; compressed formats have commonFormat == .otherFormat; tested (HelloAudio -engine: AAC packets)
AVAudioPCMBuffer in every common format: int16ChannelData, int32ChannelData, interleaved floatChannelData, stride, init(pcmFormat:bufferListNoCopy:deallocator:), copies ✅ ≤17 adapted: Int16 / Int32 / Float64 and interleaved buffers have storage in their own layout (isim before 0.26 stored every buffer as deinterleaved floats); the engine and files read them through a float view; bufferListNoCopy copies the samples; tested (HelloAudio -engine)
AVAudioChannelLayout (init(layoutTag:), init(layout:), layoutTag, layout, channelCount, secure coding), AVAudioFormat.channelLayout, init(standardFormatWithSampleRate:channelLayout:), init(commonFormat:sampleRate:interleaved:channelLayout:), init(streamDescription:channelLayout:), AVChannelLayoutKey; AudioChannelLayout, AudioChannelDescription, AudioChannelBitmap, the kAudioChannelLayoutTag_… and kAudioChannelLabel_… constants (Swift and C) ✅ ≤17 Apple's values and layouts; a tag's channel count is its low 16 bits; tested (HelloAudio -engine: 5.1 through settings)
AVAudioTime ✅ ≤17 a class (NSObject) as on iOS: sample time, host time, extrapolateTime(fromAnchor:), audioTimeStamp; host times are nanoseconds of the uptime clock. isim before 0.26 had a struct: Swift apps that use AVAudioTime must be rebuilt (isim/abi/allowlist.txt); tested (HelloAudio -engine)
AVAudioUnitTimeEffect, AVAudioUnitGenerator ✅ ≤17 AVAudioUnitVarispeed and AVAudioUnitTimePitch are time effects, as on iOS (isim before 0.26 made them AVAudioUnitEffects; apps that use them must be rebuilt); AVAudioUnit.instantiate returns the class for the component type; adapted: isim has none of Apple's generator units (AUAudioFilePlayer, AUScheduledSoundPlayer), so a generator renders silence with its mixing settings; tested (HelloAudio -engine)
AVAudioUnitMIDIInstrument (startNote, stopNote, sendController, sendPitchBend, sendPressure, sendProgramChange, sendMIDIEvent, sendMIDISysExEvent, send(_:) with a MIDIEventList, AVAudioMixing), AVAudioUnitSampler (loadSoundBankInstrument(at:program:bankMSB:bankLSB:), loadInstrument(at:), loadAudioFiles(at:), stereoPan, overallGain, globalTuning) ✅ ≤17 adapted: engine source nodes over isim's Sampler unit (see AudioToolbox): SoundFont 2 presets, audio files and .aupreset files; a sine voice until an instrument is loaded; DLS and EXS24 are not read; tested (HelloAudio -midi: test_midi_playback.py; MIDIPlaybackTest: test_midi_playback_objc.py)
AVAudioSequencer (load(from:options:), write(to:smpteResolution:replaceExisting:), data(withSMPTEResolution:error:), tracks, tempoTrack, createAndAppendTrack, removeTrack, reverseEvents, setUserCallback, beats / seconds / host time, start, stop, rate, positions, AVAudioSequencer.InfoDictionaryKey), AVMusicTrack (destination audio unit or MIDI endpoint, loopRange, isLoopingEnabled, numberOfLoops, offsetTime, mute, solo, length, timeResolution, addEvent, moveEvents, clearEvents, cutEvents, copyEvents, copyAndMergeEvents, enumerateEvents), AVBeatRange, AVMusicSequenceLoadOptions, AVMusicTrackLoopCount, AVAudioEngine.musicSequence ✅ ≤17 adapted: over isim's Music Sequence and Music Player; a track without a destination plays to the engine's first MIDI instrument; a loop always starts at beat 0 (the end of loopRange is its length); tested (HelloAudio -midi: test_midi_playback.py; MIDIPlaybackTest: test_midi_playback_objc.py)
The AVMusicEvent classes: AVMIDINoteEvent, AVMIDIChannelEvent, AVMIDIControlChangeEvent, AVMIDIPolyPressureEvent, AVMIDIProgramChangeEvent, AVMIDIChannelPressureEvent, AVMIDIPitchBendEvent, AVMIDISysexEvent, AVMIDIMetaEvent, AVMusicUserEvent, AVExtendedNoteOnEvent, AVParameterEvent, AVAUPresetEvent, AVExtendedTempoEvent ✅ 16.0 adapted: each is the Music Sequence event of the same layout; tested (HelloAudio -midi: test_midi_playback.py; MIDIPlaybackTest: test_midi_playback_objc.py)
AVMIDIPlayer (init(contentsOf:soundBankURL:), init(data:soundBankURL:), prepareToPlay, play(_:), stop, duration, isPlaying, rate, currentPosition) ✅ ≤17 adapted: a Standard MIDI File played by a Music Player through a MIDISynth with the SoundFont (a sine voice without one) to the device's output; the completion handler runs at the end; tested (HelloAudio -midi: test_midi_playback.py; MIDIPlaybackTest: test_midi_playback_objc.py)
Types not yet in isim (iOS 17 and earlier) ❌ ≤17 not implemented, found by the 2026-10 sweep: AVAudioUnitComponent, AVAudioUnitComponentManager, AVSpeechSynthesisProviderAudioUnit (3 types; with their members under "Not yet in isim")
Types not yet in isim (iOS 27) ❌ 27.0 not implemented, found by the 2026-10 sweep: AVReadOnlyAudioPCMBuffer (1 type; with its members under "Not yet in isim")

Not yet in isim

372 symbols Apple documents for iOS that isim does not have (exact; Apple snapshot 2026-10-14). Each links to Apple's documentation.

List