Skip to content

Architecture

Thiago Fernando Rech edited this page Jun 30, 2025 · 2 revisions

Architecture

ToneForge uses a modular architecture with native C++ audio processing and Java UI components.

Main Components

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   AudioRecord   │───▢│  Audio Engine   │───▢│   AudioTrack    β”‚
β”‚   (Input)       β”‚    β”‚   (C++/JNI)     β”‚    β”‚   (Output)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Audio Processing Pipeline

  1. Capture: AudioRecord captures audio from microphone
  2. Processing: Buffer sent to audio_engine.cpp via JNI
  3. Effects: Sequential application according to configured order
  4. Playback: AudioTrack plays processed audio

File Structure

app/src/main/
β”œβ”€β”€ cpp/
β”‚   β”œβ”€β”€ audio_engine.h      # Audio engine header
β”‚   β”œβ”€β”€ audio_engine.cpp    # Effect implementations
β”‚   β”œβ”€β”€ native-lib.cpp      # JNI methods
β”‚   └── CMakeLists.txt      # Build configuration
β”œβ”€β”€ java/
β”‚   └── com/thiagofernendorech/toneforge/
β”‚       β”œβ”€β”€ MainActivity.java              # Main interface and navigation
β”‚       β”œβ”€β”€ AudioEngine.java               # Real-time audio pipeline
β”‚       β”œβ”€β”€ EffectsFragment.java           # Effects interface and presets
β”‚       β”œβ”€β”€ EffectOrderAdapter.java        # Effect order adapter
β”‚       β”œβ”€β”€ HomeFragment.java              # Home screen
β”‚       β”œβ”€β”€ TunerFragment.java             # Real-time tuner
β”‚       β”œβ”€β”€ MetronomeFragment.java         # Metronome
β”‚       β”œβ”€β”€ LooperFragment.java            # Loop recorder
β”‚       β”œβ”€β”€ RecorderFragment.java          # Audio recorder
β”‚       β”œβ”€β”€ LearningFragment.java          # Learning screen
β”‚       β”œβ”€β”€ SettingsFragment.java          # Settings
β”‚       β”œβ”€β”€ AudioBackgroundService.java    # Background audio service
β”‚       β”œβ”€β”€ AudioStateManager.java         # Effect state management
β”‚       β”œβ”€β”€ PipelineManager.java           # Audio pipeline management
β”‚       β”œβ”€β”€ PermissionManager.java         # Permission management
β”‚       β”œβ”€β”€ StateRecoveryManager.java      # State recovery
β”‚       β”œβ”€β”€ PresetManager.java             # Preset management
β”‚       β”œβ”€β”€ FavoritesManager.java          # Favorites management
β”‚       β”œβ”€β”€ TooltipManager.java            # Tooltip management
β”‚       └── FavoritePresetAdapter.java     # Favorite presets adapter
β”œβ”€β”€ res/
β”‚   β”œβ”€β”€ layout/
β”‚   β”‚   β”œβ”€β”€ activity_main.xml      # Main layout
β”‚   β”‚   β”œβ”€β”€ fragment_effects.xml   # Effects interface
β”‚   β”‚   β”œβ”€β”€ fragment_home.xml      # Home screen
β”‚   β”‚   β”œβ”€β”€ fragment_tuner.xml     # Tuner
β”‚   β”‚   β”œβ”€β”€ fragment_metronome.xml # Metronome
β”‚   β”‚   β”œβ”€β”€ fragment_looper.xml    # Looper
β”‚   β”‚   β”œβ”€β”€ fragment_recorder.xml  # Recorder
β”‚   β”‚   β”œβ”€β”€ fragment_learning.xml  # Learning
β”‚   β”‚   └── fragment_settings.xml  # Settings
β”‚   β”œβ”€β”€ drawable/
β”‚   β”‚   β”œβ”€β”€ ic_*.xml               # Interface icons
β”‚   β”‚   β”œβ”€β”€ bg_gradient.xml        # Background gradient
β”‚   β”‚   β”œβ”€β”€ button_background.xml  # Button styles
β”‚   β”‚   └── round_button.xml       # Rounded buttons
β”‚   β”œβ”€β”€ navigation/
β”‚   β”‚   └── nav_graph.xml          # Screen navigation
β”‚   β”œβ”€β”€ anim/
β”‚   β”‚   β”œβ”€β”€ slide_in_*.xml         # Entry animations
β”‚   β”‚   └── slide_out_*.xml        # Exit animations
β”‚   β”œβ”€β”€ values/
β”‚   β”‚   β”œβ”€β”€ colors.xml             # Theme colors
β”‚   β”‚   β”œβ”€β”€ strings.xml            # Localized strings
β”‚   β”‚   β”œβ”€β”€ arrays.xml             # Arrays (distortion types)
β”‚   β”‚   └── themes.xml             # App themes
β”‚   β”œβ”€β”€ values-night/
β”‚   β”‚   └── themes.xml             # Dark theme
β”‚   β”œβ”€β”€ mipmap-*/                  # App icons (different densities)
β”‚   └── xml/
β”‚       β”œβ”€β”€ backup_rules.xml       # Backup rules
β”‚       └── data_extraction_rules.xml # Data extraction rules
└── AndroidManifest.xml            # App configuration

Technologies Used

  • Gradle: Build system
  • CMake: Native code build
  • JNI: Java-C++ interface
  • AudioRecord/AudioTrack: Android audio API
  • Fragments: Multi-screen navigation
  • RecyclerView: Drag-and-drop interface
  • SharedPreferences: Data persistence

Background Processing

Continuous Audio

  • ForegroundService: Keeps audio processing active with screen off
  • Persistent notification: Shows audio status and quick controls
  • Activation control: Switch in settings to enable/disable
  • Pipeline management: Automatic recovery from errors

State Recovery

  • Automatic saving: State saved when app goes to background
  • Smart restoration: Settings restored when returning
  • Recovery of: Pipeline, presets, oversampling, active effects
  • Synchronization: Interface updated with real state

Permission System

  • Required permissions: Microphone, notifications, storage
  • Optional permissions: Overlay, battery optimization
  • Automatic verification: Permission requests on startup
  • Compatibility: Support for different Android versions

See Development for setup and build instructions.

ToneForge Wiki

πŸš€ Getting Started

πŸŽ›οΈ Effects & Features

🧠 Advanced Features πŸ†•

🎡 Learning & Practice

πŸ”§ Technical


Quick Links:

Clone this wiki locally