Releases: RMANOV/Auto-Brightness-Sound-Levels-Windows-Linux
v1.3.0 - Sun-aware seasonal adaptation (NOAA)
What's New
- NOAA solar calculator built into both Python and Rust controllers — calculates sunrise/sunset for your location, adapts smoothing speed during light transition windows
- 1.5x faster convergence during sunrise/sunset (30min before to 2h after each event)
- Convergence log now shows active sun window:
Converged in 11.6s (Sunrise window)
Bug Fixes
- Fix ABRT crash: cleanup no longer opens cameras 0-9 with
cv2.VideoCapture()— was causing C++ exceptions on non-existent devices - Fix cron using Python instead of Rust:
USE_RUST=""unblocks auto-detection (was"false", which blocked the!= "false"check) - Zero compiler warnings — removed all dead code, unused imports/fields
Binary
adaptive-controller— Linux x86_64, 780K stripped, LTO-optimized- Run:
./adaptive-controller(auto-exit) or./adaptive-controller --continuous - Location config:
~/.config/adaptive-controller/location.conf
v1.2.2 - Fix Rust convergence & v4l2 capture
What's Changed
- Fix convergence bug: Rust auto-exit now compares smoothed values against the previous target (matching Python behavior). With noisy camera readings, the current target fluctuates each tick — comparing against it prevented convergence. Converges in ~12s now.
- Fix v4l2 capture:
capture_frame()now correctly takes&mut self(required byMmapStream::next()) - Fix camera_worker:
camerabinding is nowmutto match the updated signature
Binary
adaptive-controller— Linux x86_64, 780K stripped, LTO-optimized- Run:
./adaptive-controller(auto-exit) or./adaptive-controller --continuous
v1.2.0 — Windows Native: Sun-Aware Adaptive Controller
Adaptive Brightness & Volume Controller v1.2.0 — Windows Native
Sun-Aware. Zero-Dependency. Blazing Fast.
The Rust performance engine now runs natively on Windows — no Python, no WSL, no virtual machines. Just a single .exe that intelligently adapts your display and audio to natural light cycles.
What's New
Full Windows Port
- Native Windows binary — starts in <100ms, uses <4MB RAM
- No external dependencies — everything is self-contained
- Automatic volume control via Windows Core Audio API (pre-compiled C# helper, compiled once from embedded source via
csc.exe) - Laptop brightness via WMI (graceful fallback on desktop monitors)
- Cross-platform audio capture via cpal (WASAPI on Windows)
Privacy-First Microphone Usage
- Microphone active only 4% of the time (200ms sample every 5 seconds)
- Indicator light stays OFF between samples — no always-on surveillance feel
- Sun-position updates every 2s (was 100ms) — matched to actual rate of change
- ~96% reduction in audio hardware usage vs continuous capture
NOAA Solar Position Engine
- Pure-math sunrise/sunset calculator replaces physical camera
- Hardcoded for Sofia, Bulgaria (42.6977°N, 23.3219°E)
- Smooth cosine-interpolated brightness curves at dawn/dusk
- Sun-window detection: 1.5x accelerated adaptation during transitions
- Today (Feb 8): sunrise 07:32, sunset 17:48 ☀️
Intelligent Zero-UI Scheduling
- Daily planner runs at midnight, calculates exact sunrise/sunset via NOAA
- Sets precise one-shot triggers in Windows Task Scheduler — no waiting, no sleep
- Controller
.exelaunches directly — no PowerShell window, no wrapper, fully hidden - Seasonal adaptation — trigger times shift automatically throughout the year
- ~90% energy savings vs continuous operation
Architecture:
AdaptiveController-Planner (00:05 daily, hidden, <1s)
│ NOAA solar calculator → today's sunrise/sunset
│
├── AdaptiveController-Sunrise → exact time (e.g. 06:10)
│ └── adaptive-controller.exe (direct, no wrapper)
│
└── AdaptiveController-Sunset → exact time (e.g. 18:10)
└── adaptive-controller.exe (direct, no wrapper)
System Architecture
┌─────────────────────────────────────────────┐
│ adaptive-controller.exe │
├──────────┬──────────┬──────────┬────────────┤
│ Sun NOAA │ cpal │ WMI/PS │ C# CoreAudio│
│ Position │ Audio │ Brightness│ Volume │
│ (2s poll)│(200ms/5s)│ Control │ Control │
├──────────┴──────────┴──────────┴────────────┤
│ adaptive-core │
│ SIMD brightness · log volume · smooth EMA │
│ change detection · screen analysis · sun │
└─────────────────────────────────────────────┘
Performance
| Metric | Python + Numba | Rust Native |
|---|---|---|
| Startup | 2-3s | <100ms |
| Memory | ~45MB | <4MB |
| Brightness calc | 0.08ms | 0.02ms |
| Volume mapping | 0.015ms | 0.003ms |
| Convergence | ~30s | ~15s |
| Mic duty cycle | ~100% | ~4% |
Quick Start (Windows)
# One-time setup: create scheduled tasks
powershell -ExecutionPolicy Bypass -File scripts\setup-tasks.ps1
# Manual one-time run
.\adaptive-rust\target\release\adaptive-controller.exe
# Continuous mode
.\adaptive-rust\target\release\adaptive-controller.exe --continuous
# Check volume helper
%APPDATA%\adaptive-controller\volume_helper.exe getFiles
adaptive-rust/target/release/adaptive-controller.exe— main binaryscripts/daily-planner.ps1— NOAA sunrise/sunset → Task Scheduler triggersscripts/setup-tasks.ps1— one-time task creation%APPDATA%/adaptive-controller/volume_helper.exe— auto-compiled audio helper%APPDATA%/adaptive-controller/controller.log— runtime logs
Built with Rust 1.93 · SIMD-optimized · LTO fat · Privacy-first audio sampling
v2.0.0 — Exposure Lock, NVIDIA Workaround & Windows Support
What's New in v2.0.0
Exposure Lock for Accurate Ambient Light Detection
Camera auto-exposure was defeating brightness detection by compensating for ambient light changes. The controller now locks camera exposure (manual mode, fixed at -4) so that np.mean(frame) directly correlates with real room brightness. Exposure lock is enabled by default and degrades gracefully when unsupported.
NVIDIA Virtual Camera Workaround
NVIDIA Broadcast's virtual camera (VCAMDS) typically occupies camera index 0, causing the controller to read a processed video feed instead of ambient light. The new camera setup:
- Phase 1: Tries DirectShow (DSHOW) backend on indices 0–9, testing each for exposure control to distinguish real cameras from virtual ones
- Phase 2: Falls back to MSMF backend if DSHOW fails (works but without exposure lock)
Windows Platform Support
- WMI brightness control via PowerShell (
WmiMonitorBrightness/WmiMonitorBrightnessMethods) - Volume control via nircmd (if available) or PowerShell SendKeys fallback
- Platform-aware camera backend selection
Other Changes
- Removed project-specific CLAUDE.md (consolidated globally)
- Simplified log output (removed emojis for logging compatibility)
- Moved
import subprocessto top-level for cleaner imports
Preserved
All existing features remain intact:
- Rust SIMD acceleration with Python fallback
- Numba JIT compilation
- Linux support (brightnessctl, xbacklight, sysfs, amixer, pactl, wpctl)
- All screen capture methods (PIL, MSS, xrandr, GTK)
- All audio input methods (sounddevice, arecord, sox)
Full Changelog: v1.0.0...v2.0.0
v1.2.1 — Auto-exit is now default
What's Changed
Auto-exit (converge & stop) is now the permanent default behavior — no flags needed.
# Default: adjusts brightness + volume, converges in ~19s, exits
python3 adaptive_brightness_volume.py
# Old behavior (run forever):
python3 adaptive_brightness_volume.py --continuousSame for the Rust binary.
v1.2.0 — Auto-Exit Convergence Mode
What's Changed
New Feature: --auto-exit Mode
Run the controller just long enough to adjust brightness and volume, then exit automatically.
python3 adaptive_brightness_volume.py --auto-exit
# or Rust binary:
./adaptive-controller --auto-exitHow it works:
- Monitors convergence of both brightness and volume toward their targets
- After warmup, checks if
|smoothed - target| < 1%for both channels - Exits after 3 consecutive stable frames confirm convergence
- Typical convergence time: ~23 seconds (vs infinite before)
- Without
--auto-exit, behavior is unchanged (continuous mode)
Bug Fix: Audio Warmup Never Completing
current_warmup_framecounter stopped incrementing after brightness warmup ended at frame 20- Audio warmup required frame 40 but the counter was stuck — audio warmup never completed
- Fixed: counter now increments while either brightness or audio warmup is active
Rust Version Sync
- Added
--auto-exitto Rust binary (controller.rs+main.rs) tick()now returnsResult<bool>—truesignals convergence- Version bumped
0.1.0→1.2.0to match Python releases
Files Changed
adaptive_brightness_volume.py— auto-exit + warmup counter fixadaptive-rust/crates/bin/src/controller.rs— convergence trackingadaptive-rust/crates/bin/src/main.rs— CLI flag + convergence handlingadaptive-rust/Cargo.toml— version bump
v1.1.0 — Bug Fixes & Performance Optimizations
What's Changed
Bug Fixes
- Fixed bare
except:catchingSystemExit— 4 locations now useexcept Exception:/except Empty:, preventing silent swallowing of shutdown signals - Fixed sysfs brightness using uncalibrated value —
set_brightness()now correctly usescalibrated_brightnessfor the sysfs path, matching behavior of other methods - Fixed
arecordsub-second recording — replaced invalid-d 0.1(integer-only flag) with--samples=4410for correct 100ms audio capture - Fixed shell injection in
adaptive_controller_manager.sh—$saved_brightnessfrom config file was interpolated into Python code via double-quoted heredoc; now passed safely via environment variable
Performance
- Cached volume tool detection at startup —
which amixer/pactl/wpctlwas spawning a shell process on everyget_volume()/set_volume()call (~every 0.5-2s); now detected once viashutil.which()at init - Replaced deprecated
os.popen()withsubprocess.run()— proper error handling and timeouts for brightness/volume commands - Precompiled regex patterns — volume parsing regexes compiled once at module level instead of on every call
Reliability
- Instance-level screen capture disable — when screen capture fails repeatedly, it now disables per-instance (
self.screen_capture_enabled) instead of mutating the globalSCREEN_CAPTURE_AVAILABLE, preventing cross-instance side effects
Files Changed
adaptive_brightness_volume.py— 7 fixes across error handling, performance, and correctnessadaptive_controller_manager.sh— shell injection fix in flash detection heredoc
v1.0.0 — Adaptive Brightness & Volume Controller with Rust SIMD Engine
Cross-platform adaptive display and audio management system. Python+Numba core with optional Rust backend (2–4x faster, SIMD-optimized, zero-copy PyO3). Sunrise/sunset geographic scheduling achieves ~90% energy savings. Camera-based ambient light sensing, flash detection, and intelligent cron automation.
Highlights
- Rust SIMD Backend — 8-wide vectorization, 3–6ms cycle time (vs 12ms Python)
- Sunrise/Sunset Scheduling — geographic awareness, ~90% energy savings
- Camera-Based Sensing — ambient light detection, >40% flash threshold
- Lock-Free Architecture — zero-copy NumPy interop via PyO3
- Cross-Platform — Linux + Windows, auto-detected backend
Stack
Rust + PyO3 | Python + Numba + OpenCV | NumPy | cron scheduling