EqualizerViewController

class EqualizerViewController: GeneralUIViewController

This GeneralUIViewController controls the equalizer view. It allows the user to either stream real time audio from the microphone to the speaker after passing through a dual-channel equalizer. There are a total of 28 VerticalSlider objects that the user can control in order to change the gain at any given frequency.

  • Stack view containing the first set of 14 frequency sliders for the left audio channel. This stack view is organized into two rows via EqualizerTableViewCell: - Row 0 (highs): 1kHz, 2kHz, 3kHz, 4kHz, 5kHz, 10kHz, 16kHz - Row 1 (lows): 8Hz, 16Hz, 32Hz, 64Hz, 128Hz, 256Hz, 512Hz - Note: Connected to storyboard via Interface Builder - SeeAlso: EqualizerTableViewCell for individual slider configuration

    Declaration

    Swift

    class EqualizerViewController: GeneralUIViewController
  • Stack view containing the first set of 14 frequency sliders for the left audio channel. This stack view is organized into two rows via EqualizerTableViewCell: - Row 0 (highs): 1kHz, 2kHz, 3kHz, 4kHz, 5kHz, 10kHz, 16kHz - Row 1 (lows): 8Hz, 16Hz, 32Hz, 64Hz, 128Hz, 256Hz, 512Hz - Note: Connected to storyboard via Interface Builder - SeeAlso: EqualizerTableViewCell for individual slider configuration Stack view containing the second set of 14 frequency sliders for the right audio channel. This stack view mirrors sliderStackView1 but controls the right audio channel. The frequency bands are identical to the left channel, allowing independent dual-channel equalization. - Note: Connected to storyboard via Interface Builder - Important: Both channels must be configured identically for mono audio sources

    Declaration

    Swift

    class EqualizerViewController: GeneralUIViewController
  • This button allows the user to toggle between Record and Stop mode if in real time, otherwise it will allow toggling between Play and Pause mode.

    Declaration

    Swift

    @IBOutlet weak var mainButton: UIButton!
  • A flag used to represent if in realTime or if audio clip was recorded on the previous GeneralUIViewConroller.

    Declaration

    Swift

    var realTime: Bool!
  • If in realTime, this flag determines if the class is in record mode or stop mode. If not in realTime, this flag determines if the class is in play mode or pause mode.

    Declaration

    Swift

    var state: Bool = true
  • Indicates which audio channel is currently being controlled by the sliders. When true, the sliders control the right channel equalizer bands. When false, the sliders control the left channel equalizer bands. This allows users to independently adjust gains for each stereo channel.

    Declaration

    Swift

    class EqualizerViewController: GeneralUIViewController
  • Set’s the mainButton imageView based on realTime.

    Declaration

    Swift

    override func viewWillAppear(_ animated: Bool)
  • Check if user recorded clip or if they want to use real-time recording. Set the value for realTime based on if recordedAudio is nil. Once realTime is set, setupEqualizer is called.

    Declaration

    Swift

    override func viewDidLoad()
  • Remove notification observers when view will disappear.

    Declaration

    Swift

    override func viewWillDisappear(_ animated: Bool)
  • Store data from the sliders.

    Declaration

    Swift

    override func viewDidDisappear(_ animated: Bool)
  • This function is called as a callback function in the case that the number of channels requested from the tapped input is less than 2.

    Declaration

    Swift

    func failedToGetDesiredNumberOfChannels()
  • This function is called every time a VerticalSlider changes. It updates the actual gain values within each equalizer.

    Declaration

    Swift

    func updateGains()
  • This is a callback function to update UIElements after the clip finishes playing.

    Declaration

    Swift

    func finishedPlayingClip()
  • This IBAction is called by mainButton. Based on realTime and state, it manages setting the imageView for mainButton. As well as changing state for future toggles.

    Declaration

    Swift

    @IBAction func toggleAudio(_ sender: UIButton)