RepositoryKotlinPKPakistan
AhmadHassan-BTed

AhmadHassan-BTed/AhSilence

An open-source Android Active Noise Cancellation (ANC) engine. Leveraging low-latency DSP to neutralize environmental hums and help you reclaim your quiet.

4.9ksao
16fork
0issue
13lượt xem

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: jetpack-compose

#1 Repository của tuần

1
TINIX TRENDING·Chủ đề: active-noise-cancellation

#1 Repository của tuần

1
TINIX TRENDING·Chủ đề: clean-architecture

#1 Repository của tuần

AhSilence Banner

AhSilence

Silence the ambient hum. Find your perfect quiet.

Kotlin API Level Architecture DSP License


Overview

AhSilence is a native Android active noise cancellation (ANC) engine built with Jetpack Compose and Kotlin. It bridges the gap between complex digital signal processing (DSP) and human comfort by analyzing the environment for persistent, low-frequency hums (such as AC units or electrical drones) and emitting phase-inverted audio waves that mathematically neutralize acoustic disturbances.

The application runs a zero-allocation, GC-free hot loop, ensuring seamless destructive interference without frame drops or OS throttling.

Key Features

ComponentImplementationUser Benefit
FFT EngineCustom Cooley-Tukey Radix-2 algorithm on real-time PCM buffersAutomatically detects the dominant background drone
Phase CalibratorContinuous 360° trigonometric dial bound to memory blocksManual wave alignment to compensate for hardware/BT latency
OS ShieldAndroid Foreground Service with persistent notificationKeeps cancellation active while screen is locked
Stateless UIStateFlow + Compose hoisted parametersZero battery drain from unnecessary recompositions

Architecture

AhSilence follows Clean Architecture with strict unidirectional data flow and complete isolation of the Android framework from core business logic.

graph TD
    subgraph Presentation Layer
        UI[Jetpack Compose UI]
        VM[ControlViewModel]
    end

    subgraph Domain Layer
        STATE((AcousticState))
        PORT{AudioEngine Port}
    end

    subgraph Data Layer
        SERVICE[ActiveHumService]
        DSP[NativeAudioDSP]
        FFT[FastFourier]
    end

    UI -->|Observes State| VM
    UI -->|OS Intent| SERVICE
    VM -->|Updates| STATE
    VM -->|Injects Phase/Gain| PORT
    SERVICE -->|Foreground Shield| DSP
    DSP -->|Implements| PORT
    DSP -->|PCM Buffer Math| FFT

    classDef domain fill:#1E1E1E,stroke:#7F52FF,stroke-width:2px;
    class STATE,PORT domain;

Data Flow

sequenceDiagram
    participant M as Microphone
    participant E as NativeAudioDSP
    participant F as FastFourier (FFT)
    participant U as Dashboard UI
    participant S as Speaker (AudioTrack)

    Note over M,E: 7-Second Ambient Scan
    M->>E: Capture Raw PCM Buffer
    E->>F: Compute Radix-2 FFT
    F-->>E: Extract Dominant Frequency (Hz)
    E-->>U: Push AcousticState Update

    Note over U,S: User Calibration
    U->>E: Inject Phase Offset (°) & Amplitude

    Note over E,S: Continuous Emission Loop
    loop GC-Free Hot Loop
        E->>E: Synthesize Inverted Sine Wave
        E->>S: Push Buffer (AudioTrack.WRITE_BLOCKING)
        S->>M: Destructive Acoustic Interference
    end

Project Structure

app/src/main/java/com/bted/ahsilence/
├── core/                                # Cross-cutting concerns
│   ├── constants/AudioConstants.kt      # Centralised magic numbers
│   ├── di/AudioEngineLocator.kt         # Lightweight service locator
│   └── logging/AppLogger.kt            # Structured logging facade
│
├── domain/                              # Pure Kotlin — zero Android imports
│   ├── model/AcousticState.kt           # Immutable single source of truth
│   └── port/AudioEngine.kt             # DSP engine contract
│
├── data/                                # Android framework implementations
│   ├── engine/FastFourier.kt            # Radix-2 FFT math engine
│   ├── engine/NativeAudioDSP.kt        # AudioRecord / AudioTrack pipeline
│   └── service/ActiveHumService.kt     # Foreground service (OS Shield)
│
├── presentation/                        # State management
│   └── ControlViewModel.kt             # Jetpack Compose bridge
│
├── ui/                                  # Visual layer
│   ├── screen/DashboardScreen.kt        # Main dashboard (Pro / Simple mode)
│   ├── component/                       # Reusable UI elements
│   │   ├── CalibratorRing.kt           # 360° phase dial
│   │   └── GainSlider.kt               # Vertical amplitude fader
│   └── theme/                           # OLED Black / Neon Amber design system
│       ├── Color.kt
│       ├── Theme.kt
│       └── Type.kt
│
└── MainActivity.kt                      # Entry point

Getting Started

Prerequisites

  • Android Studio Ladybug (2024.2.1+)
  • JDK 21+
  • Physical Android device — emulators do not support low-latency hardware microphone FFT testing

Build

# Clone
git clone https://github.com/ahmadhassan-bted/ahsilence.git
cd ahsilence

# Build debug APK
./gradlew clean assembleDebug

# Run unit tests
./gradlew test

# Lint check
./gradlew lint

Install

# Install on connected device
./gradlew installDebug

Tech Stack

LayerTechnology
LanguageKotlin 2.0.21
UIJetpack Compose (Material 3)
StateStateFlow + ViewModel
Audio CaptureAudioRecord (PCM 16-bit, 44.1kHz)
Audio PlaybackAudioTrack (streaming mode)
FFTCustom Cooley-Tukey Radix-2
BackgroundForeground Service (mediaPlayback)
BuildGradle (Kotlin DSL) + Version Catalog
Min SDKAPI 26 (Android 8.0)

Contributing

See CONTRIBUTING.md for branch naming, commit conventions, and the non-negotiable architectural rules (zero-allocation hot loops, domain isolation, UI purity).

Security

AhSilence is fully offline — zero network calls, zero data collection, zero telemetry. See SECURITY.md.

Roadmap

See ROADMAP.md for planned features including multi-frequency cancellation, adaptive algorithms, and Bluetooth latency compensation.

License

Copyright 2025 Ahmad Hassan

Licensed under the Apache License, Version 2.0.
See LICENSE for details.

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryC++
kfrlib/kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON, RISC-V RVV)

1.9k
Nov 25, 2026
RepositoryKotlin
gkd-kit/gkd

基于无障碍,高级选择器,订阅规则的自定义屏幕点击安卓应用 | An Android APP with custom screen tapping based on Accessibility, Advanced Selectors, and Subscription Rules

45.7k
Nov 13, 2026
RepositoryKotlin
JunkFood02/Seal

🦭 Video/Audio Downloader for Android, based on yt-dlp

31.2k
Nov 25, 2026
RepositoryTypeScript
morluto/rea

Reverse engineer anything with agents, from app behavior down to native binaries.

487.0k
Dec 2, 2026
RepositoryC++
google-ai-edge/mediapipe

Cross-platform, customizable ML solutions for live and streaming media.

38.0k
Nov 30, 2026
RepositoryKotlin
lysine-dev/okhttp

A meticulous HTTP client for the JVM, Android, and GraalVM.

47.1k
Nov 27, 2026
RepositoryKotlin
komi-store/komi-store

🩵 A free, open-source app store for developers' releases on GitHub, Codeberg & Forgejo — browse, discover, and install apps with one click. Formerly GitHub Store.

23.2k
Dec 1, 2026
RepositoryKotlin
android/nowinandroid

A fully functional Android app built entirely with Kotlin and Jetpack Compose

22.2k
Dec 1, 2026
RepositoryKotlin
T8RIN/ImageToolbox

🖼️ Image Toolbox is a powerful app for advanced image manipulation. It offers dozens of features, from basic tools like crop and draw to filters, OCR, and a wide range of image processing options

15.9k
Nov 29, 2026