A professional-grade metronome application built with React, TypeScript, and Vite. Features precise timing, BPM ramping, and a modern, compact UI.
- Precise BPM Control: Adjustable from 40-280 BPM with multiple input methods
- Volume Control: Adjustable volume with visual feedback
- Accent Patterns: Configurable beats per measure (1-32)
- Subdivision Modes: No, 8th notes, triplets, 16th notes, and 16th triplets
- Feel Modes: Normal, double time (×2), and half time (1/2)
- Tap Tempo: Click the visual indicator to set BPM by tapping rhythmically
- Visual Feedback: Animated indicator shows beat timing
- Linear Ramp: Gradually increase/decrease BPM from start to target over a specified duration
- Alternating Ramp: Advanced pattern with positive and negative steps
- Configurable multiplier × positive step, followed by negative step
- Real-time sequence visualization with active step highlighting
- Shows cumulative BPM change from start for each step
- Net BPM gain per cycle calculation
- React 18 with TypeScript
- Vite for fast development and building
- Web Audio API for precise audio generation / no external samples used
- Vitest for testing
- Modern React Patterns:
useSyncExternalStorefor external state management
src/
├── components/ # React components
│ ├── BPMControl.tsx # BPM adjustment with slider and buttons
│ ├── MetronomePanel.tsx # Main metronome controls
│ ├── RampPanel.tsx # BPM ramping controls
│ ├── AlternatingRampControl.tsx # Alternating ramp configuration
│ ├── RampControl.tsx # Linear ramp configuration
│ ├── VisualIndicator.tsx # Beat visualization and tap tempo
│ └── ... # Other UI components
├── hooks/
│ └── useMetronome.ts # React hook for metronome state
├── utils/
│ ├── timing.ts # BPM/ms conversion and timing calculations
│ ├── validation.ts # Value clamping utilities
│ └── *.test.ts # Unit tests
├── audio.ts # Web Audio API wrapper
├── metronome.ts # Core metronome engine
├── styles.ts # Reusable spacing theme and styles
├── constants.ts # Application constants
└── types.ts # TypeScript type definitions
- Event-Driven Architecture: Metronome uses native
EventTargetAPI for decoupled communication - React Hooks: Custom
useMetronomehook withuseSyncExternalStorefor external state - Component Composition: Reusable, focused components
- Theme System: Centralized spacing, colors, and styling
- Precise Timing: Recursive
setTimeoutfor smooth BPM changes - Type Safety: Full TypeScript with strict mode
- Reusable Theme: Centralized spacing system (padding, margin, gap)
- Test Coverage: Unit tests for utilities and core logic
- Clean Architecture: Separation of concerns (UI, business logic, audio)
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Run tests
npm test
# Run tests with UI
npm run test:ui
# Run tests with coverage
npm run test:coverage- BPM: Adjust using slider, +/- buttons, or mouse wheel on BPM display
- Volume: Use volume slider (0-100%)
- Accent Pattern: Set beats per measure (1-32)
- Subdivisions: Select subdivision mode from radio buttons
- Feel: Choose normal, double, or half time
- Start/Stop: Click the play/pause button
- Set Start and Target BPM values
- Configure increment (BPM change per step) and duration (seconds)
- Click Start to begin ramping
- Set Start and Target BPM values
- Configure:
- Mult × +Step: Number of positive steps and their value
- -Step: Negative step value
- Meas: Measures per step
- The sequence shows the pattern with cumulative BPM changes
- Active step is highlighted during ramping
- Click Start to begin
Click the visual indicator repeatedly at your desired tempo. The metronome will calculate and set the BPM based on your taps.
The project includes comprehensive unit tests using Vitest:
- Timing utilities: BPM conversion, beat interval calculation, average interval
- Validation utilities: Value clamping with various ranges
- Test coverage: Core functionality is tested
Run tests with:
npm test- TypeScript: Strict type checking throughout
- React Best Practices: Hooks, composition, and modern patterns
- Reusable Components: DRY principles with shared components
- Theme System: Centralized spacing and styling
- Documentation: JSDoc comments for key functions
- Error Handling: Comprehensive error handling with event emission
Modern browsers with Web Audio API support:
- Chrome/Edge (latest)
- Firefox (latest)
- Safari (latest)
MIT
