AudioRecorderProtocol.swift 886 B

123456789101112131415161718192021222324
  1. import Foundation
  2. import Combine
  3. /// Protocol abstracting audio recording capabilities.
  4. /// Allows swapping between Mock and Real (AVAudioEngine) implementations.
  5. protocol AudioRecorderProtocol: ObservableObject {
  6. /// Current recording state
  7. var isRecording: Bool { get }
  8. /// Elapsed recording time in seconds
  9. var elapsedTime: TimeInterval { get }
  10. /// Current amplitude level (0.0 - 1.0) for waveform visualization
  11. var currentAmplitude: Float { get }
  12. /// Rolling buffer of recent amplitude samples for waveform drawing
  13. var waveformSamples: [Float] { get }
  14. /// The local file URL of the current/last recording. nil for mock.
  15. var outputFileURL: URL? { get }
  16. /// Whether the active recording is paused
  17. var isPaused: Bool { get }
  18. func startRecording()
  19. func stopRecording()
  20. func pauseRecording()
  21. func resumeRecording()
  22. }