Skip to content

AMazkun/MacVoiceRecorder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ™οΈ Audio Recorder for macOS

A modern, native macOS audio recording application built with SwiftUI and following MVVM architecture. Record from multiple audio sources with real-time visualization and intuitive management.

macOS 12.0+ Swift 5.9+ SwiftUI License

✨ Features

Main Screen

🎀 Multiple Audio Sources

  • Microphone - Record from your built-in or external microphone
  • System Audio Microphone - Capture bypass system input audio microphone
  • System Audio Speakers - Capture bypass system output audio (speakers/headphones)

Real-time Audio Visualization

  • Live waveform display with 50-bar visualization
  • Color gradient (blue β†’ cyan β†’ green)
  • Smooth animations and RMS-based level calculation
  • Works with all recording sources

Recording Controls

  • Start/Stop recording with one click
  • Pause/Resume functionality
  • Live recording timer (MM:SS or HH:MM:SS format)
  • Visual status indicator (red = recording, orange = paused, gray = stopped)

Recording Management

  • View all recordings with metadata:
    • Timestamp (date and time)
    • Duration
    • File size
    • Format (M4A/AAC)
    • Audio source icon
  • Play/Stop recordings directly in the app
  • Delete recordings via context menu or keyboard (⌫/⌘⌫)
  • Remaining time display during playback
  • Selection highlighting

Permission Handling

  • Automatic microphone permission requests
  • Direct link to System Settings if permission denied
  • Clear error messages and guidance

Native macOS Design

  • Follows macOS Human Interface Guidelines
  • Dark mode support dual color scheme
  • Native window controls
  • Keyboard shortcuts support Delete
  • Focus management for accessibility

Architecture

The app follows MVVM (Model-View-ViewModel) pattern with clean separation of concerns:

  • Combine framework for reactive programming
  • Async/await for asynchronous operations CoreData, etc
β”œβ”€β”€ Models
β”‚   β”œβ”€β”€ Recording (Core Data)
β”‚   └── RecordingData
β”œβ”€β”€ ViewModels
β”‚   β”œβ”€β”€ AudioInspectorModel
β”‚   └── AudioRecorderVMl
β”œβ”€β”€ Views
β”‚   β”œβ”€β”€ ContentView
β”‚   β”œβ”€β”€ AudioinspectorView
β”‚   β”œβ”€β”€ Colors
β”‚   β”œβ”€β”€ HeaderView
β”‚   β”œβ”€β”€ RecordingControlsView
β”‚   β”œβ”€β”€ AudioVisualizerView
β”‚   β”œβ”€β”€ RecordingsListView
β”‚   └── RecordingRow
β”œβ”€β”€ Services
β”‚   β”œβ”€β”€ AudioRecordingService
β”‚   β”œβ”€β”€ AudioPlaybackService
β”‚   β”œβ”€β”€ SystemAudioRecorderSource
β”‚   └── PersistenceController
└── App
    └── MacVoiceRecorderApp

Key Components

Services Layer:

  • AudioRecordingService - Handles audio capture using AVFoundation
  • AudioPlaybackService - Manages audio playback
  • PersistenceController - Core Data management

ViewModel:

  • AudioRecorderViewModel - Business logic, state management, and service coordination
  • Published properties for reactive UI updates
  • Proper memory management with weak references

Views:

  • SwiftUI-based declarative UI
  • Reusable components
  • Accessibility support

πŸ› οΈ Technical Details

Technologies Used

  • SwiftUI - Modern declarative UI framework
  • AVFoundation - Audio recording and playback
    • AVAudioRecorder for microphone recording
    • AVAudioEngine for system audio and mixing
    • AVAudioMixerNode for combining audio sources
    • AVAudioPlayer for playback
  • Core Data - SQL Light DB Persistent storage (programmatic model)
  • Combine - Reactive programming with @Published properties

Audio Specifications

  • Format: M4A (AAC codec)
  • Sample Rate: 44.1 kHz
  • Channels: Stereo (2)
  • Bit Rate: 192 kbps
  • Quality: High

Features Implementation

  • Audio Level Monitoring: RMS (Root Mean Square) calculation with 50ms updates
  • Timer Precision: 100ms update interval
  • Pause/Resume: Maintains accurate duration tracking across pauses
  • Concurrency: Swift 6 compliant with Sendable conformance

πŸ“‹ Requirements

  • macOS 12.0 (Monterey) or later
  • Xcode 14.0+
  • Swift 5.9+

πŸš€ Installation

  1. Clone the repository:
git clone https://github.com/yourusername/audio-recorder-macos.git
cd audio-recorder-macos
  1. Open the project in Xcode:
open AudioRecorder.xcodeproj
  1. Check microphone usage description to Info.plist:
<key>NSMicrophoneUsageDescription</key>
<string>This app needs microphone access to record audio.</string>
  1. Check Sendbox microphone usage

  2. Change development team

  3. Build and run (⌘R)

πŸ“± Usage

Recording Audio

  1. Select audio source using the segmented picker:
    • 🎀 Microphone
    • πŸ”Š System Audio
  2. Click Start Recording
  3. Monitor the live waveform visualization
  4. Use Pause/Resume as needed
  5. Click Stop when finished

Managing Recordings

  • Play: Click the play button next to any recording
  • Delete: Right-click β†’ Delete, or select and press ⌫
  • View details: Timestamp, duration, file size, format, and source

Keyboard Shortcuts

  • ⌫ - Delete selected recording
  • Standard macOS shortcuts work in context menus

πŸ”§ Configuration

Changing Audio Format

Modify the output settings in AudioRecordingService:

let outputSettings: [String: Any] = [
    AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
    AVSampleRateKey: 44100.0,
    AVNumberOfChannelsKey: 2,
    AVEncoderBitRateKey: 192000
]

Adjusting Visualization

Modify AudioVisualizerView bar count or colors:

@State private var bars: [Float] = Array(repeating: 0, count: 50) // Change count

πŸ§ͺ Testing

The MVVM architecture makes testing straightforward:

  • Mock AudioRecordingServiceProtocol for pecording tests
  • Mock AudioPlaybackServiceProtocol for playback tests
  • Mock Persistent manager
  • Test ViewModels independently of Views

πŸ› Known Issues

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with ❀️ using SwiftUI and AVFoundation
  • Inspired by modern macOS design principles
  • Thanks to the Swift community for best practices

πŸ“§ Contact


⭐ If you found this project useful, please consider giving it a star!

About

MacOs Audio Capture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages