Skip to content

kajukitli/code-dj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Code DJ 🎵

Ambient music generator that sonifies git repository activity. Turn your commit history into music.

How it works

Code DJ analyzes recent git activity and maps it to musical elements:

Git → Music Mapping

Git Metric Musical Element
Commit count Tempo (more commits = faster notes)
Insertion/deletion ratio Pitch (more insertions = higher octave)
File types Instrument timbre (see below)
Merge conflicts Minor key + dissonant detuned notes
No conflicts Major key, happy progression

File Type → Waveform

Different file extensions produce different synthesizer waveforms:

Extension Waveform Sound Character
.ts, .js Sine Smooth, clean synth
.rs, .go Square Punchy, 8-bit bass
.md, .txt Triangle Soft, mellow pad
Other Sawtooth Bright, edgy lead

Music Theory

The generator creates a 4-bar loop with a 4-chord progression per bar:

  • No conflicts (major): I - IV - V - I (happy, resolved)
  • Conflicts (minor): i - v - iv - v (tense, unresolved)

Each chord is built from the scale:

  • Major: C D E F G A B (intervals: 0 2 4 5 7 9 11)
  • Minor: C D Eb F G Ab Bb (intervals: 0 2 3 5 7 8 10)

Bass notes hit on beats 1 and 3. Arpeggio accents are added based on commit count.

Audio Generation

All audio is synthesized from scratch - no samples or external dependencies.

Signal Chain

  1. Oscillator: Generates raw waveforms (sine/square/sawtooth/triangle)
  2. Envelope: ADSR-like amplitude shaping (10% attack, 30% release)
  3. Mixer: Sums multiple oscillators for chords
  4. Normalizer: Prevents clipping

WAV Output

Outputs standard PCM WAV:

  • Sample rate: 44100 Hz
  • Bit depth: 16-bit signed
  • Channels: Mono

Usage

deno run -A main.ts <repo-path> [since]

Examples

# Last hour of current directory
deno run -A main.ts .

# Last 24 hours of a specific repo
deno run -A main.ts /path/to/repo "24 hours ago"

# Last week
deno run -A main.ts . "1 week ago"

Output

🎵 Code DJ - Generating music from git activity
   Repo: /path/to/repo
   Since: 24 hours ago

📊 Git Stats:
   Commits: 9
   Insertions: 4778
   Deletions: 4632
   Files changed: 39
   Authors: alice, bob, charlie
   Conflicts: ✅ No

🎹 Generating music...
✅ Saved to /tmp/code-dj/output.wav

Architecture

┌─────────────┐     ┌──────────────┐     ┌─────────────┐
│  git log    │────▶│  GitStats    │────▶│  generateMusic()
│  git status │     │  - commits   │     │  - pick scale
└─────────────┘     │  - ins/del   │     │  - build chords
                    │  - files     │     │  - mix waveforms
                    │  - conflicts │     └───────┬─────┘
                    └──────────────┘             │
                                                 ▼
                    ┌──────────────┐     ┌─────────────┐
                    │  output.wav  │◀────│  toWav()    │
                    └──────────────┘     └─────────────┘

Why?

Because code has rhythm. A repo with steady commits has a pulse. Merge conflicts are dissonant. A big refactor sounds different than small bug fixes.

Also it's fun.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors