Skip to content

victor-grajski/hypnotic-gestures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

32 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽต Hypnotic Gestures

A gesture-controlled hypnotic techno music workstation built with React, TypeScript, Tailwind CSS, shadcn/ui, Google MediaPipe, and Tone.js.

๐ŸŒ https://hypnotic-gestures.vercel.app

๐ŸŽฅ Demo Video: v6 (current)

๐ŸŽฅ Demo Videos: v1-v5

๐ŸŒŸ Overview

Hypnotic Gestures is an prototype music application that lets you control a hypnotic techno beat using hand gestures detected through your webcam. It combines real-time computer vision (MediaPipe) with audio synthesis (Tone.js) to create a (hopefully) intuitive, hands-free music production experience.

For more on my process to get to this point, check out PROCESS.md!

Key Features

  • Real-time Gesture Recognition: Detects 7 different hand gestures using Google MediaPipe: "Closed_Fist", "Open_Palm", "Pointing_Up", "Thumb_Down", "Thumb_Up", "Victory", "ILoveYou"
  • 4-Track Editor: Toggle and control volume for Kick, Hi-Hat, Bass, and Lead instruments
  • ADSR Envelope Control: Shape the sound of each instrument with attack, decay, sustain, and release parameters
  • Visual Feedback: Live video feed with hand landmark tracking

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • A modern browser with webcam support (Chrome/Edge recommended)
  • Webcam permissions for the browser

Installation

# Clone the repository
git clone https://github.com/victor-grajski/hypnotic-gestures.git
cd hypnotic-gestures

# Install dependencies
npm install

# Start the development server
npm run dev

Visit http://localhost:5173 in your browser and grant webcam permissions when prompted.

๐Ÿ–๏ธ Gesture Controls

Hypnotic Gestures recognizes 7 different hand gestures.

Quick Reference

Gesture Layer 1 Layer 2
โœŠ Closed Fist Enter Panel -
๐Ÿ–๏ธ Open Palm - Adjust Values (Left = Decrease, Right = Increase)
โ˜๏ธ Pointing Up Previous/Next Panel (Left = Previous, Right = Next) Previous/Next Item (Left = Previous, Right = Next)
๐Ÿ‘ Thumbs Up Play Play
๐Ÿ‘Ž Thumbs Down Pause Pause
โœŒ๏ธ Victory - Return to Layer 1
๐ŸคŸ ILoveYou Toggle Webcam Guide (Layer 1) Toggle Item On/Off (Layer 2: Instruments Panel)

You can also press G to toggle the gesture guide overlay.

๐ŸŽน Interface Layout

The interface supports two layout modes that you can switch between:

Switching Layouts

Press C to show/hide the config panel, then use the Layout dropdown to switch between:

  • 1+3 Grid: Large webcam view with smaller panels below (default)
  • 2x2 Grid: Equal-sized panels in a 2ร—2 grid

1+3 Grid Layout

The 1+3 grid features a large webcam view on top with three panels below:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          Webcam View (Large)          โ”‚
โ”‚          + Landmarks                  โ”‚
โ”‚          + Gesture Info               โ”‚
โ”‚                                       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Control    โ”‚ Instruments โ”‚   ADSR    โ”‚
โ”‚  Panel      โ”‚   Panel     โ”‚  Envelope โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

2x2 Grid Layout

The 2x2 grid divides the interface into four equal quadrants:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Webcam View     โ”‚  Control Panel   โ”‚
โ”‚  + Landmarks     โ”‚  + Play/Pause    โ”‚
โ”‚  + Gesture Info  โ”‚  + Volume/Tempo  โ”‚
โ”‚                  โ”‚                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Instruments     โ”‚  ADSR Envelope   โ”‚
โ”‚  + Kick Drum     โ”‚  + Attack        โ”‚
โ”‚  + Hi-Hat        โ”‚  + Decay         โ”‚
โ”‚  + Bass Synth    โ”‚  + Sustain       โ”‚
โ”‚  + Lead Synth    โ”‚  + Release       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Control Panel

  • Play/Pause: Start or stop the track
  • Master Volume: Control overall output level
  • Tempo: Adjust BPM (80-180)

Instruments Panel

  • 4 Instruments: Kick, Hi-Hat, Bass, Lead
  • Each instrument has:
    • On/Off toggle
    • Volume control
    • Selection indicator

ADSR Panel

  • ADSR Envelope Editor: Control the sound envelope for each instrument
  • Edit envelope parameters for the selected instrument:
    • Attack: How quickly the sound reaches peak volume
    • Decay: How quickly it drops to sustain level
    • Sustain: The held volume level
    • Release: How quickly the sound fades after note release
  • Select an instrument first to edit its ADSR envelope

๐ŸŽฎ How to Use

  1. Grant Webcam Permissions: Allow the browser to access your camera
  2. Wait for Model Loading: The gesture recognition model will load (a few seconds)
  3. Position Your Hand: Keep your hand visible in the webcam frame
  4. Start Making Music:
    • Use thumbs up to start playback
    • Use pointing up left/right to navigate between panels (Control, Instruments, ADSR)
    • Make a closed fist to enter the selected panel
    • Use pointing up left/right again to navigate between items in the panel
    • Use ILoveYou gesture ๐ŸคŸ to toggle the selected item on/off
    • Use open palm left/right to adjust volume or ADSR parameters
    • Use victory โœŒ๏ธ gesture to return to Layer 1 (panel selection)

Tips for Best Results

  • Keep your hand at a comfortable distance from the camera
  • Ensure good lighting for better gesture detection
  • Hold gestures steady for ~0.5 seconds for reliable recognition
  • Use the guide overlay to see position zones
  • The interface also supports clicking behavior

๐Ÿ—๏ธ Technical Architecture

Tech Stack

  • Frontend Framework: React 18 + TypeScript + Vite
  • Gesture Recognition: Google MediaPipe Gesture Recognizer
  • Audio Engine: Tone.js
  • Component Library: shadcn/ui
  • Styling: Tailwind CSS with custom theme
  • State Management: React Context + useReducer

Project Structure

src/
โ”œโ”€โ”€ components/          # React UI components
โ”‚   โ”œโ”€โ”€ WebcamViewer.tsx
โ”‚   โ”œโ”€โ”€ ControlPanel.tsx
โ”‚   โ”œโ”€โ”€ InstrumentPanel.tsx
โ”‚   โ”œโ”€โ”€ ADSRPanel.tsx
โ”‚   โ”œโ”€โ”€ ConfigPanel.tsx
โ”‚   โ””โ”€โ”€ MinimumScreenSizeOverlay.tsx
โ”œโ”€โ”€ context/            # State management
โ”‚   โ””โ”€โ”€ AppContext.tsx
โ”œโ”€โ”€ engine/             # Core logic
โ”‚   โ”œโ”€โ”€ AudioEngine.ts  # Tone.js wrapper
โ”‚   โ””โ”€โ”€ GestureHandler.ts # Gesture-to-action mapping
โ”œโ”€โ”€ hooks/              # Custom React hooks
โ”‚   โ””โ”€โ”€ useGestureRecognition.ts
โ”œโ”€โ”€ types/              # TypeScript definitions
โ”‚   โ””โ”€โ”€ index.ts
โ”œโ”€โ”€ utils/              # Helper functions
โ”‚   โ””โ”€โ”€ gestureUtils.ts
โ”œโ”€โ”€ App.tsx            # Main application
โ””โ”€โ”€ main.tsx           # Entry point

Key Components

  • AudioEngine: Manages Tone.js instruments, effects, and transport
  • GestureHandler: Maps detected gestures to application actions with debouncing
  • useGestureRecognition: Custom hook for MediaPipe integration
  • AppContext: Centralized state management with automatic audio engine sync

๐Ÿ”ง Configuration

Gesture Debounce Timing (Adjustable via UI)

Press C to show the config panel, which exposes real-time debounce timing controls for each gesture:

  • ๐Ÿ‘† Pointing Up (navigate/cycle between panels/items)
  • โœŠ Closed Fist (enter panel)
  • โœ‹ Open Palm (adjust values)
  • ๐Ÿ‘Ž Thumb Down (pause)
  • ๐Ÿ‘ Thumb Up (play)
  • โœŒ๏ธ Victory (go back to Layer 1)
  • ๐ŸคŸ I Love You (toggle items)

Each gesture can be configured independently with debounce times from 100ms to 2000ms. This allows you to fine-tune responsiveness vs. accidental trigger prevention for your specific use case.

Note: Changes made in the config panel are not persisted between sessions. Once you find your preferred settings, edit the default values in src/context/AppContext.tsx to make them permanent.

Gesture Sensitivity (Code)

Edit src/hooks/useGestureRecognition.ts:

minHandDetectionConfidence: 0.5,  // Lower = more sensitive
minHandPresenceConfidence: 0.5,
minTrackingConfidence: 0.5,

Audio Patterns

Edit src/engine/AudioEngine.ts to customize instrument patterns, sounds, and effects.

๐Ÿ› Known Issues & Limitations

  • MVP Status: This is a minimum viable product with room for improvement
  • Gesture Stability: Requires steady hand movements for reliable detection
  • Browser Support: Best performance in Chrome (WebGL + MediaPipe). Safari and Firefox are also supported
  • Lighting Sensitivity: Poor lighting can affect gesture recognition

๐Ÿš€ Future Enhancements

  • Panel Carousel: Allow for more panels by making second row scrollable with gestures
  • Pattern Recording: Save and replay gesture settings
  • More Instruments: Expand the instrument library
  • Sequencer: Let musicians create custom sequences
  • Multi-Hand Support: Use both hands for more complex control
  • Pose and Face Support: Unlock further expression with multimodal input
  • VCV Rack Integration: Load and control plugins via gesture
  • Effects Support: Toggle and tweak effects like Filter and Chorus via gesture
  • Preset System: Save and load configurations
  • Mobile Support: Mobile-friendly layout + touch-based fallback for mobile devices
  • MIDI Output: Export patterns to DAWs

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

If you encounter issues:

  1. Check that your browser supports WebGL and MediaStream API
  2. Ensure webcam permissions are granted
  3. Try a different browser (Chrome recommended)
  4. Check the browser console for error messages

Built with โค๏ธ for the intersection of music and AI

About

An AI-powered, gesture-controlled hypnotic techno music workstation built with React, TypeScript, Tailwind CSS, shadcn/ui, Google MediaPipe, and Tone.js.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages