How albertopasqualetto/soundmeteresp works
Project Type and Purpose
• This is a mobile (Android) application focused on real‐time sound level measurement.
• It uses the device’s internal microphone to measure sound (in decibels) and displays the readings in both a text view and a chart.
• The app is built for educational purposes (Embedded Systems Programming at the University of Padua) but employs production-level components like foreground services and Jetpack Compose UI.
File Structure
• The top-level structure follows the standard Android project layout:
• The “app” directory contains source code under “src/main/java” where the main packages (it.albertopasqualetto.soundmeteresp) reside.
• Key classes include:
• MainActivity.kt – the entry point for the UI layer.
• MeterService.kt – implements a foreground service that keeps the microphone active in the background.
• Charts.kt – handles rendering of the sound level data, utilizing MPAndroidChart.
• Values.kt – likely responsible for handling or processing measured sound data.
• Additional directories for tests indicate unit and instrumentation test setups.
• Gradle files (build.gradle, settings.gradle, etc.) indicate dependency management and build configuration.
Architectural Components
a. Main Components:
• UI Layer: Represented by MainActivity and related Jetpack Compose UI components located in the “ui” package (including theme setup, layouts, etc.). This layer manages the display of data, renders the charts, and configures dynamic/dark/light mode via Material3 guidelines.
• Service Layer: The MeterService is responsible for running a foreground service. It continuously captures sound measurements even when the app is backgrounded.
• Data Processing/Model Component: Values.kt and associated classes that might aggregate or process the microphone’s raw input into decibel values and histories (e.g., last 5 minutes).
• External Libraries/Dependencies:
▪ MPAndroidChart – used for rendering the sound level chart.
▪ Jetpack Compose and Material3 – for building the declarative UI.
▪ Additional libraries like accompanist-permissions for managing app permissions and material3-window-size-class for adaptive layouts.
b. Interactions and Data Flow:
• Sensor Input: The microphone input is captured by the MeterService.
• Data Processing: The captured sound data is processed (potentially by Values.kt or any additional helper functions) to produce decibel levels.
• Data Display: Processed data is sent to the UI (MainActivity and associated Compose components) where it’s rendered both as dynamic text and graphical charts.
• Lifecycle/Permissions: The app requests and manages runtime permissions as necessary for audio recording, and dynamic UI adjustments (e.g., screen rotations) are handled via utility libraries.
Architectural Patterns and Design Principles
• Separation of Concerns: The architecture separates the UI (MainActivity and Compose-based screens) from background operations (MeterService) and data processing (Values.kt).
• Service-Oriented Approach: Using a foreground service ensures that critical functionality (sound measurement) remains active across different app states.
• Use of External UI Libraries: Emphasizes theming and chart rendering which ensure that UI components are both aesthetically pleasing and functional.
• Standard Android Architecture: Adheres to Android’s application structure and recommendations for background work and UI updates.