Skip to content

Conversation

@ftrain
Copy link
Owner

@ftrain ftrain commented Nov 6, 2025

Changes:

  • CMake: Use pkg-config to find RtMidi when available
  • CMake: Auto-detect Homebrew prefix with 'brew --prefix'
  • CMake: Search in more locations (Homebrew, MacPorts, system)
  • CMake: Better error messages with diagnostic commands
  • build.sh: Improved RtMidi detection logic
  • Added check_deps.sh: Comprehensive dependency diagnostic tool

The CMake configuration now:

  1. Tries pkg-config first (cleanest method)
  2. Detects Homebrew installation path automatically
  3. Searches in multiple common locations
  4. Provides clear error messages with troubleshooting steps

Run './check_deps.sh' to diagnose dependency issues.

Changes:
- CMake: Use pkg-config to find RtMidi when available
- CMake: Auto-detect Homebrew prefix with 'brew --prefix'
- CMake: Search in more locations (Homebrew, MacPorts, system)
- CMake: Better error messages with diagnostic commands
- build.sh: Improved RtMidi detection logic
- Added check_deps.sh: Comprehensive dependency diagnostic tool

The CMake configuration now:
1. Tries pkg-config first (cleanest method)
2. Detects Homebrew installation path automatically
3. Searches in multiple common locations
4. Provides clear error messages with troubleshooting steps

Run './check_deps.sh' to diagnose dependency issues.
@ftrain ftrain merged commit b452549 into main Nov 6, 2025
ftrain pushed a commit that referenced this pull request Nov 9, 2025
This commit implements three major improvements from the code review:

## 1. Complete HardwareBase Migration (4 platforms)
- Migrated TeensyHardware to inherit from HardwareBase
- Removed ~60 lines of duplicate code from Teensy implementation
- All platforms (Desktop, macOS, iOS, Teensy) now use common base
- Total duplication eliminated: ~260 lines across 4 platforms

### Platform-specific changes:
- **TeensyHardware**: Now uses inherited buttons_/pots_ arrays from base
  - update() writes hardware readings to base class state
  - Overrides setLED() for PWM brightness control
  - Overrides getMillis() with Arduino millis()

## 2. Enhanced Lua Integration Tests (+7 tests)
- Added comprehensive ModeLoader test coverage
- Tests: mode_loader_creation, load_single_mode, reject_invalid_mode_number,
  reject_invalid_script, multiple_modes, channel_assignment, replace_mode
- Total test count: 24 tests (17 original + 7 new)
- Complete coverage of LuaContext, ModeLoader, and Lua API

## 3. Centralized Configuration (config.h)
- Created src/core/config.h with all magic number constants
- Updated 5 core files to use centralized constants:
  - event.h/pattern.h/song.h: Data structure sizes
  - engine.h/engine.cpp: Timing, tempo, LED patterns, pot mappings

### Constants centralized:
- Timing: AUTOSAVE_INTERVAL_MS, LED_TEMPO_DURATION_MS, TEMPO_DEBOUNCE_MS
- Musical: TEMPO_MIN/MAX/DEFAULT_BPM, MIDI_PPQN, STEPS_PER_BAR
- Hardware: NUM_BUTTONS, NUM_ROTARY_POTS, NUM_SLIDER_POTS, MIDI_MAX_VALUE
- Data: EVENTS_PER_TRACK, TRACKS_PER_PATTERN, PATTERNS_PER_MODE, NUM_MODES
- LED patterns: Fast blink timing constants
- Bit-packing: Event structure shifts and masks

### Benefits:
- Easier tuning and experimentation
- Self-documenting code with clear constant names
- Single source of truth for all configuration
- Improved maintainability

## Impact Summary:
- **Code reduction**: ~260 lines of duplication eliminated
- **Test coverage**: +7 comprehensive ModeLoader tests
- **Maintainability**: All magic numbers centralized in config.h
- **No functional changes**: All changes preserve existing behavior

Addresses items #1, #2, and #3 from docs/IMMEDIATE_ACTIONS.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants