random() * 15;
bar.style.height = `${height}px`;
bar.style.background = `linear-gradient(to top, hsl(${(index * 10) % 360}, 70%, 60%), transparent)`;
});
}

// 其他辅助方法
switchTab(tabName) {
document.querySelectorAll('.tab').forEach(tab => {
tab.classList.remove('active');
});
document.querySelectorAll('.editor').forEach(editor => {
editor.style.display = 'none';
});

document.querySelector(`.tab[data-tab="${tabName}"]`).classList.add('active');
document.getElementById(`${tabName}-editor`).style.display = 'block';
}

updateTempo() {
document.getElementById('current-bpm').textContent = `BPM: ${this.bpm}`;
this.showMessage(`节奏更新: ${this.bpm} BPM`, 'info');
}

updateEmotion() {
this.showMessage('情感参数已更新', 'info');
}

updateEffect(effect, value) {
// 更新音频效果参数
switch(effect) {
case 'reverb':
// 更新混响参数
break;
case 'delay':
const delay = this.audioNodes.get('delay');
delay.delay.delayTime.value = value / 100;
delay.gain.gain.value = value / 100;
break;
// 其他效果...
}
}

updateHarmony() {
this.showMessage(`和声设置更新: ${this.harmonyType} (强度: ${this.harmonyIntensity}%)`, 'info');
}

updateTimeSignature() {
this.showMessage(`拍号更新: ${this.timeSignature}`, 'info');
}

updateSwing() {
this.showMessage(`摇摆感: ${this.swing}%`, 'info');
}

loadPreset(presetName) {
const presetConfigs = {
pop: { bpm: 120, voice: 'female2', instrument: 'piano', harmony: 'third' },
rock: { bpm: 140, voice: 'male2', instrument: 'guitar', harmony: 'fifth' },
ballad: { bpm: 80, voice: 'female1', instrument: 'strings', harmony: 'full' },
electronic: { bpm: 128, voice: 'male1', instrument: 'synth', harmony: 'octave' }
};

const config = presetConfigs[presetName];
if (config) {
this.bpm = config.bpm;
this.currentVoice = config.voice;
this.currentInstrument = config.instrument;
this.harmonyType = config.harmony;

this.updateUIFromPresets();
this.showMessage(`预设加载: ${presetName}`, 'success');
}
}

formatTime(seconds) {
const mins = Math.floor(seconds / 60);
const secs = Math.floor(seconds % 60);
return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
}

showMessage(message, type = 'info') {
console.log(`💬 ${message}`);

// 创建临时消息显示
const messageDiv = document.createElement('div');
messageDiv.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
background: ${type === 'success' ? 'var(--success)' : type === 'warning' ? 'var(--warning)' : type === 'danger' ? 'var(--danger)' : 'var(--primary)'};
color: white;
padding: 12px 20px;
border-radius: 8px;
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
z-index: 1000;
font-size: 14px;
`;
messageDiv.textContent = message;
document.body.appendChild(messageDiv);

setTimeout(() => {
if (messageDiv.parentNode) {
messageDiv.parentNode.removeChild(messageDiv);
}
}, 3000);
}

// 从之前的系统继承的方法
parseLyrics(lyrics) {
const sections = [];
const lines = lyrics.split('\n');
let currentSection = null;
let currentTime = 0;

lines.forEach(line => {
line = line.trim();
if (!line) return;

if (line.startsWith('[') && line.endsWith(']')) {
const sectionType = line.slice(1, -1);
currentSection = {
type: this.detectSectionType(sectionType),
name: sectionType,
lyrics: [],
startTime: currentTime,
duration: 0
};
sections.push(currentSection);
} else if (currentSection) {
currentSection.lyrics.push(line);
currentTime += this.calculateLineDuration(line) + 0.2;
}
});

// 计算每个段落的时长
sections.forEach(section => {
if (section.type === 'interlude') {
section.duration = this.calculateInterludeDuration(section);
} else {
section.duration = section.lyrics.reduce((total, line) =>
total + this.calculateLineDuration(line) + 0.2, 0
);
}
});

return sections;
}

detectSectionType(sectionName) {
const typeMap = {
'主歌': 'verse',
'副歌': 'chorus',
'预副歌': 'pre-chorus',
'桥段': 'bridge',
'间奏': 'interlude',
'尾奏': 'outro'
};
return typeMap[sectionName] || 'verse';
}

calculateInterludeDuration(section) {
const text = section.lyrics.join(' ');
const match = text.match(/(\d+)\s*小节/);
if (match) {
const bars = parseInt(match[1]);
return bars * (60 / this.bpm) * 4;
}
return 8 * (60 / this.bpm);
}

calculateLineDuration(line) {
const baseDuration = 2.0;
const lengthFactor = line.length * 0.1;
const emotionFactor = 1 + (this.emotionProfile.happiness - 50) / 100;
return Math.max(1.0, baseDuration + lengthFactor) * emotionFactor;
}

calculateTotalDuration() {
return this.sections.reduce((total, section) => total + section.duration, 0);
}

getVoiceBaseFrequency(voiceType) {
const frequencies = {
female1: 440,
female2: 494,
male1: 330,

Prev | Next
Pg.: 1 ... 14 15 16 17 18 19 20 21 22 23 24 ... 56


Back to home | File page

Subscribe | Register | Login | N