DirSim is a comprehensive project consisting of three main modules: DirSim Controller, DirSim Port, and DirSim Visual. This repository contains the implementation of these modules, designed to work together for an integrated experience.
The DirSim Controller module is a sophisticated system for tracking hand movements and gestures to control various aspects of audio production and performance. It utilizes computer vision techniques and machine learning models to interpret hand positions and movements, translating them into meaningful control signals.
Key Features:
-
Hand Tracking:
- Utilizes the cvzone library's HandTrackingModule for real-time hand detection and tracking.
- Capable of tracking multiple hands simultaneously.
- Extracts key points of the hand for precise gesture recognition.
-
BPM (Beats Per Minute) Calculation:
- Two modes of BPM calculation: a. Hand Speed Mode: Calculates BPM based on the speed of hand movements. b. Pattern Mode: Determines BPM by timing a specific sequence of hand positions.
- Adaptive BPM range with configurable minimum and maximum values.
-
OSC (Open Sound Control) Communication:
- Sends control messages using the python-osc library.
- Communicates BPM changes, play/stop commands, and other control signals to compatible audio software.
-
GUI (Graphical User Interface):
- Built with PyQt5 for a responsive and intuitive user experience.
- Real-time visualization of hand tracking and BPM.
- Configuration panels for adjusting BPM ranges, OSC settings, and other parameters.
- Live camera feed display with overlay of tracking information.
-
Dual Slider Control:
- Virtual sliders controlled by individual finger positions.
- Allows simultaneous control of two independent parameters (e.g., volume levels).
-
Mode Switching:
- Supports switching between Hand Speed Mode and Pattern Mode for BPM calculation.
- Each mode offers unique interaction methods for controlling the BPM.
-
Debug Mode:
- Provides additional visual feedback and logging for troubleshooting and development.
Components:
main.py: The core logic of the Controller, integrating all components and managing the main program loop.gui.py: Implements the graphical user interface for the Controller.hand_tracker.py: Handles hand detection and tracking logic.bpm_calculators.py: Contains classes for different BPM calculation methods.slider_controller.py: Manages the virtual slider controls.
The DirSim Controller is designed to be flexible and extensible, allowing for easy integration with various audio production setups (actually tested with Cockos Reaper) and potential expansion to control other parameters beyond BPM and volume.
The DirSim Port module serves as a bridge between MIDI input devices and OSC-compatible software, facilitating seamless communication in audio production environments.
Key Features:
-
MIDI Input Processing:
- Utilizes the
python-rtmidilibrary for real-time MIDI message handling. - Supports a wide range of MIDI input devices.
- Capable of processing various MIDI message types (e.g., Note On/Off, Control Change).
- Utilizes the
-
OSC (Open Sound Control) Output:
- Converts MIDI messages to OSC format using the
python-osclibrary. - Configurable OSC server address and port for flexible integration with various audio software.
- Converts MIDI messages to OSC format using the
-
GUI (Graphical User Interface):
- Built with PyQt6 for a modern and responsive user interface.
- Dropdown menu for easy selection of available MIDI input devices.
- Real-time display of incoming MIDI messages and outgoing OSC messages.
-
Dynamic Configuration:
- Allows users to change MIDI input and OSC output settings on the fly.
- Provides immediate feedback on configuration changes.
-
Error Handling and Logging:
- Robust error handling for MIDI device connections and OSC message transmission.
- Detailed logging of all activities for easy troubleshooting and monitoring.
Components:
dirsim_port.py: The main script containing the GUI implementation and core logic for MIDI to OSC conversion.
DirSim Visual is a Processing-based visualization module designed to provide a dynamic, real-time representation of an orchestra based on MIDI input. It serves as the visual component of the DirSim project, creating an engaging and intuitive display of musical activity.
Key Features:
-
Orchestra Layout Visualization:
- Displays a semicircular arrangement of instrument sections, mimicking a real orchestra setup.
- Each section is represented by a circular node, positioned according to typical orchestra seating.
-
Real-time MIDI Visualization:
- Responds to MIDI input in real-time, lighting up corresponding instrument sections.
- The intensity and size of each section's visual representation change based on MIDI velocity.
-
Color-coded Instrument Families:
- Uses distinct color schemes for different instrument families (strings, woodwinds, brass, percussion).
- Enhances visual differentiation between various orchestra sections.
-
Dynamic Background:
- Features a subtle, animated background that responds to overall musical activity.
-
Conductor Representation:
- Includes a visual element representing the conductor's position.
-
Debug Mode:
- Offers a toggleable debug mode for displaying technical information such as FPS, active sections, and last received MIDI message.
-
Customizable Layout:
- Allows for easy adjustment of the orchestra layout, colors, and sizes through code modifications.
Components:
particle10.pde: The main Processing sketch containing all the visualization logic.
-
Clone this repository:
git clone https://github.com/yourusername/DirSim.git -
Navigate to the project directory:
cd DirSim -
Install the required dependencies:
pip install -r requirements.txt
To run the DirSim Controller:
-
Navigate to the DirSim Controller directory:
cd DirSim_Controller -
Run the main application:
python gui.py
To run the DirSim Port:
- Navigate to the DirSim Port directory:
cd DirSim_Port - Run the main application:
python dirsim_port.py
To run DirSim Visual:
-
Ensure you have Processing installed on your system.
-
Open the
particle3.pdefile in the Processing IDE. -
Click the "Run" button or press Ctrl+R (Cmd+R on Mac) to start the visualization.
-
Ensure that MIDI messages are being sent to the correct port (default is 57120) for the visualization to respond.
The DirSim Controller can be configured through the GUI. Key configurable parameters include:
- Initial, minimum, and maximum BPM
- OSC server address and port
- Camera selection
- Debug mode
- Mode selection (Hand Speed or Pattern)
- Sensitivity settings for hand tracking
For DirSim Port, configuration is done through the GUI:
- Select the desired MIDI input device from the dropdown menu.
- Set the OSC server address and port in the provided fields.
- Click the "Apply" button to confirm OSC settings.
- Use the "Start" button to begin MIDI to OSC conversion.
For DirSim Visual, configuration is primarily done through code adjustments:
- Modify the
sectionFamiliesandfamilyColorsarrays to change the instrument layout and color scheme. - Adjust the
radiusand angle calculations in thesetup()function to alter the overall layout. - Change the
backgroundColorvalue to set a different background color. - Modify the
Sectionclass to alter the behavior and appearance of individual instrument representations.
- This project uses the cvzone library for hand tracking and face detection.
- OSC communication is handled using the python-osc library.
- GUI is built with PyQt5.
- MIDI input processing in DirSim Port is facilitated by the python-rtmidi library.
- DirSim Visual is implemented using Processing.