Skip to content

Development

Thiago Fernando Rech edited this page Jul 6, 2025 · 2 revisions

Development

Prerequisites

  • Android Studio Hedgehog or newer
  • Android SDK API 27+
  • NDK (Native Development Kit)
  • Android device with microphone

Build

# Clone the repository
git clone <repository-url>
cd ToneForge

# Open in Android Studio or build via command line
./gradlew assembleDebug

Project Structure

πŸ†• Modern MVP Architecture

The project has been completely refactored to use:

  • MVP Pattern: Model-View-Presenter for clean architecture
  • Repository Pattern: Unified data access layer
  • Navigation Controller: Decoupled navigation system
  • Responsive Layouts: ConstraintLayout with adaptive dimensions
  • Comprehensive Testing: Unit, integration, and UI tests

Technologies Used

  • Gradle: Build system
  • CMake: Native code build
  • JNI: Java-C++ interface
  • AudioRecord/AudioTrack: Android audio API
  • Fragments: Multi-screen navigation with MVP
  • RecyclerView: Drag-and-drop interface
  • SharedPreferences: Data persistence
  • ConstraintLayout: Modern responsive layouts
  • Espresso/JUnit: Testing framework

Compatibility

  • Minimum Android: 8.1 (API 27)
  • Architectures: ARM64, ARM32, x86, x86_64
  • Sample rate: 48kHz
  • Format: PCM Float 32-bit
  • Channels: Mono (input and output)

πŸ†• Development with MVP Architecture

Creating a New Fragment

Follow the MVP pattern established in the project:

  1. Create the Contract:
public interface MyContract {
    interface View extends BaseView {
        void updateData(String data);
        void showProgress();
        void hideProgress();
    }
    
    interface Presenter extends BasePresenter<View> {
        void loadData();
        void onUserAction();
    }
}
  1. Implement the Presenter:
public class MyPresenter implements MyContract.Presenter {
    private WeakReference<MyContract.View> viewRef;
    private AudioRepository audioRepository;
    
    public MyPresenter(Context context, AudioRepository repository) {
        this.audioRepository = repository;
    }
    
    @Override
    public void loadData() {
        ifViewAttached(view -> {
            view.showProgress();
            // Load data and update view
            view.updateData("Loaded data");
            view.hideProgress();
        });
    }
}
  1. Create the Fragment:
public class MyFragment extends BaseFragment<MyContract.Presenter> 
    implements MyContract.View {
    
    @Override
    protected MyContract.Presenter createPresenter() {
        return new MyPresenter(
            requireContext(),
            AudioRepository.getInstance(requireContext())
        );
    }
    
    @Override
    public void updateData(String data) {
        // Update UI with data
    }
}

Testing Your Components

Write comprehensive tests for your presenter:

@Test
public void testPresenter_loadData() {
    // Arrange
    MyPresenter presenter = new MyPresenter(context, mockRepository);
    presenter.attachView(mockView);
    
    // Act
    presenter.loadData();
    
    // Assert
    verify(mockView).showProgress();
    verify(mockView).updateData(anyString());
    verify(mockView).hideProgress();
}

Layout Guidelines

Follow responsive design principles:

<!-- Use responsive dimensions -->
android:layout_margin="@dimen/margin_medium"
android:textSize="@dimen/text_size_large"

<!-- Use ConstraintLayout for complex layouts -->
<androidx.constraintlayout.widget.ConstraintLayout>
    <Button
        android:layout_width="0dp"
        app:layout_constraintWidth_percent="0.3" />
</androidx.constraintlayout.widget.ConstraintLayout>

Troubleshooting

Common Issues

  1. Audio not working: Check microphone permissions
  2. High latency: Use device with low audio latency
  3. Crash on startup: Verify NDK is installed
  4. Effects not applying: Restart audio
  5. Presets not saving: Check disk space
  6. Order not persisting: Restart app
  7. πŸ†• MVP Navigation issues: Check NavigationController initialization
  8. πŸ†• Test failures: Ensure all dependencies are mocked properly

Logs

Use adb logcat to see detailed logs:

adb logcat | grep ToneForge

Testing

Run the test suite:

# Unit tests
./gradlew testDebugUnitTest

# UI tests  
./gradlew connectedAndroidTest

# Validation script
./scripts/functional-validation.sh

Roadmap

βœ… Completed

  • Real-time audio pipeline
  • Basic effects (Gain, Distortion, Delay, Reverb)
  • Real-time tuner
  • Preset system
  • Customizable effect order
  • Modulation effects (Chorus, Flanger, Phaser)
  • Advanced controls (dry/wet mix, distortion types)
  • Multi-screen interface with navigation
  • 3-band Equalizer (EQ)
  • Compressor with advanced controls
  • Informative tooltips system
  • Quick parameter reset
  • Export/import presets
  • Favorites system
  • Visual effect chain representation
  • Oversampling for better quality
  • Background processing with ForegroundService
  • Persistent notification with quick controls
  • Robust permission management
  • Automatic state recovery
  • Pipeline system with automatic recovery
  • Latency adjustment: Choose between lower latency or greater stability
  • MIDI Learn for external control
  • Automation system: Record and playback parameter changes

🚧 Partially Implemented

  • Metronome (UI + basic C++ integration)
  • Looper (UI + basic C++ integration)
  • Recorder (UI ready, basic functionality)

πŸ”„ In Development

  • Metronome improvements (animations, visualization)
  • Looper improvements (timer, duration visualization)
  • Complete recorder functionality

πŸ“‹ Upcoming Features

  • Complete automation persistence (save/load)
  • Automation editing interface
  • Automation synchronization with metronome
  • Customizable response curves
  • Interface improvements (animations, transitions)
  • Support for different sample rates
  • Integration with external DAWs

Contributing

This project is open source. Feel free to contribute!

Development Guidelines

  1. Code style: Follow Android and C++ best practices
  2. Testing: Test on multiple devices and Android versions
  3. Documentation: Update documentation for new features
  4. Performance: Consider audio latency and CPU usage
  5. Compatibility: Ensure backward compatibility

πŸ“š Related Documentation

For comprehensive information about the modern architecture:

ToneForge Wiki

πŸš€ Getting Started

πŸŽ›οΈ Effects & Features

🧠 Advanced Features πŸ†•

🎡 Learning & Practice

πŸ”§ Technical


Quick Links:

Clone this wiki locally