Structure for features#192
Structure for features#192JaclynCodes merged 87 commits intocopilot/resolve-feature-request-issue-againfrom
Conversation
Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
…audio-file Add documentation comments to `__all__` in audio.py
Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
## Implementation Plan - [x] Update dependencies in requirements.txt and tests/requirements.txt - [x] Add librosa, soundfile, and numpy to requirements.txt - [x] Update test dependencies - [x] Implement audio processing module (src/symphonic_joules/audio.py) - [x] Add load_audio function - [x] Add save_audio function - [x] Add normalize_peak function - [x] Add to_mono function - [x] Add frame_signal function - [x] Extend energy calculations module (src/symphonic_joules/energy.py) - [x] Add acoustic_intensity_proxy function - [x] Add frame_energy_density function - [x] Add energy_decomposition_proxy function - [x] Create test suite (tests/test_audio.py) - [x] Add tests for all audio functions - [x] Add markdown linting to CI/CD - [x] Create .markdownlint.json configuration - [x] Update .github/workflows/blank.yml with lint-markdown job - [x] Update tests/test_integration_suite.py to verify lint-markdown job - [x] Update tests/test_energy.py with tests for new acoustic energy functions - [x] Address code review feedback - [x] Fix error message consistency - [x] Make test assertions more flexible for version updates - [x] Run tests and verify all changes work correctly - [x] Address security issues - [x] Add explicit permissions to lint-markdown job (contents: read) **Security Summary**: No security vulnerabilities found. Added explicit permissions block to the lint-markdown job to follow the principle of least privilege. **Test Results**: All 52 tests specific to the new implementation pass successfully. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > Implement the core audio processing and energy calculation modules for the Symphonic-Joules framework, and strengthen the CI/CD pipeline with markdown linting. > > ### 1. Audio Core Implementation (`src/symphonic_joules/audio.py`) > Flesh out the existing placeholder with a robust API using `librosa` and `soundfile`: > - `load_audio(path, sr=None, mono=True)`: Returns waveform, sample rate, and a metadata dictionary (duration, n_samples, channels). > - `save_audio(path, y, sr)`: Saves the waveform to a file. > - `normalize_peak(y)`: Normalizes signal to peak amplitude 1.0. > - `to_mono(y)`: Converts multi-channel audio to mono. > - `frame_signal(y, frame_length, hop_length)`: Frames the signal for analysis. > > ### 2. Acoustic Energy Foundation (`src/symphonic_joules/energy.py`) > Create a new module for physics-informed energy computations: > - `acoustic_intensity_proxy(y)`: Computes a proxy for instantaneous intensity (square of pressure). > - `frame_energy_density(y, frame_length, hop_length)`: Computes average energy density per frame. > - `energy_decomposition_proxy(y, sr)`: Concepts for potential/kinetic energy proxies via frequency band splitting (Low vs High frequencies). > > ### 3. CI/CD & Documentation Strengthening > - **Update `.github/workflows/blank.yml`**: Add a `lint-markdown` job using `davidanson/markdownlint-cli2-action` to enforce `MD040` (fenced code blocks must have language tags). > - **Create `.markdownlint.json`**: Configure linting rules to enforce MD040 and specify allowed languages (python, sh, yaml, etc.). > - **Add Tests**: Create `tests/test_audio.py` with unit tests for the new audio functions. > - **Update Integration Tests**: Update `tests/test_integration_suite.py` to verify that the `lint-markdown` job is present in the workflow configuration. > > ### 4. Project Dependencies > - Ensure `librosa`, `soundfile`, and `numpy` are added to the development/test dependencies. </details> <!-- START COPILOT CODING AGENT SUFFIX --> *This pull request was created from Copilot chat.* > <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/JaclynCodes/Symphonic-Joules/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Implements core audio processing and energy calculation modules, and adds markdown linting to CI. Enables loading, framing, and energy analysis of audio while enforcing fenced code block language tags. - **New Features** - audio.py: load_audio, save_audio, normalize_peak, to_mono, frame_signal. - energy.py: acoustic_intensity_proxy, frame_energy_density, energy_decomposition_proxy. - **CI/CD** - Add lint-markdown job enforcing MD040; include .markdownlint.json with allowed languages. - Add explicit permissions (contents: read) to lint-markdown job. - Tests: unit tests for audio and energy; integration test verifies the lint job exists. - Dependencies: add librosa, soundfile, numpy. <sup>Written for commit 685ded9. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. -->
…ctions-again Set up Copilot instructions for repository
Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
…ction-names Improve loop variable readability in frame energy calculation
…uidance comment Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
…audio-py-again
Co-authored-by: JaclynCodes <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/symphonic_joules/audio.py">
<violation number="1" location="src/symphonic_joules/audio.py:91">
P2: save_audio now requires a different channel orientation than load_audio returns, so a common load→save flow will write with swapped dimensions or fail. Either accept channel‑first input from load_audio or convert it before writing.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
1 issue found across 2 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/symphonic_joules/audio.py">
<violation number="1" location="src/symphonic_joules/audio.py:91">
P2: save_audio no longer handles the channels-first arrays produced by load_audio, so saving multi-channel output from this module will write incorrect audio unless callers manually transpose. This is an API inconsistency/regression in the module.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| if y.ndim > 1 and y.shape[0] < y.shape[1]: # Heuristic to check if channels are first dimension | ||
| y = y.T # Transpose if channels are the first dimension | ||
| sf.write(path, y, sr) | ||
| except Exception as e: |
| # y = y.T # This should be handled by the caller to ensure correct orientation. | ||
| if y.ndim > 1 and y.shape[0] < y.shape[1]: # Heuristic to check if channels are first dimension | ||
| y = y.T # Transpose if channels are the first dimension | ||
| sf.write(path, y, sr) |
Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com> Signed-off-by: Misfit <218383634+JaclynCodes@users.noreply.github.com>
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/symphonic_joules/audio.py">
<violation number="1" location="src/symphonic_joules/audio.py:92">
P2: The auto-transpose heuristic assumes samples > channels. For short multi‑channel arrays where n_samples < n_channels, it will transpose valid (n_samples, n_channels) data and silently save corrupted audio. Consider requiring explicit orientation or validating shape instead of guessing.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| try: | ||
| # Transpose if multi-channel audio is in (n_channels, n_samples) format | ||
| # to match soundfile's expected (n_samples, n_channels) format | ||
| if y.ndim == 2 and y.shape[0] < y.shape[1]: |
There was a problem hiding this comment.
P2: The auto-transpose heuristic assumes samples > channels. For short multi‑channel arrays where n_samples < n_channels, it will transpose valid (n_samples, n_channels) data and silently save corrupted audio. Consider requiring explicit orientation or validating shape instead of guessing.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/symphonic_joules/audio.py, line 92:
<comment>The auto-transpose heuristic assumes samples > channels. For short multi‑channel arrays where n_samples < n_channels, it will transpose valid (n_samples, n_channels) data and silently save corrupted audio. Consider requiring explicit orientation or validating shape instead of guessing.</comment>
<file context>
@@ -86,9 +87,11 @@ def save_audio(path: str, y: np.ndarray, sr: int) -> None:
- # Caller must provide waveform in (n_samples, n_channels) orientation.
+ # Transpose if multi-channel audio is in (n_channels, n_samples) format
+ # to match soundfile's expected (n_samples, n_channels) format
+ if y.ndim == 2 and y.shape[0] < y.shape[1]:
+ y = y.T
+
</file context>
…tion Update API documentation for clarity and accuracy
Add emoji support for user messages
…les-infrastructure Update Symphonic Joules Infrastructure to v2
4fe134f
into
copilot/resolve-feature-request-issue-again
This pull request introduces significant improvements to project documentation, CI/CD workflows, and testing configuration, with a focus on scientific rigor, maintainability, and automation. The README is completely restructured to emphasize the scientific foundation, interface-first design, and a documentation-as-code testing philosophy. CI workflows are enhanced with caching, markdown linting, and more robust parsing. Testing infrastructure is strengthened with stricter pytest configuration and support for parallel execution.
Documentation and Scientific Foundation:
README.mdto clearly articulate the scientific motivation (acoustic energy density), interface-first API design, documentation-as-code testing approach, phased roadmap, and scientific references. The README now includes diagrams, example code, and detailed explanations of project phases and scientific background. [1] [2] [3] [4] [5].markdownlint.jsonconfiguration to enforce markdown style and code block language tags, improving documentation quality.CI/CD and Workflow Enhancements:
.github/workflows/blank.ymlto enable pip caching for Python dependencies, optimize test runs, and add a new markdown linting job usingmarkdownlint-cli2-action. [1] [2] [3]canarytomainin.github/workflows/static.ymlfor more standard release management.Testing Infrastructure:
pytest.iniwith strict marker/config enforcement, cache directory, and explicit test markers for better test organization and error detection.pytest-xdisttosetup.pyfor parallel test execution, improving CI speed.These changes collectively improve the project's scientific clarity, documentation quality, workflow automation, and testing reliability.
Summary by cubic
Implements core audio and energy modules with a clean public API, and upgrades CI/testing and documentation to lay a reliable, science-first foundation.
New Features
CI/CD and Testing
Written for commit d04f63b. Summary will update on new commits.