66, volume: 0.1}, {frequency: 349.23, volume: 0.08}, {frequency: 440.00, volume: 0.06}], duration: duration / 4 },
{ notes: [{frequency: 329.63, volume: 0.1}, {frequency: 392.00, volume: 0.08}, {frequency: 493.88, volume: 0.06}], duration: duration / 4 },
{ notes: [{frequency: 349.23, volume: 0.1}, {frequency: 440.00, volume: 0.08}, {frequency: 523.25, volume: 0.06}], duration: duration / 4 }
],
chorus: [
{ notes: [{frequency: 261.63, volume: 0.15}, {frequency: 329.63, volume: 0.12}, {frequency: 392.00, volume: 0.1}], duration: duration / 4 },
{ notes: [{frequency: 293.66, volume: 0.15}, {frequency: 349.23, volume: 0.12}, {frequency: 440.00, volume: 0.1}], duration: duration / 4 },
{ notes: [{frequency: 261.63, volume: 0.15}, {frequency: 329.63, volume: 0.12}, {frequency: 392.00, volume: 0.1}], duration: duration / 4 },
{ notes: [{frequency: 349.23, volume: 0.15}, {frequency: 440.00, volume: 0.12}, {frequency: 523.25, volume: 0.1}], duration: duration / 4 }
],
'pre-chorus': [
{ notes: [{frequency: 293.66, volume: 0.12}, {frequency: 349.23, volume: 0.1}, {frequency: 440.00, volume: 0.08}], duration: duration / 3 },
{ notes: [{frequency: 329.63, volume: 0.12}, {frequency: 392.00, volume: 0.1}, {frequency: 493.88, volume: 0.08}], duration: duration / 3 },
{ notes: [{frequency: 349.23, volume: 0.12}, {frequency: 440.00, volume: 0.1}, {frequency: 523.25, volume: 0.08}], duration: duration / 3 }
]
};

return chordProgressions[style] || chordProgressions.verse;
}

// 获取段落音乐风格
getMusicStyleForSection(sectionType) {
const styleMap = {
verse: 'verse',
chorus: 'chorus',
'pre-chorus': 'pre-chorus',
bridge: 'verse',
interlude: 'verse'
};
return styleMap[sectionType] || '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; // 4拍每小节
}
return 8 * (60 / this.bpm); // 默认8小节
}

// 计算行时长
calculateLineDuration(line) {
const baseDuration = 2.0; // 基础时长2秒
const lengthFactor = line.length * 0.1; // 每字符0.1秒
const emotionFactor = 1 + (this.emotionProfile.happiness - 50) / 100; // 情感影响

return Math.max(1.0, baseDuration + lengthFactor) * emotionFactor;
}

// 计算总时长
calculateTotalDuration() {
let total = 0;
this.sections.forEach(section => {
if (section.type === 'interlude') {
total += this.calculateInterludeDuration(section);
} else {
section.lyrics.forEach(line => {
total += this.calculateLineDuration(line) + 0.2; // 加上行间间隔
});
}
});
return total;
}

// 更新节奏
updateTempo() {
// 更新所有基于BPM的计算
this.showMessage(`节奏已更新: ${this.bpm} BPM`);
}

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

// 初始化可视化
initVisualization() {
this.createWaveform();
this.createSpectrum();
this.createTimeline();
}

// 创建波形显示
createWaveform() {
const container = document.getElementById('waveform');
// 创建波形可视化
for (let i = 0; i < 200; i++) {
const bar = document.createElement('div');
bar.style.position = 'absolute';
bar.style.bottom = '0';
bar.style.left = `${(i / 200) * 100}%`;
bar.style.width = '1px';
bar.style.height = '0px';
bar.style.background = 'linear-gradient(to top, #667eea, #764ba2)';
bar.style.transition = 'height 0.1s ease';
container.appendChild(bar);
}
}

// 创建频谱显示
createSpectrum() {
const container = document.getElementById('spectrum');
// 创建频谱可视化
for (let i = 0; i < 64; i++) {
const bar = document.createElement('div');
bar.style.position = 'absolute';
bar.style.bottom = '0';
bar.style.left = `${(i / 64) * 100}%`;
bar.style.width = '3px';
bar.style.height = '0px';
bar.style.background = 'linear-gradient(to top, #f093fb, #f5576c)';
bar.style.borderRadius = '2px 2px 0 0';
bar.style.transition = 'height 0.05s ease';
container.appendChild(bar);
}
}

// 创建时间线
createTimeline() {
const container = document.getElementById('timeline');
// 创建时间线标记
for (let i = 0; i < 10; i++) {
const marker = document.createElement('div');
marker.style.position = 'absolute';
marker.style.bottom = '0';
marker.style.left = `${i * 10}%`;
marker.style.width = '1px';
marker.style.height = '20px';
marker.style.background = '#667eea';

const label = document.createElement('div');
label.style.position = 'absolute';
label.style.bottom = '25px';
label.style.left = `${i * 10}%`;
label.style.transform = 'translateX(-50%)';
label.style.fontSize = '10px';
label.style.color = '#667eea';
label.textContent = `${i * 10}s`;

container.appendChild(marker);
container.appendChild(label);
}
}

// 更新进度
updateProgress() {
const progress = (this.currentTime / this.totalTime) * 100;
document.getElementById('progress').style.width = `${progress}%`;
document.getElementById('current-time').textContent = this.formatTime(this.currentTime);
}

// 格式化时间
formatTime(seconds) {
const mins = Math.floor(seconds / 60);
const secs = Math.

Prev | Next
Pg.: 1 2 3 4 5 6 7 8 9 ... 56


Back to home | File page

Subscribe | Register | Login | N