Skip to content

suricforever/AMRAudioSwift

 
 

Repository files navigation

AMRAudioSwift

AMRAudioSwift is a useful tool to encode or decode audio between AMR and WAVE. It's written in Swift, and it supports Bitcode.

In addition, AMRAudioSwift contains an audio recorder/player, which can record voice and play AMR data.

At the bottom level, libopencore-amr is applied for audio decoding.

How To Get Started

Carthage

Specify "AMRAudioSwift" in your Cartfile:

github "teambition/AMRAudioSwift"

Usage

Configuration

let audioRecorder = AMRAudioRecorder()
audioRecorder.volume = ...
audioRecorder.isProximityMonitoringEnabled = ...
audioRecorder.isScreenBrightWhenPlaying = ...

// assign delegate
audioRecorder.delegate = self

Recording and Playing

audioRecorder.startRecord()
audioRecorder.cancelRecord()
audioRecorder.stopRecord()
audioRecorder.play(waveData)
audioRecorder.playAmr(amrData)
audioRecorder.stopPlay()

Implement delegate

func audioRecorderDidStartRecording(_ audioRecorder: AMRAudioRecorder) {
    // do something
}

func audioRecorderDidCancelRecording(_ audioRecorder: AMRAudioRecorder) {
    // do something
}

func audioRecorderDidStopRecording(_ audioRecorder: AMRAudioRecorder, withURL url: URL?) {
    // do something
}

func audioRecorderEncodeErrorDidOccur(_ audioRecorder: AMRAudioRecorder, error: Error?) {
    // do something
}

func audioRecorderDidFinishRecording(_ audioRecorder: AMRAudioRecorder, successfully flag: Bool) {
    // do something
}

func audioRecorderDidStartPlaying(_ audioRecorder: AMRAudioRecorder) {
    // do something
}

func audioRecorderDidStopPlaying(_ audioRecorder: AMRAudioRecorder) {
    // do something
}

func audioRecorderDecodeErrorDidOccur(_ audioRecorder: AMRAudioRecorder, error: Error?) {
    // do something
}

func audioRecorderDidFinishPlaying(_ audioRecorder: AMRAudioRecorder, successfully flag: Bool) {
    // do something
}

Minimum Requirement

iOS 10.0

Release Notes

License

AMRAudioSwift is released under the MIT license. See LICENSE for details.

More Info

Have a question? Please open an issue!

About

A useful tool to encode or decode audio between AMR and WAVE.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 56.6%
  • Objective-C 38.4%
  • Ruby 2.7%
  • C 2.3%