-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
985 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
ASAudioKit.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# ``ASAudioKit`` | ||
|
||
<!--@START_MENU_TOKEN@-->Summary<!--@END_MENU_TOKEN@--> | ||
|
||
## Overview | ||
|
||
<!--@START_MENU_TOKEN@-->Text<!--@END_MENU_TOKEN@--> | ||
|
||
## Topics | ||
|
||
### <!--@START_MENU_TOKEN@-->Group<!--@END_MENU_TOKEN@--> | ||
|
||
- <!--@START_MENU_TOKEN@-->``Symbol``<!--@END_MENU_TOKEN@--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// ASAudioKit.h | ||
// ASAudioKit | ||
// | ||
// Created by 박진성 on 11/11/24. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
//! Project version number for ASAudioKit. | ||
FOUNDATION_EXPORT double ASAudioKitVersionNumber; | ||
|
||
//! Project version string for ASAudioKit. | ||
FOUNDATION_EXPORT const unsigned char ASAudioKitVersionString[]; | ||
|
||
// In this header, you should import all the public headers of your framework using statements like #import <ASAudioKit/PublicHeader.h> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
class ASAudioPlayer { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import AVFoundation | ||
|
||
class ASAudioRecorder { | ||
private var audioRecorder: AVAudioRecorder? = nil | ||
|
||
func startRecording(url: URL) { | ||
let settings = [ | ||
AVFormatIDKey: Int(kAudioFormatMPEG4AAC), | ||
AVSampleRateKey: 12000, | ||
AVNumberOfChannelsKey: 1, | ||
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue | ||
] | ||
|
||
do { | ||
audioRecorder = try AVAudioRecorder(url: url, settings: settings) | ||
audioRecorder?.record() | ||
} catch { | ||
//TODO: AVAudioRecorder 객체 생성 실패 시에 대한 처리 | ||
} | ||
} | ||
|
||
func isRecording() -> Bool { | ||
if let audioRecorder { | ||
return audioRecorder.isRecording | ||
} | ||
return false | ||
} | ||
|
||
func stopRecording() -> Data? { | ||
// 녹음 종료 시에 어디 저장되었는지 리턴해줄 필요가 있을 듯, 저장된 녹음파일을 network에 던져줄 필요가 있음. | ||
audioRecorder?.stop() | ||
|
||
guard let recordURL = audioRecorder?.url else {return nil} | ||
|
||
do { | ||
let recordData = try Data(contentsOf: recordURL) | ||
return recordData | ||
} catch { | ||
return nil | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# ASAudioRecorder | ||
|
||
ASAudioRecorder 객체 생성 | ||
```swift | ||
let recorder = ASAudioRecorder() | ||
``` | ||
|
||
녹음 시작 | ||
```swift | ||
let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] | ||
.appendingPathComponent("녹음성공테스트") | ||
recorder.startRecording(url: url) | ||
``` | ||
|
||
녹음 종료 | ||
```swift | ||
recorder.stopRecording() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Testing | ||
import Foundation | ||
|
||
struct ASAudioRecorderTests{ | ||
var recorder: ASAudioRecorder? | ||
|
||
init() async throws { | ||
recorder = ASAudioRecorder() | ||
} | ||
|
||
@Test func startRecording_성공() async throws { | ||
let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] | ||
.appendingPathComponent("녹음성공테스트") | ||
guard let recorder else { | ||
#expect(false) | ||
return | ||
} | ||
recorder.startRecording(url: url) | ||
#expect(recorder.isRecording()) | ||
} | ||
|
||
@Test func stopRecording_성공() async throws { | ||
let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] | ||
.appendingPathComponent("녹음저장성공테스트") | ||
guard let recorder else { | ||
#expect(false) | ||
return | ||
} | ||
recorder.startRecording(url: url) | ||
recorder.stopRecording() | ||
#expect(FileManager.default.fileExists(atPath: url.path)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
alsongDalsong/Assets.xcassets/asGreen.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0.063", | ||
"green" : "0.835", | ||
"red" : "0.165" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0.063", | ||
"green" : "0.835", | ||
"red" : "0.165" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
alsongDalsong/Assets.xcassets/asLightGray.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0.945", | ||
"green" : "0.941", | ||
"red" : "0.925" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0.945", | ||
"green" : "0.941", | ||
"red" : "0.925" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
alsongDalsong/Assets.xcassets/asLightRed.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0.478", | ||
"green" : "0.478", | ||
"red" : "1.000" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "0.478", | ||
"green" : "0.478", | ||
"red" : "1.000" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.