Skip to content

Commit

Permalink
Merge pull request #1709 from wallisch/CATTY-364
Browse files Browse the repository at this point in the history
CATTY-364 Refactor AudioEngine, change audio category and fix loudness sensor
  • Loading branch information
m-herold authored Apr 7, 2022
2 parents 16b111b + fd185db commit 07f69ca
Show file tree
Hide file tree
Showing 20 changed files with 15 additions and 277 deletions.
22 changes: 0 additions & 22 deletions src/Catty.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,6 @@
4CDE4CF1203DBBF500B43034 /* YKImageCropperView.license in Resources */ = {isa = PBXBuildFile; fileRef = 4CDE4CD9203DBBF300B43034 /* YKImageCropperView.license */; };
4CDE4CF4203DBBF500B43034 /* HMSegmentedControl.license in Resources */ = {isa = PBXBuildFile; fileRef = 4CDE4CDC203DBBF300B43034 /* HMSegmentedControl.license */; };
4CDE4CF5203DBBF500B43034 /* UIImage+FloodFill.license in Resources */ = {isa = PBXBuildFile; fileRef = 4CDE4CDD203DBBF400B43034 /* UIImage+FloodFill.license */; };
4CDE4CF6203DBBF500B43034 /* SharkfoodMuteSwitchDetector.license in Resources */ = {isa = PBXBuildFile; fileRef = 4CDE4CDE203DBBF400B43034 /* SharkfoodMuteSwitchDetector.license */; };
4CDE4CF7203DBBF500B43034 /* EVCircularProgressView.license in Resources */ = {isa = PBXBuildFile; fileRef = 4CDE4CDF203DBBF400B43034 /* EVCircularProgressView.license */; };
4CDE4CF8203DBBF500B43034 /* LCTableViewPickerControl.license in Resources */ = {isa = PBXBuildFile; fileRef = 4CDE4CE0203DBBF400B43034 /* LCTableViewPickerControl.license */; };
4CDE4CFA203DBBF500B43034 /* MXSegmentedPager.license in Resources */ = {isa = PBXBuildFile; fileRef = 4CDE4CE2203DBBF500B43034 /* MXSegmentedPager.license */; };
Expand Down Expand Up @@ -1179,8 +1178,6 @@
92FF2E941A24C7D800093DA7 /* Logger.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF2E641A24C7D800093DA7 /* Logger.m */; };
92FF2E951A24C7D800093DA7 /* LoggerProperties.plist in Resources */ = {isa = PBXBuildFile; fileRef = 92FF2E651A24C7D800093DA7 /* LoggerProperties.plist */; };
92FF2E9A1A24C7D800093DA7 /* NavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF2E721A24C7D800093DA7 /* NavigationController.m */; };
92FF2E9E1A24C7D800093DA7 /* IMPORTANT.caf in Resources */ = {isa = PBXBuildFile; fileRef = 92FF2E7C1A24C7D800093DA7 /* IMPORTANT.caf */; };
92FF2E9F1A24C7D800093DA7 /* SharkfoodMuteSwitchDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF2E7E1A24C7D800093DA7 /* SharkfoodMuteSwitchDetector.m */; };
92FF2EA11A24C7D800093DA7 /* TimerLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF2E841A24C7D800093DA7 /* TimerLabel.m */; };
92FF2EA21A24C7D800093DA7 /* TableUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF2E871A24C7D800093DA7 /* TableUtil.m */; };
92FF2EA31A24C7D800093DA7 /* UIUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 92FF2E891A24C7D800093DA7 /* UIUtil.m */; };
Expand Down Expand Up @@ -2911,7 +2908,6 @@
4CDE4CD9203DBBF300B43034 /* YKImageCropperView.license */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = YKImageCropperView.license; sourceTree = "<group>"; };
4CDE4CDC203DBBF300B43034 /* HMSegmentedControl.license */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HMSegmentedControl.license; sourceTree = "<group>"; };
4CDE4CDD203DBBF400B43034 /* UIImage+FloodFill.license */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "UIImage+FloodFill.license"; sourceTree = "<group>"; };
4CDE4CDE203DBBF400B43034 /* SharkfoodMuteSwitchDetector.license */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SharkfoodMuteSwitchDetector.license; sourceTree = "<group>"; };
4CDE4CDF203DBBF400B43034 /* EVCircularProgressView.license */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EVCircularProgressView.license; sourceTree = "<group>"; };
4CDE4CE0203DBBF400B43034 /* LCTableViewPickerControl.license */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LCTableViewPickerControl.license; sourceTree = "<group>"; };
4CDE4CE2203DBBF500B43034 /* MXSegmentedPager.license */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = MXSegmentedPager.license; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3421,9 +3417,6 @@
92FF2E651A24C7D800093DA7 /* LoggerProperties.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = LoggerProperties.plist; sourceTree = "<group>"; };
92FF2E711A24C7D800093DA7 /* NavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationController.h; sourceTree = "<group>"; };
92FF2E721A24C7D800093DA7 /* NavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavigationController.m; sourceTree = "<group>"; };
92FF2E7C1A24C7D800093DA7 /* IMPORTANT.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = IMPORTANT.caf; sourceTree = "<group>"; };
92FF2E7D1A24C7D800093DA7 /* SharkfoodMuteSwitchDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharkfoodMuteSwitchDetector.h; sourceTree = "<group>"; };
92FF2E7E1A24C7D800093DA7 /* SharkfoodMuteSwitchDetector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SharkfoodMuteSwitchDetector.m; sourceTree = "<group>"; };
92FF2E831A24C7D800093DA7 /* TimerLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimerLabel.h; sourceTree = "<group>"; };
92FF2E841A24C7D800093DA7 /* TimerLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TimerLabel.m; sourceTree = "<group>"; };
92FF2E861A24C7D800093DA7 /* TableUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableUtil.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6886,7 +6879,6 @@
4CDE4CD5203DBBF300B43034 /* NSString+FastImageSize.license */,
4CDE4CD1203DBBF200B43034 /* OrderedDictionary.license */,
9E5DFD8B25057ECF0049265C /* ScratchSampleInstruments.license */,
4CDE4CDE203DBBF400B43034 /* SharkfoodMuteSwitchDetector.license */,
4CDE4CFB203DBC8100B43034 /* Siren.license */,
4CDE4CD8203DBBF300B43034 /* SPUserResizableView.license */,
4CDE4CD0203DBBF200B43034 /* SSZipArchive.license */,
Expand Down Expand Up @@ -8345,7 +8337,6 @@
2E25F6DD262040380044B2DF /* Network */,
4C0F9F47204ADD0C00E71B2D /* OrderedDictionary */,
929CC0D11BC39B280027DEC0 /* PhiroHelper */,
92FF2E7B1A24C7D800093DA7 /* SharkfoodMuteSwitchDetector */,
9276B7021C9E8F6C008BC594 /* SoundCache */,
5E99F2E123442DD2007878C1 /* ThemesHelper */,
92FF2E821A24C7D800093DA7 /* TimerLabel */,
Expand Down Expand Up @@ -8415,16 +8406,6 @@
path = NavigationController;
sourceTree = "<group>";
};
92FF2E7B1A24C7D800093DA7 /* SharkfoodMuteSwitchDetector */ = {
isa = PBXGroup;
children = (
92FF2E7C1A24C7D800093DA7 /* IMPORTANT.caf */,
92FF2E7D1A24C7D800093DA7 /* SharkfoodMuteSwitchDetector.h */,
92FF2E7E1A24C7D800093DA7 /* SharkfoodMuteSwitchDetector.m */,
);
path = SharkfoodMuteSwitchDetector;
sourceTree = "<group>";
};
92FF2E821A24C7D800093DA7 /* TimerLabel */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -11618,7 +11599,6 @@
9E5DFD09250574380049265C /* 18-cuica.wv in Resources */,
9EBAC31122A9B91C002E198D /* AudioKit.license in Resources */,
9EC520B724FC063D0029CD0E /* flute-72.wv in Resources */,
92FF2E9E1A24C7D800093DA7 /* IMPORTANT.caf in Resources */,
9E5DFD15250574380049265C /* synth-pad.sfz in Resources */,
9E5DFD0E250574380049265C /* 5-open-hi-hat.wv in Resources */,
9E5DFD0C250574380049265C /* 11-cowbell.wv in Resources */,
Expand Down Expand Up @@ -11650,7 +11630,6 @@
92FF2E391A24C5A700093DA7 /* LICENSE_NSString+FastImageSize in Resources */,
9E5DFD13250574380049265C /* music-box.sfz in Resources */,
9EC5208224FC04EA0029CD0E /* electric-guitar-60.wv in Resources */,
4CDE4CF6203DBBF500B43034 /* SharkfoodMuteSwitchDetector.license in Resources */,
9EC5208A24FC04EA0029CD0E /* trombo-36.wv in Resources */,
4CDE4CF0203DBBF500B43034 /* SPUserResizableView.license in Resources */,
CADBD6F419B0E8C200C62836 /* Settings.bundle in Resources */,
Expand Down Expand Up @@ -12966,7 +12945,6 @@
184949B9248130A9000B8CDA /* NSStringExtension.swift in Sources */,
92FF2E8C1A24C7D800093DA7 /* AudioManager.m in Sources */,
6F5B4C6224D412EF00D2D319 /* Scene.swift in Sources */,
92FF2E9F1A24C7D800093DA7 /* SharkfoodMuteSwitchDetector.m in Sources */,
59EA52B824FCF9E400AC6E8D /* WhenBackgroundChangesScriptCell.swift in Sources */,
186212462475C9140098F4C5 /* PenConfiguration.swift in Sources */,
AAAF228A1BC0D0630076F11E /* TurnRightBrick+Instruction.swift in Sources */,
Expand Down
2 changes: 0 additions & 2 deletions src/Catty/Defines/LanguageTranslationDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@
#define kLocalizedInvalidSoundNameDescription NSLocalizedString(@"No or invalid sound name entered, try again.", nil)
#define kLocalizedImageNameAlreadyExistsDescription NSLocalizedString(@"An image with the same name already exists, try again.", nil)
#define kLocalizedUnableToPlaySoundDescription NSLocalizedString(@"Unable to play that sound!\nMaybe this is no valid sound or the file is corrupt.", nil)
#define kLocalizedDeviceIsInMutedStateIPhoneDescription NSLocalizedString(@"Unable to play the selected sound. Your device is in silent mode. Please turn off silent mode by toggling the switch on the left side of your iPhone and tap on play again.", nil)
#define kLocalizedDeviceIsInMutedStateIPadDescription NSLocalizedString(@"Unable to play the selected sound. Your device is in silent mode. Please turn off silent mode by toggling the switch on the right side of your iPad and tap on play again.", nil)
#define kLocalizedProjectAlreadyDownloadedDescription NSLocalizedString(@"You have already downloaded this project!", nil)
#define kLocalizedNoAccesToImagesCheckSettingsDescription NSLocalizedString(@"Pocket Code has no access to your images. To permit access, tap settings and activate images. Your drawing will automatically be saved to PocketCode for you.", nil)
#define kLocalizedNoAccesToCameraCheckSettingsDescription NSLocalizedString(@"Pocket Code has no access to your camera. To permit access, tap settings and activate camera. Your drawing will automatically be saved to PocketCode for you.", nil)
Expand Down
2 changes: 0 additions & 2 deletions src/Catty/Defines/LanguageTranslationDefinesSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ let kLocalizedInvalidImageNameDescription = NSLocalizedString("No or invalid ima
let kLocalizedInvalidSoundNameDescription = NSLocalizedString("No or invalid sound name entered, try again.", comment: "")
let kLocalizedImageNameAlreadyExistsDescription = NSLocalizedString("An image with the same name already exists, try again.", comment: "")
let kLocalizedUnableToPlaySoundDescription = NSLocalizedString("Unable to play that sound!\nMaybe this is no valid sound or the file is corrupt.", comment: "")
let kLocalizedDeviceIsInMutedStateIPhoneDescription = NSLocalizedString("Unable to play the selected sound. Your device is in silent mode. Please turn off silent mode by toggling the switch on the left side of your iPhone and tap on play again.", comment: "")
let kLocalizedDeviceIsInMutedStateIPadDescription = NSLocalizedString("Unable to play the selected sound. Your device is in silent mode. Please turn off silent mode by toggling the switch on the right side of your iPad and tap on play again.", comment: "")
let kLocalizedProjectAlreadyDownloadedDescription = NSLocalizedString("You have already downloaded this project!", comment: "")
let kLocalizedNoAccesToImagesCheckSettingsDescription = NSLocalizedString("Pocket Code has no access to your images. To permit access, tap settings and activate images. Your drawing will automatically be saved to PocketCode for you.", comment: "")
let kLocalizedNoAccesToCameraCheckSettingsDescription = NSLocalizedString("Pocket Code has no access to your camera. To permit access, tap settings and activate camera. Your drawing will automatically be saved to PocketCode for you.", comment: "")
Expand Down
Binary file not shown.

This file was deleted.

This file was deleted.

2 changes: 2 additions & 0 deletions src/Catty/PlayerEngine/AudioEngine/AudioEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ import Foundation
@objc func stop() {
stopAllAudioSources()
engine.stop()

audioEngineHelper.deactivateAudioSession()
}

private func pauseAllAudioSources() {
Expand Down
4 changes: 2 additions & 2 deletions src/Catty/PlayerEngine/AudioEngine/AudioEngineHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Foundation

func activateAudioSession() {
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.soloAmbient, options: AVAudioSession.CategoryOptions.defaultToSpeaker)
try AVAudioSession.sharedInstance().setCategory(.playAndRecord, options: [.defaultToSpeaker, .allowAirPlay, .allowBluetoothA2DP])
try AVAudioSession.sharedInstance().setActive(true)
} catch let error as NSError {
debugPrint("Could not activate audio session.")
Expand All @@ -49,7 +49,7 @@ import Foundation

func deactivateAudioSession() {
do {
try AVAudioSession.sharedInstance().setActive(false)
try AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
} catch let error as NSError {
debugPrint("Could not deactivate audio session.")
debugPrint(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ extension AudioManager: AudioManagerProtocol {
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
] as [String: Any]

let audioSession = AVAudioSession.sharedInstance()
try? audioSession.setActive(true)
try? audioSession.setCategory(.playAndRecord, mode: .default)
try? audioSession.overrideOutputAudioPort(AVAudioSession.PortOverride.speaker)
try? self.recorder = AVAudioRecorder(url: url, settings: settings)
}

Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions src/Catty/Resources/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1993,12 +1993,6 @@
/* No comment provided by engineer. */
"Unable to play that sound!\nMaybe this is no valid sound or the file is corrupt." = "Unable to play that sound!\nMaybe this is no valid sound or the file is corrupt.";

/* No comment provided by engineer. */
"Unable to play the selected sound. Your device is in silent mode. Please turn off silent mode by toggling the switch on the left side of your iPhone and tap on play again." = "Unable to play the selected sound. Your device is in silent mode. Please turn off silent mode by toggling the switch on the left side of your iPhone and tap on play again.";

/* No comment provided by engineer. */
"Unable to play the selected sound. Your device is in silent mode. Please turn off silent mode by toggling the switch on the right side of your iPad and tap on play again." = "Unable to play the selected sound. Your device is in silent mode. Please turn off silent mode by toggling the switch on the right side of your iPad and tap on play again.";

/* paint */
"underline" = "underline";

Expand Down
6 changes: 0 additions & 6 deletions src/Catty/Settings.bundle/Acknowledgements.plist
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@
<key>FooterText</key>
<string>Catty/Resources/Licenses/ScratchSampleInstruments</string>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
<key>FooterText</key>
<string>Catty/Resources/Licenses/SharkfoodMuteSwitchDetector</string>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
Expand Down
Loading

0 comments on commit 07f69ca

Please sign in to comment.