Implement musical time conversion functionality#25
Conversation
- Define getMusicalTime() interface for converting real time to musical time - Support arbitrary hierarchical depth with clear level naming - Add optional referenceLevel parameter for fractional calculation at any hierarchy level - Use pulse-based fractional calculation to handle rubato and irregular timing - Include comprehensive test cases and edge case handling - Designed for identical implementation across Python and TypeScript
- Add MusicalTime dataclass with cycle, hierarchical position, and fractional beat - Add Meter.get_musical_time() method with optional reference level support - Support arbitrary hierarchical depth (beat, subdivision, sub-subdivision, etc.) - Use pulse-based fractional calculation to handle rubato and irregular timing - Add comprehensive test suite with 18 test cases covering all functionality - Update package exports for MusicalTime class - Implement specification from docs/musical-time-spec.md Features: - Convert real time to musical position within meter boundaries - Reference levels allow fractional calculation at any hierarchy level - Handles complex meters like [3, 2, 4] with proper level naming - Returns False for out-of-bounds times, MusicalTime for valid times - String representations: compact (C0:2.1+0.500) and readable formats
|
📦 Test Package Built Successfully! This PR has been automatically built and uploaded to TestPyPI for testing. 🔗 TestPyPI Link: https://test.pypi.org/project/idtap/ To test this version: pip install --index-url https://test.pypi.org/simple/ idtap✅ All tests passed and package builds successfully. |
|
@claude review |
|
Claude finished @jon-myers's task —— View job Code Review Complete ✅Review Checklist
Overall Assessment: Excellent Implementation 🎯This is a high-quality implementation that closely follows the comprehensive specification. The code demonstrates excellent software engineering practices with robust validation, comprehensive testing, and clear documentation. Code Quality & Best Practices ✅Strengths
MusicalTime Dataclass (
|
|
Claude finished @jon-myers's task —— View job Code Review: Musical Time Conversion ImplementationReview Checklist
SummaryThis is an excellent implementation that demonstrates high code quality, comprehensive testing, and thoughtful design. The musical time conversion functionality is well-architected and follows the specification precisely. ✅ Strengths1. Architecture & Design
2. Algorithm Implementation
3. Code Quality
4. Test Coverage
🔍 Technical AnalysisMusicalTime Class (
|
- Removed claude.yml which was triggering alongside claude-code-review.yml - Now only claude-code-review.yml handles @claude review comments - This prevents duplicate comments on PR reviews
|
📦 Test Package Built Successfully! This PR has been automatically built and uploaded to TestPyPI for testing. 🔗 TestPyPI Link: https://test.pypi.org/project/idtap/ To test this version: pip install --index-url https://test.pypi.org/simple/ idtap✅ All tests passed and package builds successfully. |
- Fixed _calculate_level_start_time to properly handle truncated positions array - Now correctly extends with zeros rather than potentially accessing out of bounds indices - All tests still pass
|
📦 Test Package Built Successfully! This PR has been automatically built and uploaded to TestPyPI for testing. 🔗 TestPyPI Link: https://test.pypi.org/project/idtap/ To test this version: pip install --index-url https://test.pypi.org/simple/ idtap✅ All tests passed and package builds successfully. |
- Added test for multi-level hierarchy overflow scenarios - Added test for truncated positions array handling with reference levels - Added test for recursive overflow at reference level boundaries - Added test for complex list-based hierarchy overflow - These tests specifically cover the edge cases Copilot's review identified - All 22 tests pass, increasing confidence in robustness
|
📦 Test Package Built Successfully! This PR has been automatically built and uploaded to TestPyPI for testing. 🔗 TestPyPI Link: https://test.pypi.org/project/idtap/ To test this version: pip install --index-url https://test.pypi.org/simple/ idtap✅ All tests passed and package builds successfully. |
There was a problem hiding this comment.
Pull Request Overview
This PR implements comprehensive musical time conversion functionality, enabling conversion of real time to hierarchical musical positions within meter structures. The implementation adds a new MusicalTime dataclass and enhances the Meter class with get_musical_time() method, supporting arbitrary hierarchy depths, reference levels for fractional calculations, and proper handling of rubato timing.
- New
MusicalTimedataclass with cycle number, hierarchical position, and fractional beat representation - Enhanced
Meterclass with musical time conversion algorithm supporting pulse-based timing - Comprehensive test suite with 18 test cases covering edge cases, rubato handling, and reference level validation
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
idtap/classes/musical_time.py |
New MusicalTime dataclass with validation, string representations, and hierarchy property accessors |
idtap/classes/meter.py |
Enhanced Meter class with get_musical_time method and helper functions for hierarchical calculations |
idtap/__init__.py |
Added MusicalTime to package exports |
idtap/tests/musical_time_test.py |
Comprehensive test suite covering all functionality, edge cases, and spec compliance |
docs/musical-time-spec.md |
Complete specification document for the musical time conversion feature |
docs/musical-time-implementation-plan.md |
Detailed implementation plan and development strategy |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Summary
Implements comprehensive musical time conversion functionality per the specification in
docs/musical-time-spec.md.Key Features
Meter.get_musical_time(real_time, reference_level?)- Convert real time to musical positionMusicalTimedataclass - Represents hierarchical musical time with cycle, position, and fractional beat[4, 4],[3, 2, 4],[2, 2, 2, 2], etc.Falsefor out-of-bounds timesImplementation Details
offset_pulse()modificationsUnion[MusicalTime, Literal[False]]return typeExample Usage
Test Coverage
Files Changed
idtap/classes/musical_time.py- New MusicalTime dataclassidtap/classes/meter.py- Enhanced with get_musical_time methodidtap/tests/musical_time_test.py- Comprehensive test suiteidtap/__init__.py- Updated package exportsdocs/musical-time-spec.md- Complete specificationdocs/musical-time-implementation-plan.md- Implementation plan🤖 Generated with Claude Code