Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Resonance: Tunin In

An AI-assisted DJ prototyping platform that listens to crowd energy, searches and enriches tracks with Spotify metadata, analyzes local audio files, and recommends smoother next-track transitions in a live browser dashboard.

Resonance: Tunin In is built as an end-to-end demo of a feedback loop for intelligent DJ support: crowd signal in, track intelligence out.

Overview

This project combines a Python backend with a browser-based frontend to simulate how an AI DJ assistant could react to a room in real time.

The system can:

  • monitor live microphone input from the browser
  • estimate crowd energy from incoming audio chunks
  • search Spotify tracks and enrich them with tempo, key, energy, and danceability
  • suggest a next track based on harmonic compatibility, BPM proximity, and crowd state
  • browse genre lanes automatically depending on whether the room feels low, building, or peak
  • analyze local audio files for BPM, beat activity, RMS, onset rate, and spectral motion
  • preview Spotify clips directly in the UI

The result is a practical experimental dashboard for testing crowd-reactive recommendation logic rather than a full production DJ engine.

Key Features

Live Crowd Energy Monitoring

The frontend can stream microphone audio to the backend over WebSockets. The backend analyzes incoming chunks and returns live energy metrics such as:

  • RMS
  • onset rate
  • spectral flux
  • inferred crowd state (low, building, or peak)

These values are visualized in real time in the browser.

Spotify Track Search and Enrichment

Search results are pulled from Spotify and enriched with musical metadata including:

  • BPM / tempo
  • musical key
  • mode
  • Camelot notation
  • energy
  • danceability
  • preview URL when available

This gives the recommendation engine enough structure to make safer transition choices.

AI Genre Browsing

Instead of only searching manually, the app can browse multiple genres based on the current crowd state.

Default lane behavior:

  • low: calmer or reset-friendly genres
  • building: genres with more lift and motion
  • peak: higher-pressure genres for peak-time energy

You can also supply your own custom genre mix and optionally enable auto re-browse when the crowd state changes.

Intelligent Next-Track Recommendation

The recommendation engine scores candidate tracks using a combination of:

  • harmonic compatibility
  • BPM proximity
  • energy matching
  • danceability
  • artist continuity or variety
  • preview availability

It then selects a strong follow-up candidate and explains why it was chosen.

Local Audio File Analysis

The app can analyze a local audio file path and estimate:

  • BPM
  • beat count
  • first beat offset
  • RMS
  • onset rate
  • spectral flux
  • duration

That analysis can be merged into the current track or added to the working library as a locally analyzed track.

Browser-Based Demo Dashboard

The frontend provides a compact control surface for:

  • connecting to the backend
  • starting and stopping microphone capture
  • simulating demo energy pulses
  • searching Spotify
  • browsing AI-selected genres
  • previewing tracks
  • selecting a current deck
  • promoting a recommended next track
  • scanning local audio files

Tech Stack

Backend

  • FastAPI
  • Uvicorn
  • WebSockets
  • Spotipy
  • python-dotenv
  • librosa
  • NumPy
  • SciPy

Frontend

  • HTML
  • CSS
  • Vanilla JavaScript
  • Web Audio API
  • native WebSocket API

How It Works

  1. The browser connects to the FastAPI backend over WebSocket.
  2. Microphone audio is captured in the frontend and sent as sample arrays.
  3. The backend computes crowd-energy metrics and classifies the room state.
  4. The frontend uses that state to drive AI genre browsing and recommendation behavior.
  5. Spotify search results are enriched with audio features.
  6. The track selector scores available tracks and recommends a follow-up.
  7. Local audio analysis can supplement or extend the track library.

Project Structure

DJ AI/
├── backend/
│   ├── api/
│   │   ├── server.py
│   │   └── spotify_client.py
│   ├── engine/
│   │   ├── beat_tracker.py
│   │   ├── energy_analyzer.py
│   │   ├── local_track_analyzer.py
│   │   └── track_selector.py
│   ├── main.py
│   ├── requirements.txt
│   └── .env.example
├── frontend/
│   ├── css/
│   ├── js/
│   └── index.html
└── .gitignore

Setup

1. Clone the repository

git clone https://github.com/manassanjaymishra24/Resonance-Tunin-In.git
cd Resonance-Tunin-In

2. Create and activate a virtual environment

On Windows:

cd backend
python -m venv .venv
.venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt

4. Configure environment variables

Create a backend/.env file based on backend/.env.example:

SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret

You can obtain these from the Spotify Developer Dashboard.

Running the Project

Start the backend

From the backend folder:

python main.py

The API will run on:

http://localhost:8000

Open the frontend

Open frontend/index.html in your browser.

Then:

  1. set the WebSocket URL to ws://localhost:8000/ws if needed
  2. click Connect
  3. start the mic or simulate energy
  4. search Spotify tracks or use AI Browse
  5. set a current track and request a recommendation

API Endpoints

Health Check

GET /health

Returns a simple backend status response.

Local Audio Analysis

POST /analyze/local

Example request body:

{
  "audio_path": "C:\\Users\\Lenovo\\Music\\track.mp3"
}

WebSocket

/ws

Supported message types include:

  • audio_chunk
  • search
  • select_next
  • ai_browse

Recommendation Logic

The track selector is designed to prefer transitions that feel musically safer and context-aware.

It uses:

  • Camelot compatibility when key information is available
  • BPM distance thresholds
  • crowd-state energy targets
  • danceability weighting
  • slight random variation to avoid identical choices every time

If strong harmonic matches are unavailable, the selector gracefully falls back to broader tempo-safe candidates.

Environment Notes

This project is a prototype and assumes:

  • valid Spotify API credentials
  • a browser with microphone permissions
  • local file paths that the backend machine can access
  • Python audio-analysis dependencies installed successfully

Some audio libraries can be platform-sensitive depending on your Python setup.

Current Scope

Resonance: Tunin In is currently a demo/research project focused on recommendation and interaction flow. It is not yet a production-ready DJ performance system.

It does not currently include:

  • full deck syncing
  • live beatmatched playback between tracks
  • waveform editing
  • playlist persistence
  • authentication
  • deployment configuration
  • production hardening

Why This Project Matters

This project explores a compelling intersection of:

  • music intelligence
  • crowd-reactive systems
  • real-time browser interaction
  • recommendation logic
  • AI-assisted DJ tooling

It demonstrates how lightweight live signals and track metadata can be combined into a more adaptive DJ-assist experience.

Future Improvements

Potential next steps include:

  • richer crowd-state modeling
  • persistent playlists and session history
  • improved transition scoring
  • waveform and beat-grid visualization
  • direct Spotify playback integration
  • deployment with a hosted frontend and backend
  • stronger error handling and test coverage

Author

Built by Manas Mishra

About

AI-powered DJ mixing app that analyzes track energy and beat patterns, streams recommendations from a Python backend, and drives a live browser-based frontend for interactive music playback and visualization.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages