A Flutter application that detects and counts breaths using the device's microphone, while also providing multiple breathing techniques with guided instructions.
Main Screen | Breath Hold | History View |
---|---|---|
![]() |
![]() |
![]() |
-
Multiple Breathing Techniques:
- Tummo Breathing: Deep breathing with breath counting and automatic breath hold
- Box Breathing: Structured 4-phase breathing with guided timing
- Fire Breath: Rapid breathing exercise with round tracking
- Three-Part Breath: Sequential belly, rib, and chest breathing
-
Breath Detection: Automatically detects and counts breaths using the device's microphone
-
Breath Visualization: Visual feedback for breathing patterns
-
Breath Hold Timer: Track breath-holding duration with a single tap
-
Session History: Records breathing sessions with breath counts and hold durations
-
Sensitivity Adjustment: Fine-tune breath detection sensitivity
-
Calibration: Automatically calibrates to ambient noise levels
-
Guided Instruction: Visual cues and text instructions for each breathing technique
- Flutter SDK 2.10.0 or higher
- Dart 2.16.0 or higher
- Android Studio / VS Code with Flutter extensions
- iOS or Android device with microphone access
- Docker (for web deployment)
-
Clone the repository:
git clone https://github.com/yourusername/breath_counter.git
-
Navigate to the project directory:
cd breath_counter
-
Install dependencies:
flutter pub get
-
Run the app:
flutter run
The app includes a Dockerfile for easy web deployment:
-
Build the Docker image:
docker build -t breath-counter .
-
Run the container:
docker run -p 8080:8080 breath-counter
-
Access the web app at
http://localhost:8080
The Docker configuration is ready for deployment to cloud platforms like:
- Fly.io
- Google Cloud Run
- AWS App Runner
- DigitalOcean App Platform
Example deployment to Fly.io:
fly launch
fly deploy
-
Initial Setup:
- When first launched, the app will request microphone permissions
- The app will automatically calibrate to the ambient noise level
- Wait for "Calibration complete" message
-
Selecting a Technique:
- Choose from 4 different breathing techniques from the sidebar
- Each technique has its own specific settings and parameters
-
Tummo Breathing:
- Press "Start" to begin breath detection and counting
- Breathe deeply near your device's microphone
- The circle will pulse with your breath, showing blue for inhales and green for exhales
- Press "Hold" to start a breath hold or wait for automatic hold after reaching the target count
- Your breath count and hold duration will be recorded
-
Box Breathing:
- Follow the guided instructions for equal-duration phases:
- Inhale → Hold → Exhale → Hold
- Customize phase durations in settings
-
Fire Breath:
- Follow the instructions for rapid breathing
- Complete multiple rounds with guidance
- Adjust pace and round count in settings
-
Three-Part Breath:
- Sequential breathing phases for belly, ribs, and chest
- Guided timing for each phase
- Customize all phase durations in settings
-
View History:
- Tap the history icon in the app bar to see your breathing sessions
- Each session shows the number of breaths and hold duration
-
Adjust Technique Settings:
- Tap the settings icon in the app bar
- Customize parameters specific to each breathing technique
- For Tummo: Adjust breath detection sensitivity and targets
The app follows a modular architecture with clear separation of concerns:
- Models: Data structures for breathing techniques and history
- Services: Core functionality for breath detection and technique guidance
- Screens: Main container screens
- Widgets: Technique-specific UI components and controls
BreathDetector
: Core service that processes microphone input to detect breathsBreathingTechniquesService
: Manages timing and instructions for each techniqueBreathCounterScreen
: Main UI container that coordinates technique switching- Technique-specific widgets for each breathing method
This app requires the following permissions:
- Microphone: Used for breath detection
- Android: Add to AndroidManifest.xml
- iOS: Add to Info.plist
- flutter_sound: Audio recording and processing
- permission_handler: Handling device permissions
- just_audio: Audio feedback
- No breaths detected: Try adjusting sensitivity or speak during a breath for more detectable sound
- False detections: Lower sensitivity or recalibrate in a quieter environment
- Calibration issues: Ensure you're in a relatively quiet environment during startup
- Technique timing problems: Adjust the timing parameters in the technique settings
- Microphone access: Ensure you've granted microphone permissions in your browser
- Browser compatibility: Chrome and Edge offer best microphone support for WebRTC APIs
- Mobile web: The web version works on mobile browsers, but native apps provide better performance
- Audio issues in web: If detection is inconsistent in web browsers, try clearing site permissions and reloading
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Flutter - UI toolkit for building natively compiled applications
- flutter_sound - Audio processing capabilities