Skip to content

Commit

Permalink
Pin to specifiic SF2Lib that works on iOS < 17
Browse files Browse the repository at this point in the history
  • Loading branch information
bradhowes committed Dec 22, 2024
1 parent f4e08d6 commit 870f3dd
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 48 deletions.
18 changes: 9 additions & 9 deletions SoundFontInfoLib/SoundFontInfoLib.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
BD2398A32BBB65D5009265E4 /* SF2Files.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD9C8A272A8AC2DC0055A95C /* SF2Files.framework */; };
BD6791622973622C0055BB38 /* FourCharCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD6791612973622C0055BB38 /* FourCharCode.swift */; };
BD74D17123CDB1D200204ED4 /* SoundFontInfoLib.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD74D16723CDB1D200204ED4 /* SoundFontInfoLib.framework */; };
BD9C8A262A8A68C20055A95C /* SF2Lib in Frameworks */ = {isa = PBXBuildFile; productRef = BD9C8A252A8A68C20055A95C /* SF2Lib */; };
BD7779472D18548C004AA250 /* SF2Lib in Frameworks */ = {isa = PBXBuildFile; productRef = BD7779462D18548C004AA250 /* SF2Lib */; };
BDB1BF9E265DB1F0002AD159 /* SoundFontInfoLib.h in Headers */ = {isa = PBXBuildFile; fileRef = BDB1BF40265DB1F0002AD159 /* SoundFontInfoLib.h */; settings = {ATTRIBUTES = (Public, ); }; };
BDB1BFF0265DB1F1002AD159 /* SoundFontInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = BDB1BF9C265DB1F0002AD159 /* SoundFontInfo.mm */; };
BDB1BFF1265DB788002AD159 /* SoundFontInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = BDB1BF95265DB1F0002AD159 /* SoundFontInfo.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -57,8 +57,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BD7779472D18548C004AA250 /* SF2Lib in Frameworks */,
BD2398A32BBB65D5009265E4 /* SF2Files.framework in Frameworks */,
BD9C8A262A8A68C20055A95C /* SF2Lib in Frameworks */,
BDFA98F3280C73280069A46F /* AudioToolbox.framework in Frameworks */,
BDD2D6AB261C8854000557A3 /* Accelerate.framework in Frameworks */,
);
Expand Down Expand Up @@ -154,7 +154,7 @@
);
name = SoundFontInfoLib;
packageProductDependencies = (
BD9C8A252A8A68C20055A95C /* SF2Lib */,
BD7779462D18548C004AA250 /* SF2Lib */,
);
productName = SoundFontInfoLib;
productReference = BD74D16723CDB1D200204ED4 /* SoundFontInfoLib.framework */;
Expand Down Expand Up @@ -214,7 +214,7 @@
);
mainGroup = BD74D15D23CDB1D200204ED4;
packageReferences = (
BD9C8A242A8A68C20055A95C /* XCRemoteSwiftPackageReference "SF2Lib" */,
BD7779452D18548C004AA250 /* XCRemoteSwiftPackageReference "SF2Lib" */,
);
productRefGroup = BD74D16823CDB1D200204ED4 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -681,20 +681,20 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
BD9C8A242A8A68C20055A95C /* XCRemoteSwiftPackageReference "SF2Lib" */ = {
BD7779452D18548C004AA250 /* XCRemoteSwiftPackageReference "SF2Lib" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/bradhowes/SF2Lib";
requirement = {
branch = main;
kind = branch;
kind = exactVersion;
version = 6.1.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
BD9C8A252A8A68C20055A95C /* SF2Lib */ = {
BD7779462D18548C004AA250 /* SF2Lib */ = {
isa = XCSwiftPackageProductDependency;
package = BD9C8A242A8A68C20055A95C /* XCRemoteSwiftPackageReference "SF2Lib" */;
package = BD7779452D18548C004AA250 /* XCRemoteSwiftPackageReference "SF2Lib" */;
productName = SF2Lib;
};
/* End XCSwiftPackageProductDependency section */
Expand Down
30 changes: 19 additions & 11 deletions SoundFontsApp/SoundFontsApp/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,21 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
}

/**
Notification handler for when the application starts.
Notification handler for when the application starts. Handles requests to visit the AppStore and view the SoundFonts
page there.

- parameter application: the application that is running
- parameter launchOptions: the options used to start the application
*/
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
observer = NotificationCenter.default.addObserver(forName: .visitAppStore, object: nil,
queue: nil) { [weak self] _ in
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
observer = NotificationCenter.default.addObserver(
forName: .visitAppStore,
object: nil,
queue: nil
) { [weak self] _ in
self?.visitAppStore()
}
return true
Expand All @@ -69,8 +75,11 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
- parameter url: the URL of the file to open
- parameter options: dictionary of options that may affect the opening (unused)
*/
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
// DispatchQueue.main.async { self.components.fontsViewManager.addSoundFonts(urls: [url]) }
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
pendingAddition = url
return true
}
Expand Down Expand Up @@ -130,10 +139,9 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
false
}

@objc private func visitAppStore() {
guard let writeReviewURL = URL(string: "https://itunes.apple.com/app/id1453325077?action=write-review") else {
fatalError("Expected a valid URL")
private func visitAppStore() {
if let writeReviewURL = URL(string: "https://itunes.apple.com/app/id1453325077?action=write-review") {
UIApplication.shared.open(writeReviewURL, options: [:], completionHandler: nil)
}
UIApplication.shared.open(writeReviewURL, options: [:], completionHandler: nil)
}
}
15 changes: 8 additions & 7 deletions SoundFontsApp/SoundFontsApp/App/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import ProgressHUD
final class MainViewController: UIViewController {
private lazy var log: Logger = Logging.logger("MainViewController")

private var activePresetManager: ActivePresetManager!
private var activePresetManager: ActivePresetManager?
private var audioEngine: AudioEngine?
private var settings: Settings!
private var settings: Settings?
private var askForReview: AskForReview?

private var startRequested = false
Expand All @@ -40,7 +40,7 @@ final class MainViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
UIApplication.shared.appDelegate.setMainViewController(self)
UIApplication.shared.appDelegate?.setMainViewController(self)
setNeedsUpdateOfScreenEdgesDeferringSystemGestures()
observers.append(NotificationCenter.default.addObserver(forName: .showChanges, object: nil,
queue: nil) { [weak self] _ in
Expand All @@ -58,7 +58,7 @@ final class MainViewController: UIViewController {

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

guard let settings else { return }
if !skipTutorial {
if !settings.showedTutorial {
showTutorial()
Expand Down Expand Up @@ -103,8 +103,9 @@ extension MainViewController {
Show the changes screen if there are changes to be shown.
*/
func showChanges(_ force: Bool = false) {
guard let settings else { return }
let currentVersion = alwaysShowChanges ? "" : Bundle.main.releaseVersionNumber

if settings.showedChanges != currentVersion || alwaysShowChanges || force {
let changes = ChangesCompiler.compile()
settings.showedChanges = currentVersion
Expand Down Expand Up @@ -288,7 +289,7 @@ extension MainViewController: ControllerConfiguration {
}

if let audioEngine = router.audioEngine {
activePresetManager.runOnNotifyQueue {
router.activePresetManager.runOnNotifyQueue {
audioEngine.attachKeyboard(keyboard)
self.setAudioEngineInBackground(audioEngine)
}
Expand All @@ -303,7 +304,7 @@ extension MainViewController: ControllerConfiguration {
}
}

activePresetManager.restoreActive(settings.lastActivePreset)
router.activePresetManager.restoreActive(router.settings.lastActivePreset)
log.debug("establishConnections END")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,5 @@ import UIKit
extension UIApplication {

/// Obtain the AppDelegate instance for the application
var appDelegate: AppDelegate {
guard let del = self.delegate as? AppDelegate else {
fatalError("unexpected nil or type for appDelegate")
}
return del
}
var appDelegate: AppDelegate? { self.delegate as? AppDelegate }
}
32 changes: 17 additions & 15 deletions SoundFontsFramework/SoundFontsFramework/Audio/AudioEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public final class AudioEngine: SynthProvider {
- parameter mode: determines how the sampler is hosted.
- parameter activePresetManager: the manager of the active preset
- parameter settings: user-adjustable settings
- parameter midi: the provider of MIDI events
- parameter midiControllerActionStateManager: manager for mapping of MIDI controller events to internal actions
*/
init(mode: Mode, activePresetManager: ActivePresetManager, settings: Settings, midi: MIDI?,
midiControllerActionStateManager: MIDIControllerActionStateManager?) {
Expand Down Expand Up @@ -122,9 +124,9 @@ public final class AudioEngine: SynthProvider {

// MARK: - Control

public extension AudioEngine {
extension AudioEngine {

func attachKeyboard(_ keyboard: AnyKeyboard) {
public func attachKeyboard(_ keyboard: AnyKeyboard) {
guard let midi = self.midi,
let midiConnectionMonitor = self.midiConnectionMonitor,
let midiControllerActionStateManager = self.midiControllerActionStateManager
Expand All @@ -144,7 +146,7 @@ public extension AudioEngine {

- returns: Result value indicating success or failure
*/
func start() -> StartResult {
public func start() -> StartResult {
log.debug("start BEGIN")
let synth = makeSynth()
self._synth = synth
Expand Down Expand Up @@ -174,7 +176,7 @@ public extension AudioEngine {
/**
Stop the existing audio engine. NOTE: this only applies to the standalone case.
*/
func stop() {
public func stop() {
log.debug("stop BEGIN")
guard mode == .standalone else { fatalError("unexpected `stop` called on audioUnit") }

Expand Down Expand Up @@ -212,19 +214,19 @@ public extension AudioEngine {
/**
Command the synth to stop playing active notes.
*/
func stopAllNotes() { synth?.stopAllNotes() }
public func stopAllNotes() { synth?.stopAllNotes() }
}

// MARK: - Configuration Changes

private extension AudioEngine {
extension AudioEngine {

/**
Change the synth to use the given preset configuration values.

- parameter presetConfig: the configuration to use
*/
func applyPresetConfig(_ presetConfig: PresetConfig) {
private func applyPresetConfig(_ presetConfig: PresetConfig) {
log.debug("applyPresetConfig BEGIN")

if presetConfig.presetTuning != 0.0 {
Expand Down Expand Up @@ -275,7 +277,7 @@ private extension AudioEngine {

- parameter value: the value to set in cents (+/- 2400)
*/
func setTuning(_ value: Float) {
private func setTuning(_ value: Float) {
log.debug("setTuning BEGIN - \(value)")
synth?.synthGlobalTuning = value
log.debug("setTuning END")
Expand All @@ -286,7 +288,7 @@ private extension AudioEngine {

- parameter value: the value to set
*/
func setGain(_ value: Float) {
private func setGain(_ value: Float) {
log.debug("setGain BEGIN - \(value)")
synth?.synthGain = value
log.debug("setGain END")
Expand All @@ -297,7 +299,7 @@ private extension AudioEngine {

- parameter value: the value to set
*/
func setPan(_ value: Float) {
private func setPan(_ value: Float) {
log.debug("setPan BEGIN - \(value)")
synth?.synthStereoPan = value
log.debug("setPan END")
Expand All @@ -308,13 +310,13 @@ private extension AudioEngine {

- parameter value: range in semitones
*/
func setPitchBendRange(value: UInt8) {
private func setPitchBendRange(value: UInt8) {
log.debug("setPitchBendRange BEGIN - \(value)")
synth?.setPitchBendRange(value: value)
log.debug("setPitchBendRange END")
}

func pendingPresetLoad() {
private func pendingPresetLoad() {
// We delay changing preset in case there is another change coming over due to UI/MIDI controls. When another one
// comes in we cancel the running timer and restart it, setting a new preset only after the time finishes and fires.
DispatchQueue.main.async { [weak self] in
Expand All @@ -333,7 +335,7 @@ private extension AudioEngine {

- returns: StartResult indicating success or failure
*/
func loadActivePreset(_ afterLoadBlock: (() -> Void)? = nil) -> StartResult {
private func loadActivePreset(_ afterLoadBlock: (() -> Void)? = nil) -> StartResult {
log.debug("loadActivePreset BEGIN - \(self.activePresetManager.active.description, privacy: .public)")

// Ok if the sampler is not yet available. We will apply the preset when it is
Expand Down Expand Up @@ -378,9 +380,9 @@ private extension AudioEngine {
return .success(synth)
}

func makeSynth() -> AnyMIDISynth { AVAudioUnitSampler() }
private func makeSynth() -> AnyMIDISynth { AVAudioUnitSampler() }

func startEngine(_ synth: AnyMIDISynth) -> StartResult {
private func startEngine(_ synth: AnyMIDISynth) -> StartResult {
log.debug("creating AVAudioEngine")
let engine = AVAudioEngine()
self.engine = engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public final class ConsolidatedConfigProvider: NSObject {

- parameter inApp: `true` if running as an app, `false` if as an AUv3 app extension
- parameter fileURL: the location for the document
- parameter identity: the unique tag assigned to this instance
*/
public init(inApp: Bool, fileURL: URL, identity: String) {
self.log = Logging.logger("ConsolidatedConfigProvider[\(identity)]")
Expand Down

0 comments on commit 870f3dd

Please sign in to comment.