Skip to content

Simple sound meter Android app created with Jetpack Compose with dynamic theming

License

Notifications You must be signed in to change notification settings

albertopasqualetto/SoundMeterESP

Repository files navigation

SoundMeterESP App icon

This is a simple sound meter Android app created for the Embedded Systems Programming course (Computer Engineering) at the University of Padua.

Description

It uses the internal microphone of the device to measure the sound level in decibels.

The sound level is displayed in a chart and in a text view in "real time", also there is the history of the sound level of the last 5 minutes.

Technical details

The app is written in Kotlin and uses the MPAndroidChart library to display the chart.

The app is based on Jetpack Compose for showing the UI and it follows material3 guidelines and style as much as possible.

Its targetSdk is API 31 (Android 12) since my device is running Android 12 (Samsung Galaxy S10) and the minSdk is API 26. It implements the dynamic color theming introduced in Android 12 both in icon and in the app's colors.

The app uses a foreground service to keep the microphone active even when the app is in background so that it can keep measuring the sound level.

The dB value presented is not accurate since it is not calibrated with a reference of 0 dB and the MediaRecorder.AudioSource.MIC does some elaboration to the audio (MediaRecorder.AudioSource.UNPROCESSED is not used since it is not supported on all the devices); but it is enough to see the difference between a quiet and a loud environment.

Some Google's libraries are used to get the screen height on rotation in order to choose the right screen layout (material3-window-size-class) and for asking and managing the permissions at runtime easily in compose (accompanist-permissions) which relies on the androidx's APIs.

Screenshots

Horizontal layout in light mode:

Horizontal light mode last second view Horizontal light mode last five minutes view

Vertical layout in dark mode:

Vertical dark mode last second view Vertical dark mode last five minutes view