{"id":13761328,"url":"https://github.com/sbooth/SFBAudioEngine","last_synced_at":"2025-05-10T12:31:43.211Z","repository":{"id":698476,"uuid":"343671","full_name":"sbooth/SFBAudioEngine","owner":"sbooth","description":"A toolbox of powerful audio functionality for macOS and iOS","archived":false,"fork":false,"pushed_at":"2024-04-14T01:49:33.000Z","size":325781,"stargazers_count":535,"open_issues_count":10,"forks_count":83,"subscribers_count":28,"default_branch":"main","last_synced_at":"2024-04-14T12:34:34.496Z","etag":null,"topics":["audio","audio-decoders","audio-encoders","audio-player","avaudioengine","coreaudio","dsd","ios","macos","objective-c","swift"],"latest_commit_sha":null,"homepage":"https://sbooth.github.io/SFBAudioEngine/","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbooth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2009-10-20T16:18:58.000Z","updated_at":"2024-04-16T19:53:32.795Z","dependencies_parsed_at":"2024-04-14T03:05:51.429Z","dependency_job_id":null,"html_url":"https://github.com/sbooth/SFBAudioEngine","commit_stats":{"total_commits":1366,"total_committers":8,"mean_commits":170.75,"dds":"0.010248901903367469","last_synced_commit":"fa925109e5da70aab2f9e5b721e641e4fc9c6b95"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbooth%2FSFBAudioEngine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbooth%2FSFBAudioEngine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbooth%2FSFBAudioEngine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbooth%2FSFBAudioEngine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbooth","download_url":"https://codeload.github.com/sbooth/SFBAudioEngine/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224958147,"owners_count":17398495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","audio-decoders","audio-encoders","audio-player","avaudioengine","coreaudio","dsd","ios","macos","objective-c","swift"],"created_at":"2024-08-03T13:01:49.472Z","updated_at":"2025-05-10T12:31:43.184Z","avatar_url":"https://github.com/sbooth.png","language":"Objective-C","readme":"# SFBAudioEngine\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fsbooth%2FSFBAudioEngine%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/sbooth/SFBAudioEngine)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fsbooth%2FSFBAudioEngine%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/sbooth/SFBAudioEngine)\n\nSFBAudioEngine is a powerhouse of audio functionality for macOS, iOS, and tvOS. SFBAudioEngine supports:\n\n* [Audio decoding](#decoding)\n* [Audio playback](#playback)\n* [Audio encoding](#encoding)\n* [Audio format conversion](#conversion)\n* [Audio properties information and metadata editing](#properties-and-metadata)\n\nSFBAudioEngine is usable from both Swift and Objective-C.\n\n## Format Support\n\nSFBAudioEngine supports most audio formats. In addition to all formats supported by [Core Audio](https://developer.apple.com/library/archive/documentation/MusicAudio/Conceptual/CoreAudioOverview/Introduction/Introduction.html) SFBAudioEngine supports:\n\n* [Ogg Speex](https://www.speex.org)\n* [Ogg Vorbis](https://xiph.org/vorbis/)\n* [Monkey's Audio](https://www.monkeysaudio.com)\n* [Musepack](https://www.musepack.net)\n* Shorten\n* True Audio\n* [WavPack](http://www.wavpack.com)\n* All formats supported by [libsndfile](http://libsndfile.github.io/libsndfile/)\n* DSD to PCM conversion for DSD64\n* DSD decoding for DSF and DSDIFF with support for DSD over PCM (DoP)\n\n[FLAC](https://xiph.org/flac/), [Ogg Opus](https://opus-codec.org), and MP3 are natively supported by Core Audio, however SFBAudioEngine provides its own encoders and decoders for these formats.\n\n## Quick Start\n\n### Playback\n\nPlaying an audio file is as simple as:\n\n~~~swift\nimport SFBAudioEngine\nlet player = AudioPlayer()\nlet url = URL(fileURLWithPath: \"example.flac\")\ntry? player.play(url)\n~~~\n\n\u003e [!NOTE]\n\u003e Only file URLs are supported.\n\n### Metadata\n\nReading audio properties and metadata is similarly trivial:\n\n~~~swift\nif let audioFile = try? AudioFile(readingPropertiesAndMetadataFrom: url) {\n    let sampleRate = audioFile.properties.sampleRate\n    let title = audioFile.metadata.title\n}\n~~~\n\n### Conversion\n\nWant to convert a WAVE file to FLAC?\n\n~~~swift\nlet inputURL = URL(fileURLWithPath: \"music.wav\")\nlet outputURL = URL(fileURLWithPath: \"music.flac\")\ntry AudioConverter.convert(inputURL, to: outputURL)\n~~~\n\nThe output file's format is inferred from the file extension.\n\nMore complex conversions are supported including writing to `Data` instead of files:\n\n~~~swift\nlet output = OutputSource.makeForData()\nlet encoder = try AudioEncoder(outputSource: output, encoderName: .coreAudio)\nencoder.settings = [\n    .coreAudioFileTypeID: kAudioFileM4AType,\n    .coreAudioFormatID: kAudioFormatMPEG4AAC,\n    .coreAudioAudioConverterPropertySettings: [kAudioConverterCodecQuality: kAudioConverterQuality_High]\n]\ntry AudioConverter.convert(inputURL, using: encoder)\n// Encoder output is in `output.data`\n~~~\n\n## Requirements\n\nmacOS 11.0+, iOS 15.0+, or tvOS 15.0+\n\n## Installation\n\n### Swift Package Manager\n\nAdd a package dependency to https://github.com/sbooth/SFBAudioEngine in Xcode.\n\n### Manual or Custom Build\n\n1. Clone the [SFBAudioEngine](https://github.com/sbooth/SFBAudioEngine) repository.\n2. `swift build`.\n\n## Decoding\n\n[Audio decoders](Sources/CSFBAudioEngine/Decoders/) in SFBAudioEngine are broadly divided into two categories, those producing PCM output and those producing DSD output. Audio decoders read data from an [SFBInputSource](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBInputSource.h) which may refer to a file, buffer, or data.\n\nAll audio decoders in SFBAudioEngine implement the [SFBAudioDecoding](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioDecoding.h) protocol. PCM-producing decoders additionally implement [SFBPCMDecoding](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBPCMDecoding.h) while DSD decoders implement [SFBDSDDecoding](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBDSDDecoding.h).\n\nThree special decoder subclasses that wrap an underlying audio decoder instance are also provided: [SFBLoopableRegionDecoder](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBLoopableRegionDecoder.h), [SFBDoPDecoder](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBDoPDecoder.h), and [SFBDSDPCMDecoder](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBDSDPCMDecoder.h). For seekable inputs, [SFBLoopableRegionDecoder](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBLoopableRegionDecoder.h) allows arbitrary looping and repeating of a specified PCM decoder segment. [SFBDoPDecoder](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBDoPDecoder.h) and [SFBDSDPCMDecoder](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBDSDPCMDecoder.h) wrap a DSD decoder providing DSD over PCM (DoP) and PCM output respectively.\n\n## Playback\n\n### [SFBAudioPlayerNode](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioPlayerNode.h)\n\n[SFBAudioPlayerNode](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioPlayerNode.h) is a subclass of [AVAudioSourceNode](https://developer.apple.com/documentation/avfaudio/avaudiosourcenode) that provides rich playback functionality within an [AVAudioEngine](https://developer.apple.com/documentation/avfaudio/avaudioengine) processing graph. [SFBAudioPlayerNode](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioPlayerNode.h) supports gapless playback and comprehensive status notifications through a delegate.\n\n### [SFBAudioPlayer](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioPlayer.h)\n\n[SFBAudioPlayer](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioPlayer.h) wraps an [AVAudioEngine](https://developer.apple.com/documentation/avfaudio/avaudioengine) processing graph driven by [SFBAudioPlayerNode](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioPlayerNode.h). [SFBAudioPlayer](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioPlayer.h) provides complete player functionality with no required configuration but also allows customization of the underlying processing graph as well as rich status notifications through a delegate.\n\n## Encoding\n\n[Audio encoders](Sources/CSFBAudioEngine/Encoders/) in SFBAudioEngine process input data and convert it to their output format. Audio encoders write data to an [SFBOutputSource](Sources/CSFBAudioEngine/include/SFBOutputSource.h) which may refer to a file, buffer, or data.\n\nAll audio encoders in SFBAudioEngine implement the [SFBAudioEncoding](Sources/CSFBAudioEngine/include/SFBAudioEncoding.h) protocol. PCM-consuming encoders additionally implement [SFBPCMEncoding](Sources/CSFBAudioEngine/include/SFBPCMEncoding.h). Currently there are no encoders consuming DSD in SFBAudioEngine.\n\nEncoders don't support arbitrary input formats. The processing format used by an encoder is derived from a desired format combined with the encoder's settings.\n\n## Conversion\n\n[SFBAudioConverter](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioConverter.h) supports high level conversion operations. An audio converter reads PCM audio from an audio decoder in the decoder's processing format, converts that audio to an intermediate PCM format, and then writes the intermediate PCM audio to an audio encoder which performs the final conversion to the desired format.\n\nThe decoder's processing format and the intermediate format must both be PCM but do not have to have the same sample rate, bit depth, channel count, or channel layout.\n\n## Properties and Metadata\n\nAudio properties and metadata are accessed via instances of [SFBAudioFile](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioFile.h). [Audio properties](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioProperties.h) are read-only while [metadata](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioMetadata.h) is writable for most formats. Audio metadata may be obtained from an instance of [SFBAudioFile](Sources/CSFBAudioEngine/include/SFBAudioEngine/SFBAudioFile.h) or instantiated directly. \n\n## Sample Audio Players\n\nTwo versions of SimplePlayer, one for macOS and one for iOS, are provided to illustrate the usage of SFBAudioEngine.\n\n### macOS\n\n[SimplePlayer for macOS](https://github.com/sbooth/SimplePlayer-macOS) is written in Swift using AppKit and supports gapless sequential playback of items from a playlist. The essential functionality is contained in one file, [PlayerWindowController.swift](https://github.com/sbooth/SimplePlayer-macOS/blob/main/SimplePlayer/PlayerWindowController.swift).\n\n### iOS\n\n[SimplePlayer for iOS](https://github.com/sbooth/SimplePlayer-iOS) is written in Swift using SwiftUI and supports playback of a single item selected from a list.\n\n## License\n\nSFBAudioEngine is released under the [MIT License](https://github.com/sbooth/SFBAudioEngine/blob/master/LICENSE.txt).\n\nThe open-source projects providing support for the various audio formats are subject to their own licenses that are compatible with the MIT license when used with SFBAudioEngine's default build configuration.\n\n### LGPL Notes\n\nIn order to maintain compatibility with the LGPL used by [libsndfile](http://libsndfile.github.io/libsndfile/), [mpg123](https://www.mpg123.de), [libtta-cpp](https://sourceforge.net/projects/tta/), [lame](https://lame.sourceforge.io), and the Musepack encoder dynamic linking is required.\n","funding_links":[],"categories":["Objective-C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbooth%2FSFBAudioEngine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbooth%2FSFBAudioEngine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbooth%2FSFBAudioEngine/lists"}