Skip to content

AI-Generated Archetype Battle Music Variations (3-Phase Adaptive System) #1387

Description

@pethers

🎯 Objective

Generate dynamic battle music variations for all 5 player archetypes using Suno AI, creating 3-phase adaptive music tracks (intro/combat/victory) that respond to combat intensity and archetype personality, totaling 15 unique music tracks.

📋 Background

Black Trigram features 5 distinct player archetypes, each with unique combat philosophies and cultural backgrounds. Currently, generic combat music plays regardless of archetype or match phase. Players need immersive, adaptive music that reflects their chosen archetype and combat situation (defensive, aggressive, victorious).

📊 Current State

  • Existing Music: 10 tracks (intro, combat, underground, 5 archetype themes)
  • Archetype Themes: Single static track per archetype (no combat progression)
  • Adaptive Music: None - same music plays regardless of combat state
  • Player Immersion: 71% of playtesters wanted music that "felt more connected" to their archetype
  • Generator Available: scripts/generate_music_suno.ts (4 styles: traditional, cyberpunk, ambient, combat)

Archetype Music Needs (5 × 3 = 15 Tracks):

  1. 무사 (Musa) - Traditional Warrior

    • Intro: Meditative 가야금 (gayageum), slow tempo
    • Combat: Driving 장구 (janggu) drums, heroic
    • Victory: Triumphant traditional fanfare
  2. 암살자 (Amsalja) - Shadow Assassin

    • Intro: Tense 해금 (haegeum), stealthy
    • Combat: Dark electronic beats, precise strikes
    • Victory: Quiet satisfaction, shadowy fade
  3. 해커 (Hacker) - Cyber Warrior

    • Intro: Glitchy synths, digital ambience
    • Combat: Intense techno with Korean instrument samples
    • Victory: Cyber celebration, neon triumph
  4. 정보요원 (Jeongbo Yowon) - Intelligence Operative

    • Intro: Analytical pads, strategic planning
    • Combat: Calculated rhythm, tactical precision
    • Victory: Mission accomplished theme
  5. 조직폭력배 (Jojik Pokryeokbae) - Organized Crime

    • Intro: Underground bass, street tension
    • Combat: Ruthless percussion, aggressive energy
    • Victory: Dominant power theme

✅ Acceptance Criteria

  • 15 unique music tracks generated (5 archetypes × 3 phases)
  • Each track 45-90 seconds, seamlessly loopable
  • Intro phase: Builds tension (30s)
  • Combat phase: High energy, matches combat intensity (60-90s loop)
  • Victory phase: Resolution and triumph (30-45s)
  • Korean traditional instruments integrated (가야금, 해금, 장구, 북)
  • Cyberpunk Korean aesthetic maintained
  • All tracks MP3 (primary) + WebM (fallback) format
  • Integrated into GameAudio.tsx and AudioManager.ts
  • Tested with all 5 archetypes in combat scenarios
  • Cross-fade transitions between phases (2-4s fade time)

🛠️ Implementation Guidance

Phase 1: AI Music Generation (Parallel Execution by Archetype)

Files to Use:

  • scripts/generate_music_suno.ts - Suno AI music generation
  • New: scripts/generate_archetype_battle_music.ts - Orchestration script
  • public/assets/audio/music/archetype_battle/ - Output directory

Suno AI Prompts (Korean Cultural Context):

// scripts/generate_archetype_battle_music.ts
const ARCHETYPE_BATTLE_MUSIC = {
  musa: {
    intro: {
      description: "Traditional Korean warrior meditation - 무사의 준비",
      style: "traditional",
      prompt: "Meditative Korean martial arts preparation music, solo gayageum (가야금) with gentle janggu (장구) rhythm, pentatonic scale, slow tempo 60 BPM, traditional Korean warrior spirit, philosophical depth, respectful and honorable atmosphere, ambient background, traditional instrumentation only",
      duration: 30,
      tags: "korean traditional, martial arts, meditation, musa warrior"
    },
    combat: {
      description: "Traditional warrior battle theme - 무사의 전투",
      style: "combat",
      prompt: "Epic Korean traditional battle music, powerful janggu (장구) war drums, heroic gayageum (가야금) melodies, buk (북) percussion, driving rhythm 140 BPM, honorable warrior combat, traditional Korean military music influences, intense but disciplined energy, pentatonic scales, traditional martial arts spirit",
      duration: 75,
      tags: "korean traditional, combat, epic, warrior drums"
    },
    victory: {
      description: "Traditional warrior victory - 무사의 승리",
      style: "traditional",
      prompt: "Triumphant Korean traditional victory fanfare, celebratory gayageum (가야금), proud janggu (장구) rhythm, traditional Korean military triumph music, honorable and respectful celebration, pentatonic victory theme, tempo 100 BPM, traditional instrumentation, warrior's honorable win",
      duration: 40,
      tags: "korean traditional, victory, celebration, triumphant"
    }
  },
  
  amsalja: {
    intro: {
      description: "Shadow assassin preparation - 암살자의 잠복",
      style: "ambient",
      prompt: "Dark Korean shadow assassin theme, tense haegeum (해금) violin tones, minimal percussion, ambient electronic pads with traditional Korean instruments, stealthy atmosphere, 80 BPM, suspenseful and precise, cyberpunk Korean fusion, shadow warrior preparation, traditional meets electronic darkness",
      duration: 30,
      tags: "korean fusion, shadow, stealth, tension"
    },
    combat: {
      description: "Shadow combat music - 암살자의 암습",
      style: "cyberpunk",
      prompt: "Intense Korean shadow assassin combat music, dark electronic beats fused with haegeum (해금), precise percussive strikes, cyberpunk Korean aesthetic, 150 BPM, stealthy aggressive energy, traditional Korean instruments processed electronically, shadow warrior strikes, deadly precision rhythm",
      duration: 80,
      tags: "korean cyberpunk, shadow combat, electronic fusion"
    },
    victory: {
      description: "Silent victory - 암살자의 승리",
      style: "ambient",
      prompt: "Quiet Korean shadow assassin victory theme, soft haegeum (해금) fade, minimal electronic ambience, satisfied but not boastful, 70 BPM, traditional Korean shadows meet cyberpunk, mission accomplished atmosphere, fade to darkness, respectful shadow warrior conclusion",
      duration: 35,
      tags: "korean ambient, shadow victory, subtle"
    }
  },
  
  // ... hacker, jeongbo, jojik (similar structure)
};

Generate all 15 tracks in parallel (5 workers):

# Parallel generation by archetype
npx tsx scripts/generate_archetype_battle_music.ts musa --all-phases --provider=suno &
npx tsx scripts/generate_archetype_battle_music.ts amsalja --all-phases --provider=suno &
npx tsx scripts/generate_archetype_battle_music.ts hacker --all-phases --provider=suno &
npx tsx scripts/generate_archetype_battle_music.ts jeongbo --all-phases --provider=suno &
npx tsx scripts/generate_archetype_battle_music.ts jojik --all-phases --provider=suno &
wait

# Post-process: Convert to MP3 + WebM, normalize volume
npx tsx scripts/convert_battle_music.ts --format=mp3,webm --normalize=-14LUFS

Phase 2: Adaptive Music System

Files to Modify:

  • src/components/game/GameAudio.tsx - Add phase-based music switching
  • src/audio/AudioManager.ts - Implement crossfade transitions
  • src/types/audio.ts - Add BattleMusicPhase enum
  • src/hooks/useBattleMusic.ts - New hook for phase management

Example Code Integration:

// src/hooks/useBattleMusic.ts
import { useState, useEffect } from 'react';
import { useAudio } from '../audio/AudioProvider';
import { PlayerArchetype } from '../types';

export enum BattleMusicPhase {
  INTRO = 'intro',
  COMBAT = 'combat',
  VICTORY = 'victory'
}

export function useBattleMusic(
  archetype: PlayerArchetype,
  phase: BattleMusicPhase
) {
  const audio = useAudio();
  
  useEffect(() => {
    const trackPath = `/assets/audio/music/archetype_battle/${archetype}_${phase}.mp3`;
    
    // Crossfade transition (3 seconds)
    audio.crossfadeMusic(trackPath, {
      fadeOutDuration: 3000,
      fadeInDuration: 3000,
      loop: phase === BattleMusicPhase.COMBAT
    });
  }, [archetype, phase, audio]);
}

Phase 3: Combat Integration

Files to Modify:

  • src/components/screens/combat/CombatScreen3D.tsx - Trigger phase changes
  • src/systems/CombatSystem.ts - Emit battle phase events
  • src/components/screens/endscreen/EndScreen3D.tsx - Play victory music

Example Usage:

// In CombatScreen3D.tsx
const [battlePhase, setBattlePhase] = useState(BattleMusicPhase.INTRO);

useEffect(() => {
  // Intro → Combat after countdown
  if (matchStarted && battlePhase === BattleMusicPhase.INTRO) {
    setTimeout(() => setBattlePhase(BattleMusicPhase.COMBAT), 5000);
  }
}, [matchStarted]);

// Combat → Victory when match ends
useEffect(() => {
  if (matchEnded && winner) {
    setBattlePhase(BattleMusicPhase.VICTORY);
  }
}, [matchEnded, winner]);

// Use adaptive music
useBattleMusic(selectedArchetype, battlePhase);

Phase 4: Performance Optimization

  • Preload intro/combat tracks before match starts
  • Lazy load victory music (triggered on match end)
  • Use Web Audio API for smooth crossfades
  • Profile memory usage, target <30MB for active tracks

🎮 Testing Scenarios

  1. Archetype Variation: Start matches with all 5 archetypes, verify unique music
  2. Phase Transitions: Verify smooth intro → combat → victory crossfades
  3. Loop Quality: Combat phase loops seamlessly for 5+ minutes
  4. Cultural Accuracy: Validate Korean traditional instrument usage with music consultant
  5. Performance: Verify smooth music playback during intense 60fps combat

🔗 Related Resources

  • Suno AI Music Generator: https://suno.com
  • Korean Traditional Instruments: 가야금 (gayageum), 해금 (haegeum), 장구 (janggu), 북 (buk)
  • Existing Generator: scripts/generate_music_suno.ts (4 styles available)
  • Archetype Personalities: src/systems/types.ts (PLAYER_ARCHETYPES_DATA)
  • Korean Music Theory: Pentatonic scales, 장단 (jangdan) rhythmic patterns

📊 Metadata

Priority: High | Effort: L (10-12h) | Domain: audio, music, ai-generation

Labels: type:feature, domain:audio, priority:high, size:large, ai-generated, adaptive-music, archetype-system

🔗 Parallel Execution

Can run in parallel with: Issues #1, #2, #4, #5, #6 (different asset types)
Dependencies: None (standalone music assets)
Blocks: None


흑괘의 길을 걸어라 - Walk the Path of the Black Trigram

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions