   private func stopMetering() {
     link?.invalidate()
   }
-
 }

    recorder.meteringEnabled = metering
  }

  public func record() {
    if recorder == nil {
      prepare()
    }

    session.setCategory(AVAudioSessionCategoryRecord, error: nil)

    recorder.record()


    recorder.stop()
  }

  public func play() throws {
    try session.setCategory(AVAudioSessionCategoryPlayback)

    player = try AVAudioPlayer(contentsOfURL: url)
    player.play()
  }

  public func updateMeter() {
    recorder.updateMeters()

    let dB = recorder.averagePowerForChannel(0)

    delegate.audioMeterDidUpdate?(dB)
  }
