Skip to content

Commit 74f014a

Browse files
committed
src
1 parent 7fbd6dc commit 74f014a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+4426
-0
lines changed

CMakeLists.txt

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(labsoundpy)
3+
4+
# Set C++ standard
5+
set(CMAKE_CXX_STANDARD 17)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
# Find Python
9+
find_package(Python 3.7 REQUIRED COMPONENTS Interpreter Development)
10+
11+
# Option to use git submodules or fetch dependencies
12+
option(USE_SUBMODULES "Use git submodules for dependencies" ON)
13+
14+
# Handle nanobind dependency
15+
if(USE_SUBMODULES)
16+
# Check if nanobind submodule exists
17+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/nanobind/CMakeLists.txt")
18+
message(FATAL_ERROR "Nanobind submodule not found. Please run: git submodule update --init --recursive")
19+
endif()
20+
else()
21+
# Fetch nanobind if not present
22+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/nanobind/CMakeLists.txt")
23+
message(STATUS "Downloading nanobind...")
24+
execute_process(
25+
COMMAND git clone --depth 1 https://github.com/wjakob/nanobind.git third_party/nanobind
26+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
27+
)
28+
endif()
29+
endif()
30+
31+
# Add nanobind
32+
add_subdirectory(third_party/nanobind)
33+
34+
# Handle LabSound dependency
35+
if(USE_SUBMODULES)
36+
# Check if LabSound submodule exists
37+
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/LabSound/CMakeLists.txt")
38+
message(FATAL_ERROR "LabSound submodule not found. Please run: git submodule update --init --recursive")
39+
endif()
40+
41+
# Build LabSound
42+
set(LABSOUND_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/LabSound")
43+
set(LABSOUND_BUILD_EXAMPLES OFF CACHE BOOL "Build LabSound examples")
44+
set(LABSOUND_BUILD_TESTS OFF CACHE BOOL "Build LabSound tests")
45+
add_subdirectory(${LABSOUND_DIR})
46+
47+
# Use modern CMake target-based approach
48+
set(LABSOUND_INCLUDES
49+
${LABSOUND_DIR}/include
50+
${LABSOUND_DIR}/src
51+
)
52+
else()
53+
# Try to find installed LabSound
54+
find_package(LabSound QUIET)
55+
56+
if(LabSound_FOUND)
57+
message(STATUS "Found installed LabSound")
58+
else()
59+
# If not found, use a specific location or fetch it
60+
if(NOT DEFINED LABSOUND_DIR)
61+
message(STATUS "LabSound not found. Downloading...")
62+
execute_process(
63+
COMMAND git clone --depth 1 https://github.com/LabSound/LabSound.git third_party/LabSound
64+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
65+
)
66+
set(LABSOUND_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/LabSound")
67+
set(LABSOUND_BUILD_EXAMPLES OFF CACHE BOOL "Build LabSound examples")
68+
set(LABSOUND_BUILD_TESTS OFF CACHE BOOL "Build LabSound tests")
69+
add_subdirectory(${LABSOUND_DIR})
70+
else()
71+
message(STATUS "Using LabSound from: ${LABSOUND_DIR}")
72+
endif()
73+
74+
set(LABSOUND_INCLUDES
75+
${LABSOUND_DIR}/include
76+
${LABSOUND_DIR}/src
77+
)
78+
endif()
79+
endif()
80+
81+
# Include LabSound headers
82+
include_directories(${LABSOUND_INCLUDES})
83+
84+
# Define the extension module
85+
nanobind_add_module(
86+
_core # Module name
87+
src/core.cpp # Main binding file
88+
src/audio_context.cpp # AudioContext bindings
89+
src/audio_node.cpp # AudioNode base class bindings
90+
src/audio_param.cpp # AudioParam bindings
91+
src/nodes/oscillator_node.cpp # OscillatorNode bindings
92+
src/nodes/gain_node.cpp # GainNode bindings
93+
src/nodes/biquad_filter_node.cpp # BiquadFilterNode bindings
94+
src/nodes/buffer_source_node.cpp # BufferSourceNode bindings
95+
src/nodes/analyzer_node.cpp # AnalyzerNode bindings
96+
src/nodes/function_node.cpp # FunctionNode bindings
97+
src/nodes/destination_node.cpp # DestinationNode bindings
98+
src/nodes/channel_merger_node.cpp # ChannelMergerNode bindings
99+
src/nodes/channel_splitter_node.cpp # ChannelSplitterNode bindings
100+
src/nodes/constant_source_node.cpp # ConstantSourceNode bindings
101+
src/nodes/convolver_node.cpp # ConvolverNode bindings
102+
src/nodes/delay_node.cpp # DelayNode bindings
103+
src/nodes/dynamics_compressor_node.cpp # DynamicsCompressorNode bindings
104+
src/nodes/panner_node.cpp # PannerNode bindings
105+
src/nodes/stereo_panner_node.cpp # StereoPannerNode bindings
106+
src/nodes/wave_shaper_node.cpp # WaveShaperNode bindings
107+
)
108+
109+
target_include_directories(_core PRIVATE
110+
${LABSOUND_INCLUDES}
111+
${Python_INCLUDE_DIRS}
112+
src
113+
)
114+
115+
# Link against LabSound
116+
if(LabSound_FOUND)
117+
# Use modern CMake target
118+
target_link_libraries(_core PRIVATE LabSound::LabSound)
119+
else()
120+
# Link against LabSound libraries directly
121+
if(APPLE)
122+
target_link_libraries(_core PRIVATE
123+
${LABSOUND_DIR}/build/bin/LabSound.framework/Versions/A/LabSound
124+
${LABSOUND_DIR}/build/bin/libLabSoundMiniAudio.a
125+
${LABSOUND_DIR}/build/bin/libLabSoundRtAudio.a
126+
${LABSOUND_DIR}/build/third_party/libnyquist/lib/liblibnyquist.a
127+
)
128+
else()
129+
# For Linux and Windows, adjust paths as needed
130+
target_link_libraries(_core PRIVATE LabSound)
131+
endif()
132+
endif()
133+
134+
# Install the extension module
135+
install(TARGETS _core DESTINATION labsound)

CONTRIBUTING.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Contributing to LabSoundPy
2+
3+
Thank you for your interest in contributing to LabSoundPy! This document provides guidelines and instructions for contributing to the project.
4+
5+
## Code of Conduct
6+
7+
Please be respectful and considerate of others when contributing to this project. We aim to foster an inclusive and welcoming community.
8+
9+
## Getting Started
10+
11+
1. Fork the repository on GitHub
12+
2. Clone your fork locally
13+
3. Set up the development environment
14+
4. Create a new branch for your changes
15+
5. Make your changes
16+
6. Run tests to ensure your changes don't break existing functionality
17+
7. Submit a pull request
18+
19+
## Development Environment Setup
20+
21+
```bash
22+
# Clone the repository
23+
git clone https://github.com/LabSound/LabSound.git
24+
cd LabSound/labsoundpy
25+
26+
# Install in development mode
27+
pip install -e .
28+
```
29+
30+
## Coding Standards
31+
32+
### Python Code
33+
34+
- Follow [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guidelines
35+
- Use Google-style docstrings
36+
- Use type hints where appropriate
37+
- Write unit tests for new functionality
38+
39+
### C++ Code
40+
41+
- Follow the existing code style in the LabSound project
42+
- Use C++17 features where appropriate
43+
- Document all public APIs
44+
- Write unit tests for new functionality
45+
46+
## Testing
47+
48+
Before submitting a pull request, make sure all tests pass:
49+
50+
```bash
51+
# Run Python tests
52+
python -m unittest discover -s tests
53+
54+
# Build and run C++ tests
55+
cd build
56+
cmake --build . --target test
57+
```
58+
59+
## Pull Request Process
60+
61+
1. Update the README.md or documentation with details of changes if appropriate
62+
2. Update the examples if you've added or changed functionality
63+
3. Make sure all tests pass
64+
4. The pull request will be reviewed by maintainers
65+
5. Address any feedback from the review
66+
6. Once approved, your changes will be merged
67+
68+
## Adding New Features
69+
70+
When adding new features, please follow these guidelines:
71+
72+
1. Discuss major changes in an issue before implementing
73+
2. Ensure the feature is well-documented
74+
3. Add appropriate tests
75+
4. Add examples demonstrating the feature
76+
5. Update the API documentation
77+
78+
## Reporting Bugs
79+
80+
When reporting bugs, please include:
81+
82+
1. A clear description of the bug
83+
2. Steps to reproduce the bug
84+
3. Expected behavior
85+
4. Actual behavior
86+
5. Environment information (OS, Python version, etc.)
87+
88+
## Feature Requests
89+
90+
Feature requests are welcome! Please include:
91+
92+
1. A clear description of the feature
93+
2. Use cases for the feature
94+
3. Any relevant examples or references
95+
96+
## License
97+
98+
By contributing to LabSoundPy, you agree that your contributions will be licensed under the same license as the project.

MANIFEST.in

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Include all C++ source files and headers
2+
recursive-include src *.cpp *.h *.hpp
3+
recursive-include third_party/nanobind *
4+
recursive-include third_party/LabSound *
5+
6+
# Include CMake files
7+
include CMakeLists.txt
8+
recursive-include cmake *.cmake
9+
10+
# Include documentation and examples
11+
recursive-include docs *
12+
recursive-include examples *.py
13+
14+
# Include tests
15+
recursive-include tests *.py
16+
17+
# Include license and readme
18+
include LICENSE
19+
include README.md
20+
include pyproject.toml
21+
include .gitmodules

0 commit comments

Comments
 (0)