RecorderViewController
class RecorderViewController: GeneralUIViewController, AVAudioRecorderDelegate
This GeneralUIViewController controls the Equalizer’s recorder view. It allows the user to prerecord an audio clip if they do not want to use the equalizer in real-time.
Provides audio recording functionality for the equalizer, allowing users to pre-record audio clips for processing.
-
The
UIButtonto start recording.Declaration
Swift
@IBOutlet weak var recordButton: UIButton! -
The
UIButtonto stop recording.Declaration
Swift
@IBOutlet weak var stopButton: UIButton! -
The
GeneralUILabelthat displays if in record mode.Declaration
Swift
@IBOutlet weak var recordingLabel: GeneralUILabel!
-
The state of the recorder -> true if recording, false if paused or stopped.
Declaration
Swift
var state: Bool! // This will decide if the button should be a mic or the pause button
-
Hide
stopButtonandrecordingLabel. This must be done since the user should not be able to stop the recording before it even starts.Declaration
Swift
override func viewWillAppear(_ animated: Bool) -
Set the state and font of the
recordingLabel. CallsetupAVAudioSessionto initiate the recording process.Declaration
Swift
override func viewDidLoad() -
Set the state so that it does not keep getting modified.
Declaration
Swift
override func viewWillDisappear(_ animated: Bool)
-
Overridden to send
RecordedAudioObjectto the nextGeneralUIViewControllerthat we are seguing to. In this case the only possible segue is toEqualizerViewController.Declaration
Swift
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
-
Ensures that when the recording ends a sucess or failure flag is sent to
recordingEndedfunction.Declaration
Swift
func audioRecorderDidFinishRecording(_ recorder: AVAudioRecorder, successfully flag: Bool)
-
Toggle the state - this function handles the logic of switching the state as well as toggling the visibility for different views.
Declaration
Swift
@IBAction func toggleRecording(_ sender: UIButton) -
Stops recording by invoking the
AVAudioRecorder's stopmethod onAudio.sharedInstance.recorder.Declaration
Swift
@IBAction func stopRecording(_ sender: UIButton)
View on GitHub
RecorderViewController Class Reference