#!/bin/bash

# 创建占位音频文件用于测试
# 这些是无声的音频文件，确保系统可以正常加载

echo "🎵 创建占位音频文件..."

TARGET_DIR="app/src/main/res/raw"
mkdir -p "$TARGET_DIR"

# 创建无声音频文件函数 (使用ffmpeg)
create_silent_audio() {
    local filename=$1
    local duration=$2
    local description=$3
    
    echo "📄 创建: $filename ($description) - ${duration}秒"
    
    # 检查是否有ffmpeg
    if command -v ffmpeg &> /dev/null; then
        ffmpeg -f lavfi -i anullsrc=r=44100:cl=mono -t $duration -q:a 9 -acodec mp3 "$TARGET_DIR/$filename" -y 2>/dev/null
        if [ $? -eq 0 ]; then
            echo "✅ 已创建: $filename"
        else
            echo "❌ 创建失败: $filename"
        fi
    else
        # 如果没有ffmpeg，创建一个空文件作为占位符
        touch "$TARGET_DIR/$filename"
        echo "⚠️  创建空文件: $filename (需要替换为真实音频)"
    fi
}

echo ""
echo "🎼 创建背景音乐占位符..."
create_silent_audio "ambient_mystery.mp3" 120 "神秘氛围音乐"
create_silent_audio "electronic_tension.mp3" 90 "电子紧张音乐"
create_silent_audio "orchestral_revelation.mp3" 150 "管弦乐启示"
create_silent_audio "epic_finale.mp3" 180 "史诗终章"

echo ""
echo "🌟 创建环境音效占位符..."
create_silent_audio "ventilation_soft.mp3" 30 "通风系统音效"
create_silent_audio "heart_monitor.mp3" 15 "心率监控音效"
create_silent_audio "reactor_hum.mp3" 45 "反应堆嗡鸣"
create_silent_audio "space_silence.mp3" 60 "太空寂静"

echo ""
echo "⛈️ 创建天气音效占位符..."
create_silent_audio "wind_gentle.mp3" 30 "微风音效"
create_silent_audio "rain_light.mp3" 45 "小雨音效"
create_silent_audio "storm_cyber.mp3" 30 "电子风暴"
create_silent_audio "solar_storm.mp3" 30 "太阳风暴"

echo ""
echo "🔘 创建UI音效占位符..."
create_silent_audio "button_click.mp3" 0.5 "按钮点击音效"
create_silent_audio "notification_beep.mp3" 1 "通知提示音效"
create_silent_audio "error_alert.mp3" 2 "错误警报音效"

echo ""
echo "🎭 创建事件音效占位符..."
create_silent_audio "discovery_chime.mp3" 2 "发现音效"
create_silent_audio "time_distortion.mp3" 3 "时间扭曲音效"
create_silent_audio "oxygen_leak_alert.mp3" 3 "氧气泄漏警报"

echo ""
echo "✅ 占位音频文件创建完成！"
echo ""
echo "📂 文件位置: $TARGET_DIR"
echo "📋 已创建 18 个占位音频文件"
echo ""
echo "🚀 现在你可以："
echo "   1. 编译并测试音频系统: ./gradlew assembleDebug"
echo "   2. 稍后使用真实音频文件替换这些占位符"
echo "   3. 使用 ./audio_rename.sh 自动替换下载的音频"
echo ""
echo "💡 提示: 占位符是无声的，用于测试系统功能。"
echo "    下载真实音频后，音频体验会更好！"
