'fifth': [3/2, 2/3], // 五度
'full': [2, 4/3, 3/2, 0.5, 3/4, 2/3] // 完整和声
};

const intervals = harmonyIntervals[this.harmonyType] || [];
const intensity = this.harmonyIntensity / 100;

for (const interval of intervals) {
const harmonyNotes = this.generateHarmonyNotes(duration, interval, intensity);
for (const note of harmonyNotes) {
this.playNoteWithEffects(note.frequency, note.duration, note.volume, this.currentInstrument);
}
}

return new Promise(resolve => {
setTimeout(resolve, duration * 1000);
});
}

// 生成和声音符
generateHarmonyNotes(duration, interval, intensity) {
const baseFreq = this.getVoiceBaseFrequency(this.currentVoice);
const noteCount = 4;
const notes = [];

for (let i = 0; i < noteCount; i++) {
notes.push({
frequency: baseFreq * interval,
duration: duration / noteCount,
volume: 0.05 * intensity
});
}

return notes;
}

// 切换录制
toggleRecord() {
this.isRecording = !this.isRecording;
const recordBtn = document.getElementById('record-btn');

if (this.isRecording) {
recordBtn.style.background = 'var(--danger)';
recordBtn.innerHTML = '<span>⏹️</span><span>停止录制</span>';
this.recordingData = [];
this.showMessage('开始录制...', 'info');
} else {
recordBtn.style.background = '';
recordBtn.innerHTML = '<span>⏺️</span><span>录制</span>';
this.showMessage(`录制完成,共 ${this.recordingData.length} 个音频片段`, 'success');
this.saveRecording();
}
}

// 切换循环
toggleLoop() {
this.isLooping = !this.isLooping;
const loopBtn = document.getElementById('loop-btn');

if (this.isLooping) {
loopBtn.style.background = 'var(--success)';
this.showMessage('循环播放已启用', 'success');
} else {
loopBtn.style.background = '';
this.showMessage('循环播放已禁用', 'info');
}
}

// 导出音频
async exportAudio() {
this.showMessage('音频导出功能开发中...', 'info');
// 这里可以实现Web Audio API的录音和导出功能
}

// 显示帮助
showHelp() {
const helpText = `
🎵 高级音乐编排系统使用指南

1. 🎤 发音人选择
- 选择不同的发音人模拟不同声音特征
- 每个发音人都有特定的情感表现范围

2. 🎹 乐器配置
- 选择主奏乐器和背景乐器
- 不同乐器有不同的音色和效果配置

3. 🎭 情感控制
- 调整情感滑块影响语音和音乐的表現
- 系统会智能分析歌词情感并自动调整

4. 🎼 歌曲结构
- 使用 [主歌]、[副歌] 等标记定义结构
- 系统会自动处理段落过渡和间奏

5. 🎛️ 音频效果
- 混响: 增加空间感
- 延迟: 创造回声效果
- 合唱: 让声音更丰满
- 压缩: 平衡音频动态

6. ⏱️ 节奏设置
- 调整BPM控制整体速度
- 选择拍号改变节奏感
- 摇摆感增加节奏的动感
`;

alert(helpText);
}

// 更新UI方法
updateVoiceSelection() {
document.querySelectorAll('.voice-option').forEach(option => {
option.classList.remove('active');
if (option.dataset.voice === this.currentVoice) {
option.classList.add('active');
}
});
document.getElementById('current-voice').textContent = `发音人: ${document.querySelector('.voice-option.active div:nth-child(2) div').textContent}`;
}

updateInstrumentSelection() {
document.querySelectorAll('.instrument-option').forEach(option => {
option.classList.remove('active');
if (option.dataset.instrument === this.currentInstrument) {
option.classList.add('active');
}
});
}

updateEmotionSliders() {
Object.keys(this.emotionProfile).forEach(emotion => {
const slider = document.querySelector(`.emotion[data-emotion="${emotion}"]`);
const valueDisplay = document.getElementById(`${emotion}-value`);
if (slider && valueDisplay) {
slider.value = this.emotionProfile[emotion];
valueDisplay.textContent = `${this.emotionProfile[emotion]}%`;
}
});
}

updateEffectSliders() {
Object.keys(this.effectProfile).forEach(effect => {
const slider = document.querySelector(`.effect[data-effect="${effect}"]`);
const valueDisplay = document.getElementById(`${effect}-value`);
if (slider && valueDisplay) {
slider.value = this.effectProfile[effect];
valueDisplay.textContent = `${this.effectProfile[effect]}%`;
}
});
}

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

updateSectionMarkers() {
const markersContainer = document.getElementById('section-markers');
markersContainer.innerHTML = '';

this.sections.forEach((section, index) => {
const marker = document.createElement('div');
marker.className = 'section-marker';
marker.style.left = `${(section.startTime / this.totalTime) * 100}%`;
marker.title = section.name;
markersContainer.appendChild(marker);
});
}

updateVisualization() {
this.updateWaveform();
this.updateSpectrum();
}

updateWaveform() {
const container = document.getElementById('waveform');
const bars = container.querySelectorAll('div:not(:first-child)');

bars.forEach((bar, index) => {
const height = 20 + Math.sin(Date.now() * 0.01 + index * 0.3) * 15 + Math.random() * 10;
bar.style.height = `${height}px`;
});
}

updateSpectrum() {
const container = document.getElementById('spectrum');
const bars = container.querySelectorAll('div:not(:first-child)');

bars.forEach((bar, index) => {
const height = 10 + Math.sin(Date.now() * 0.02 + index * 0.5) * 20 + Math.

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


Back to home | File page

Subscribe | Register | Login | N