[![CI Status](http://img.shields.io/travis/Johannes Gorset/Recorder.svg?style=flat)](https://travis-ci.org/Johannes Gorset/Recorder)
import UIKit
import Recorder
class ViewController: UIViewController, RecorderDelegate {
var recording: Recording!
override func viewDidLoad() {
super.viewDidLoad()
recording = Recording(to: "recording.m4a")
recording.delegate = self
// Optionally, you can prepare the recording in the background to
// make it start recording faster when you hit `record()`.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
do {
try self.recording.prepare()
} catch {
print(error)
}
}
}
func start() {
do {
try recording.record()
} catch {
print(error)
}
}
func stop() {
recording.stop()
}
func play() {
do {
try recording.play()
} catch {
print(error)
}
}
}
RecorderDelegate
just extends AVAudioRecorderDelegate
, so if you need to
delegate things you can just implement those methods as you would normally do.
You can meter incoming audio levels by implementing audioMeterDidUpdate
:
func audioMeterDidUpdate(db: Float) {
print("db level: %f", db)
}
The following configurations may be made to the Recording
instance:
bitRate
(default192000
)sampleRate
(default41000.0
)channels
(default1
)
- Balls of steel (it's my first pod, and it's really bad)
Recorder is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'Recorder'
Recorder is also available through Carthage. To install just write into your Cartfile:
github "jgorset/Recorder"
Johannes Gorset, [email protected]
Recorder is available under the MIT license. See the LICENSE file for more info.