Add sampler nodes and startup screen

This commit is contained in:
Skyler Lehmkuhl
2025-10-28 01:32:51 -04:00
parent e57ae51397
commit 2e9699b524
30 changed files with 5012 additions and 215 deletions
+5
View File
@@ -0,0 +1,5 @@
<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<!-- Placeholder animation/drawing icon -->
<path d="M20,80 Q30,60 50,50 T80,20" stroke="currentColor" stroke-width="4" fill="none" stroke-linecap="round"/>
<circle cx="30" cy="70" r="8" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 310 B

+10
View File
@@ -0,0 +1,10 @@
<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<!-- Placeholder music/piano icon -->
<rect x="10" y="20" width="18" height="60" fill="none" stroke="currentColor" stroke-width="3"/>
<rect x="30" y="20" width="18" height="60" fill="none" stroke="currentColor" stroke-width="3"/>
<rect x="50" y="20" width="18" height="60" fill="none" stroke="currentColor" stroke-width="3"/>
<rect x="70" y="20" width="18" height="60" fill="none" stroke="currentColor" stroke-width="3"/>
<rect x="24" y="20" width="12" height="35" fill="currentColor"/>
<rect x="44" y="20" width="12" height="35" fill="currentColor"/>
<rect x="74" y="20" width="12" height="35" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 728 B

+9
View File
@@ -0,0 +1,9 @@
<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<!-- Placeholder video/clapperboard icon -->
<rect x="15" y="40" width="70" height="45" fill="currentColor" rx="4"/>
<rect x="15" y="25" width="70" height="15" fill="none" stroke="currentColor" stroke-width="3" rx="4"/>
<rect x="20" y="25" width="7" height="15" fill="currentColor"/>
<rect x="35" y="25" width="7" height="15" fill="currentColor"/>
<rect x="50" y="25" width="7" height="15" fill="currentColor"/>
<rect x="65" y="25" width="7" height="15" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 585 B

+435 -12
View File
@@ -8,6 +8,12 @@ import {
showNewFileDialog,
closeDialog,
} from "./newfile.js";
import {
createStartScreen,
updateStartScreen,
showStartScreen,
hideStartScreen,
} from "./startscreen.js";
import {
titleCase,
getMousePositionFraction,
@@ -125,6 +131,12 @@ const { PhysicalPosition, LogicalPosition } = window.__TAURI__.dpi;
const { getCurrentWindow } = window.__TAURI__.window;
const { getVersion } = window.__TAURI__.app;
// Supported file extensions
const imageExtensions = ["png", "gif", "avif", "jpg", "jpeg"];
const audioExtensions = ["mp3", "wav", "aiff", "ogg", "flac"];
const midiExtensions = ["mid", "midi"];
const beamExtensions = ["beam"];
// import init, { CoreInterface } from './pkg/lightningbeam_core.js';
window.onerror = (message, source, lineno, colno, error) => {
@@ -1369,7 +1381,9 @@ function _newFile(width, height, fps, layoutKey) {
const oldRoot = root;
console.log('[_newFile] Old root:', oldRoot, 'frameRate:', oldRoot?.frameRate);
root = new GraphicsObject("root");
// Determine initial child type based on layout
const initialChildType = layoutKey === 'audioDaw' ? 'midi' : 'layer';
root = new GraphicsObject("root", initialChildType);
// Switch to the selected layout if provided
if (layoutKey) {
@@ -1791,12 +1805,6 @@ function revert() {
}
async function importFile() {
// Define supported extensions
const imageExtensions = ["png", "gif", "avif", "jpg", "jpeg"];
const audioExtensions = ["mp3", "wav", "aiff", "ogg", "flac"];
const midiExtensions = ["mid", "midi"];
const beamExtensions = ["beam"];
// Define filters in consistent order
const allFilters = [
{
@@ -4363,12 +4371,33 @@ function outliner(object = undefined) {
async function startup() {
await loadConfig();
createNewFileDialog(_newFile, _open, config);
// Create start screen with callback
createStartScreen(async (options) => {
hideStartScreen();
if (options.type === 'new') {
// Create new project with selected focus
_newFile(
options.width || 800,
options.height || 600,
options.fps || 24,
options.projectFocus
);
} else if (options.type === 'reopen' || options.type === 'recent') {
// Open existing file
await _open(options.filePath);
}
});
if (!window.openedFiles?.length) {
if (config.reopenLastSession && config.recentFiles?.length) {
document.body.style.cursor = "wait"
setTimeout(()=>_open(config.recentFiles[0]), 10)
} else {
showNewFileDialog(config);
// Show start screen instead of new file dialog
await updateStartScreen(config);
showStartScreen();
}
}
}
@@ -6074,9 +6103,11 @@ function nodeEditor() {
// Create the Drawflow canvas
const editorDiv = document.createElement("div");
editorDiv.id = "drawflow";
editorDiv.style.width = "100%";
editorDiv.style.height = "calc(100% - 40px)"; // Account for header
editorDiv.style.position = "relative";
editorDiv.style.position = "absolute";
editorDiv.style.top = "40px"; // Start below header
editorDiv.style.left = "0";
editorDiv.style.right = "0";
editorDiv.style.bottom = "0";
container.appendChild(editorDiv);
// Create node palette
@@ -6611,7 +6642,7 @@ function nodeEditor() {
const nodeElement = document.getElementById(`node-${nodeId}`);
if (!nodeElement) return;
const sliders = nodeElement.querySelectorAll(".node-slider");
const sliders = nodeElement.querySelectorAll('input[type="range"]');
sliders.forEach(slider => {
// Prevent node dragging when interacting with slider
slider.addEventListener("mousedown", (e) => {
@@ -6654,6 +6685,115 @@ function nodeEditor() {
}
});
});
// Handle Load Sample button for SimpleSampler
const loadSampleBtn = nodeElement.querySelector(".load-sample-btn");
if (loadSampleBtn) {
loadSampleBtn.addEventListener("mousedown", (e) => e.stopPropagation());
loadSampleBtn.addEventListener("pointerdown", (e) => e.stopPropagation());
loadSampleBtn.addEventListener("click", async (e) => {
e.stopPropagation();
const nodeData = editor.getNodeFromId(nodeId);
if (!nodeData || nodeData.data.backendId === null) {
showError("Node not yet created on backend");
return;
}
const currentTrackId = getCurrentMidiTrack();
if (currentTrackId === null) {
showError("No MIDI track selected");
return;
}
try {
const filePath = await openFileDialog({
title: "Load Audio Sample",
filters: [{
name: "Audio Files",
extensions: audioExtensions
}]
});
if (filePath) {
await invoke("sampler_load_sample", {
trackId: currentTrackId,
nodeId: nodeData.data.backendId,
filePath: filePath
});
// Update UI to show filename
const sampleInfo = nodeElement.querySelector(`#sample-info-${nodeId}`);
if (sampleInfo) {
const filename = filePath.split('/').pop().split('\\').pop();
sampleInfo.textContent = filename;
}
}
} catch (err) {
console.error("Failed to load sample:", err);
showError(`Failed to load sample: ${err}`);
}
});
}
// Handle Add Layer button for MultiSampler
const addLayerBtn = nodeElement.querySelector(".add-layer-btn");
if (addLayerBtn) {
addLayerBtn.addEventListener("mousedown", (e) => e.stopPropagation());
addLayerBtn.addEventListener("pointerdown", (e) => e.stopPropagation());
addLayerBtn.addEventListener("click", async (e) => {
e.stopPropagation();
const nodeData = editor.getNodeFromId(nodeId);
if (!nodeData || nodeData.data.backendId === null) {
showError("Node not yet created on backend");
return;
}
const currentTrackId = getCurrentMidiTrack();
if (currentTrackId === null) {
showError("No MIDI track selected");
return;
}
try {
const filePath = await openFileDialog({
title: "Add Sample Layer",
filters: [{
name: "Audio Files",
extensions: audioExtensions
}]
});
if (filePath) {
// Show dialog to configure layer mapping
const layerConfig = await showLayerConfigDialog(filePath);
if (layerConfig) {
await invoke("multi_sampler_add_layer", {
trackId: currentTrackId,
nodeId: nodeData.data.backendId,
filePath: filePath,
keyMin: layerConfig.keyMin,
keyMax: layerConfig.keyMax,
rootKey: layerConfig.rootKey,
velocityMin: layerConfig.velocityMin,
velocityMax: layerConfig.velocityMax
});
// Wait a bit for the audio thread to process the add command
await new Promise(resolve => setTimeout(resolve, 100));
// Refresh the layers list
await refreshSampleLayersList(nodeId);
}
}
} catch (err) {
console.error("Failed to add layer:", err);
showError(`Failed to add layer: ${err}`);
}
});
}
}, 100);
}
@@ -6682,6 +6822,134 @@ function nodeEditor() {
enterTemplate(node.data.backendId, nodeName);
}
// Refresh the layers list for a MultiSampler node
async function refreshSampleLayersList(nodeId) {
const nodeData = editor.getNodeFromId(nodeId);
if (!nodeData || nodeData.data.backendId === null) {
return;
}
const currentTrackId = getCurrentMidiTrack();
if (currentTrackId === null) {
return;
}
try {
const layers = await invoke("multi_sampler_get_layers", {
trackId: currentTrackId,
nodeId: nodeData.data.backendId
});
const layersList = document.querySelector(`#sample-layers-list-${nodeId}`);
const layersContainer = document.querySelector(`#sample-layers-container-${nodeId}`);
if (!layersList) return;
// Prevent scroll events from bubbling to canvas
if (layersContainer && !layersContainer.dataset.scrollListenerAdded) {
layersContainer.addEventListener('wheel', (e) => {
e.stopPropagation();
}, { passive: false });
layersContainer.dataset.scrollListenerAdded = 'true';
}
if (layers.length === 0) {
layersList.innerHTML = '<tr><td colspan="5" class="sample-layers-empty">No layers loaded</td></tr>';
} else {
layersList.innerHTML = layers.map((layer, index) => {
const filename = layer.file_path.split('/').pop().split('\\').pop();
const keyRange = `${midiToNoteName(layer.key_min)}-${midiToNoteName(layer.key_max)}`;
const rootNote = midiToNoteName(layer.root_key);
const velRange = `${layer.velocity_min}-${layer.velocity_max}`;
return `
<tr data-index="${index}">
<td class="sample-layer-filename" title="${filename}">${filename}</td>
<td>${keyRange}</td>
<td>${rootNote}</td>
<td>${velRange}</td>
<td>
<div class="sample-layer-actions">
<button class="btn-edit-layer" data-node="${nodeId}" data-index="${index}">Edit</button>
<button class="btn-delete-layer" data-node="${nodeId}" data-index="${index}">Del</button>
</div>
</td>
</tr>
`;
}).join('');
// Add event listeners for edit buttons
const editButtons = layersList.querySelectorAll('.btn-edit-layer');
editButtons.forEach(btn => {
btn.addEventListener('click', async (e) => {
e.stopPropagation();
const index = parseInt(btn.dataset.index);
const layer = layers[index];
// Show edit dialog with current values
const layerConfig = await showLayerConfigDialog(layer.file_path, {
keyMin: layer.key_min,
keyMax: layer.key_max,
rootKey: layer.root_key,
velocityMin: layer.velocity_min,
velocityMax: layer.velocity_max
});
if (layerConfig) {
try {
await invoke("multi_sampler_update_layer", {
trackId: currentTrackId,
nodeId: nodeData.data.backendId,
layerIndex: index,
keyMin: layerConfig.keyMin,
keyMax: layerConfig.keyMax,
rootKey: layerConfig.rootKey,
velocityMin: layerConfig.velocityMin,
velocityMax: layerConfig.velocityMax
});
// Refresh the list
await refreshSampleLayersList(nodeId);
} catch (err) {
console.error("Failed to update layer:", err);
showError(`Failed to update layer: ${err}`);
}
}
});
});
// Add event listeners for delete buttons
const deleteButtons = layersList.querySelectorAll('.btn-delete-layer');
deleteButtons.forEach(btn => {
btn.addEventListener('click', async (e) => {
e.stopPropagation();
const index = parseInt(btn.dataset.index);
const layer = layers[index];
const filename = layer.file_path.split('/').pop().split('\\').pop();
if (confirm(`Delete layer "${filename}"?`)) {
try {
await invoke("multi_sampler_remove_layer", {
trackId: currentTrackId,
nodeId: nodeData.data.backendId,
layerIndex: index
});
// Refresh the list
await refreshSampleLayersList(nodeId);
} catch (err) {
console.error("Failed to remove layer:", err);
showError(`Failed to remove layer: ${err}`);
}
}
});
});
}
} catch (err) {
console.error("Failed to get layers:", err);
}
}
// Handle connection creation
function handleConnectionCreated(connection) {
console.log("handleConnectionCreated called:", connection);
@@ -7508,6 +7776,161 @@ function showSavePresetDialog(container) {
});
}
// Helper function to convert MIDI note number to note name
function midiToNoteName(midiNote) {
const noteNames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
const octave = Math.floor(midiNote / 12) - 1;
const noteName = noteNames[midiNote % 12];
return `${noteName}${octave}`;
}
// Show dialog to configure MultiSampler layer zones
function showLayerConfigDialog(filePath, existingConfig = null) {
return new Promise((resolve) => {
const filename = filePath.split('/').pop().split('\\').pop();
const isEdit = existingConfig !== null;
// Use existing values or defaults
const keyMin = existingConfig?.keyMin ?? 0;
const keyMax = existingConfig?.keyMax ?? 127;
const rootKey = existingConfig?.rootKey ?? 60;
const velocityMin = existingConfig?.velocityMin ?? 0;
const velocityMax = existingConfig?.velocityMax ?? 127;
// Create modal dialog
const dialog = document.createElement('div');
dialog.className = 'modal-overlay';
dialog.innerHTML = `
<div class="modal-dialog">
<h3>${isEdit ? 'Edit' : 'Configure'} Sample Layer</h3>
<p style="font-size: 12px; color: #666; margin-bottom: 16px;">
File: <strong>${filename}</strong>
</p>
<form id="layer-config-form">
<div class="form-group">
<label>Key Range</label>
<div class="form-group-inline">
<div>
<label style="font-size: 11px; color: #888;">Min</label>
<input type="number" id="key-min" min="0" max="127" value="${keyMin}" required />
<div id="key-min-name" class="form-note-name">${midiToNoteName(keyMin)}</div>
</div>
<span>-</span>
<div>
<label style="font-size: 11px; color: #888;">Max</label>
<input type="number" id="key-max" min="0" max="127" value="${keyMax}" required />
<div id="key-max-name" class="form-note-name">${midiToNoteName(keyMax)}</div>
</div>
</div>
</div>
<div class="form-group">
<label>Root Key (original pitch)</label>
<input type="number" id="root-key" min="0" max="127" value="${rootKey}" required />
<div id="root-key-name" class="form-note-name">${midiToNoteName(rootKey)}</div>
</div>
<div class="form-group">
<label>Velocity Range</label>
<div class="form-group-inline">
<div>
<label style="font-size: 11px; color: #888;">Min</label>
<input type="number" id="velocity-min" min="0" max="127" value="${velocityMin}" required />
</div>
<span>-</span>
<div>
<label style="font-size: 11px; color: #888;">Max</label>
<input type="number" id="velocity-max" min="0" max="127" value="${velocityMax}" required />
</div>
</div>
</div>
<div class="form-actions">
<button type="button" class="btn-cancel">Cancel</button>
<button type="submit" class="btn-primary">${isEdit ? 'Update' : 'Add'} Layer</button>
</div>
</form>
</div>
`;
document.body.appendChild(dialog);
// Update note names when inputs change
const keyMinInput = dialog.querySelector('#key-min');
const keyMaxInput = dialog.querySelector('#key-max');
const rootKeyInput = dialog.querySelector('#root-key');
const updateKeyMinName = () => {
const note = parseInt(keyMinInput.value) || 0;
dialog.querySelector('#key-min-name').textContent = midiToNoteName(note);
};
const updateKeyMaxName = () => {
const note = parseInt(keyMaxInput.value) || 127;
dialog.querySelector('#key-max-name').textContent = midiToNoteName(note);
};
const updateRootKeyName = () => {
const note = parseInt(rootKeyInput.value) || 60;
dialog.querySelector('#root-key-name').textContent = midiToNoteName(note);
};
keyMinInput.addEventListener('input', updateKeyMinName);
keyMaxInput.addEventListener('input', updateKeyMaxName);
rootKeyInput.addEventListener('input', updateRootKeyName);
// Focus first input
setTimeout(() => dialog.querySelector('#key-min')?.focus(), 100);
// Handle cancel
dialog.querySelector('.btn-cancel').addEventListener('click', () => {
dialog.remove();
resolve(null);
});
// Handle submit
dialog.querySelector('#layer-config-form').addEventListener('submit', (e) => {
e.preventDefault();
const keyMin = parseInt(keyMinInput.value);
const keyMax = parseInt(keyMaxInput.value);
const rootKey = parseInt(rootKeyInput.value);
const velocityMin = parseInt(dialog.querySelector('#velocity-min').value);
const velocityMax = parseInt(dialog.querySelector('#velocity-max').value);
// Validate ranges
if (keyMin > keyMax) {
alert('Key Min must be less than or equal to Key Max');
return;
}
if (velocityMin > velocityMax) {
alert('Velocity Min must be less than or equal to Velocity Max');
return;
}
if (rootKey < keyMin || rootKey > keyMax) {
alert('Root Key must be within the key range');
return;
}
dialog.remove();
resolve({
keyMin,
keyMax,
rootKey,
velocityMin,
velocityMax
});
});
// Close on background click
dialog.addEventListener('click', (e) => {
if (e.target === dialog) {
dialog.remove();
resolve(null);
}
});
});
}
function filterPresets(container) {
const searchTerm = container.querySelector('#preset-search')?.value.toLowerCase() || '';
const selectedTag = container.querySelector('#preset-tag-filter')?.value || '';
+25 -4
View File
@@ -31,7 +31,7 @@ export function initializeGraphicsObjectDependencies(deps) {
}
class GraphicsObject extends Widget {
constructor(uuid) {
constructor(uuid, initialChildType = 'layer') {
super(0, 0)
this.rotation = 0; // in radians
this.scale_x = 1;
@@ -48,10 +48,31 @@ class GraphicsObject extends Widget {
this.currentTime = 0; // New: continuous time for AnimationData curves
this.currentLayer = 0;
this._activeAudioTrack = null; // Reference to active audio track (if any)
this.children = [new Layer(uuid + "-L1", this)];
// this.layers = [new Layer(uuid + "-L1")];
// Initialize children and audioTracks based on initialChildType
this.children = [];
this.audioTracks = [];
// this.children = []
if (initialChildType === 'layer') {
this.children = [new Layer(uuid + "-L1", this)];
this.currentLayer = 0; // Set first layer as active
} else if (initialChildType === 'midi') {
const midiTrack = new AudioTrack(uuid + "-M1", "MIDI 1", 'midi');
this.audioTracks.push(midiTrack);
this._activeAudioTrack = midiTrack; // Set MIDI track as active (the object, not index)
// Initialize the MIDI track in the audio backend
midiTrack.initializeTrack().catch(err => {
console.error('Failed to initialize MIDI track:', err);
});
} else if (initialChildType === 'audio') {
const audioTrack = new AudioTrack(uuid + "-A1", "Audio 1", 'audio');
this.audioTracks.push(audioTrack);
this._activeAudioTrack = audioTrack; // Set audio track as active (the object, not index)
audioTrack.initializeTrack().catch(err => {
console.error('Failed to initialize audio track:', err);
});
}
// If initialChildType is 'none' or anything else, leave both arrays empty
this.shapes = [];
+381 -26
View File
@@ -56,7 +56,7 @@ export const nodeTypes = {
<div class="node-param">
<label>Waveform: <span id="wave-${nodeId}">Sine</span></label>
<input type="range"
class="node-slider"
data-node="${nodeId}"
data-param="2"
min="0"
@@ -67,7 +67,7 @@ export const nodeTypes = {
<div class="node-param">
<label>Frequency: <span id="freq-${nodeId}">440</span> Hz</label>
<input type="range"
class="node-slider"
data-node="${nodeId}"
data-param="0"
min="20"
@@ -78,7 +78,7 @@ export const nodeTypes = {
<div class="node-param">
<label>Amplitude: <span id="amp-${nodeId}">0.5</span></label>
<input type="range"
class="node-slider"
data-node="${nodeId}"
data-param="1"
min="0"
@@ -110,7 +110,7 @@ export const nodeTypes = {
<div class="node-param">
<label>Gain: <span id="gain-${nodeId}">1.0</span>x</label>
<input type="range"
class="node-slider"
data-node="${nodeId}"
data-param="0"
min="0"
@@ -146,19 +146,19 @@ export const nodeTypes = {
<div class="node-title">Mixer</div>
<div class="node-param">
<label>Gain 1: <span id="g1-${nodeId}">1.0</span>x</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="0" max="2" value="1" step="0.01">
<input type="range" data-node="${nodeId}" data-param="0" min="0" max="2" value="1" step="0.01">
</div>
<div class="node-param">
<label>Gain 2: <span id="g2-${nodeId}">1.0</span>x</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0" max="2" value="1" step="0.01">
<input type="range" data-node="${nodeId}" data-param="1" min="0" max="2" value="1" step="0.01">
</div>
<div class="node-param">
<label>Gain 3: <span id="g3-${nodeId}">1.0</span>x</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="2" min="0" max="2" value="1" step="0.01">
<input type="range" data-node="${nodeId}" data-param="2" min="0" max="2" value="1" step="0.01">
</div>
<div class="node-param">
<label>Gain 4: <span id="g4-${nodeId}">1.0</span>x</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="3" min="0" max="2" value="1" step="0.01">
<input type="range" data-node="${nodeId}" data-param="3" min="0" max="2" value="1" step="0.01">
</div>
</div>
`
@@ -185,15 +185,15 @@ export const nodeTypes = {
<div class="node-title">Filter</div>
<div class="node-param">
<label>Cutoff: <span id="cutoff-${nodeId}">1000</span> Hz</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="20" max="20000" value="1000" step="1">
<input type="range" data-node="${nodeId}" data-param="0" min="20" max="20000" value="1000" step="1">
</div>
<div class="node-param">
<label>Resonance: <span id="res-${nodeId}">0.707</span></label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0.1" max="10" value="0.707" step="0.01">
<input type="range" data-node="${nodeId}" data-param="1" min="0.1" max="10" value="0.707" step="0.01">
</div>
<div class="node-param">
<label>Type: <span id="ftype-${nodeId}">LP</span></label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="2" min="0" max="1" value="0" step="1">
<input type="range" data-node="${nodeId}" data-param="2" min="0" max="1" value="0" step="1">
</div>
</div>
`
@@ -220,19 +220,19 @@ export const nodeTypes = {
<div class="node-title">ADSR</div>
<div class="node-param">
<label>A: <span id="a-${nodeId}">0.01</span>s</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="0.001" max="5" value="0.01" step="0.001">
<input type="range" data-node="${nodeId}" data-param="0" min="0.001" max="5" value="0.01" step="0.001">
</div>
<div class="node-param">
<label>D: <span id="d-${nodeId}">0.1</span>s</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0.001" max="5" value="0.1" step="0.001">
<input type="range" data-node="${nodeId}" data-param="1" min="0.001" max="5" value="0.1" step="0.001">
</div>
<div class="node-param">
<label>S: <span id="s-${nodeId}">0.7</span></label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="2" min="0" max="1" value="0.7" step="0.01">
<input type="range" data-node="${nodeId}" data-param="2" min="0" max="1" value="0.7" step="0.01">
</div>
<div class="node-param">
<label>R: <span id="r-${nodeId}">0.2</span>s</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="3" min="0.001" max="5" value="0.2" step="0.001">
<input type="range" data-node="${nodeId}" data-param="3" min="0.001" max="5" value="0.2" step="0.001">
</div>
</div>
`
@@ -295,11 +295,11 @@ export const nodeTypes = {
<div class="node-title">Audio→CV</div>
<div class="node-param">
<label>Attack: <span id="att-${nodeId}">0.01</span>s</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="0.001" max="1.0" value="0.01" step="0.001">
<input type="range" data-node="${nodeId}" data-param="0" min="0.001" max="1.0" value="0.01" step="0.001">
</div>
<div class="node-param">
<label>Release: <span id="rel-${nodeId}">0.1</span>s</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0.001" max="1.0" value="0.1" step="0.001">
<input type="range" data-node="${nodeId}" data-param="1" min="0.001" max="1.0" value="0.1" step="0.001">
</div>
</div>
`
@@ -325,11 +325,11 @@ export const nodeTypes = {
<div class="node-title">Oscilloscope</div>
<div class="node-param">
<label>Time: <span id="time-${nodeId}">100</span>ms</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="10" max="1000" value="100" step="10">
<input type="range" data-node="${nodeId}" data-param="0" min="10" max="1000" value="100" step="10">
</div>
<div class="node-param">
<label>Trigger: <span id="trig-${nodeId}">Free</span></label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0" max="2" value="0" step="1">
<input type="range" data-node="${nodeId}" data-param="1" min="0" max="2" value="0" step="1">
</div>
<div class="node-info" style="margin-top: 4px; font-size: 10px;">Pass-through monitor</div>
</div>
@@ -355,7 +355,7 @@ export const nodeTypes = {
<div class="node-title">Voice Allocator</div>
<div class="node-param">
<label>Voices: <span id="voices-${nodeId}">8</span></label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="1" max="16" value="8" step="1">
<input type="range" data-node="${nodeId}" data-param="0" min="1" max="16" value="8" step="1">
</div>
<div class="node-info" style="margin-top: 4px; font-size: 10px;">Double-click to edit</div>
</div>
@@ -443,15 +443,15 @@ export const nodeTypes = {
<div class="node-title">LFO</div>
<div class="node-param">
<label>Wave: <span id="lfowave-${nodeId}">Sine</span></label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="2" min="0" max="4" value="0" step="1">
<input type="range" data-node="${nodeId}" data-param="2" min="0" max="4" value="0" step="1">
</div>
<div class="node-param">
<label>Freq: <span id="lfofreq-${nodeId}">1.0</span> Hz</label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="0.01" max="20" value="1.0" step="0.01">
<input type="range" data-node="${nodeId}" data-param="0" min="0.01" max="20" value="1.0" step="0.01">
</div>
<div class="node-param">
<label>Depth: <span id="lfoamp-${nodeId}">1.0</span></label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0" max="1" value="1.0" step="0.01">
<input type="range" data-node="${nodeId}" data-param="1" min="0" max="1" value="1.0" step="0.01">
</div>
</div>
`
@@ -474,11 +474,11 @@ export const nodeTypes = {
<div class="node-title">Noise</div>
<div class="node-param">
<label>Color: <span id="noisecolor-${nodeId}">White</span></label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="1" min="0" max="1" value="0" step="1">
<input type="range" data-node="${nodeId}" data-param="1" min="0" max="1" value="0" step="1">
</div>
<div class="node-param">
<label>Level: <span id="noiselevel-${nodeId}">0.5</span></label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="0" max="1" value="0.5" step="0.01">
<input type="range" data-node="${nodeId}" data-param="0" min="0" max="1" value="0.5" step="0.01">
</div>
</div>
`
@@ -525,7 +525,362 @@ export const nodeTypes = {
<div class="node-title">Pan</div>
<div class="node-param">
<label>Position: <span id="panpos-${nodeId}">0.0</span></label>
<input type="range" class="node-slider" data-node="${nodeId}" data-param="0" min="-1" max="1" value="0" step="0.01">
<input type="range" data-node="${nodeId}" data-param="0" min="-1" max="1" value="0" step="0.01">
</div>
</div>
`
},
Delay: {
name: 'Delay',
category: NodeCategory.EFFECT,
description: 'Stereo delay with feedback',
inputs: [
{ name: 'Audio In', type: SignalType.AUDIO, index: 0 }
],
outputs: [
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
],
parameters: [
{ id: 0, name: 'delay_time', label: 'Delay Time', min: 0.001, max: 2.0, default: 0.5, unit: 's' },
{ id: 1, name: 'feedback', label: 'Feedback', min: 0, max: 0.95, default: 0.5, unit: '' },
{ id: 2, name: 'wet_dry', label: 'Wet/Dry', min: 0, max: 1, default: 0.5, unit: '' }
],
getHTML: (nodeId) => `
<div class="node-content">
<div class="node-title">Delay</div>
<div class="node-param">
<label>Time: <span id="delaytime-${nodeId}">0.5</span>s</label>
<input type="range" data-node="${nodeId}" data-param="0" min="0.001" max="2" value="0.5" step="0.001">
</div>
<div class="node-param">
<label>Feedback: <span id="feedback-${nodeId}">0.5</span></label>
<input type="range" data-node="${nodeId}" data-param="1" min="0" max="0.95" value="0.5" step="0.01">
</div>
<div class="node-param">
<label>Wet/Dry: <span id="wetdry-${nodeId}">0.5</span></label>
<input type="range" data-node="${nodeId}" data-param="2" min="0" max="1" value="0.5" step="0.01">
</div>
</div>
`
},
Reverb: {
name: 'Reverb',
category: NodeCategory.EFFECT,
description: 'Schroeder reverb with room size and damping',
inputs: [
{ name: 'Audio In', type: SignalType.AUDIO, index: 0 }
],
outputs: [
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
],
parameters: [
{ id: 0, name: 'room_size', label: 'Room Size', min: 0, max: 1, default: 0.5, unit: '' },
{ id: 1, name: 'damping', label: 'Damping', min: 0, max: 1, default: 0.5, unit: '' },
{ id: 2, name: 'wet_dry', label: 'Wet/Dry', min: 0, max: 1, default: 0.3, unit: '' }
],
getHTML: (nodeId) => `
<div class="node-content">
<div class="node-title">Reverb</div>
<div class="node-param">
<label>Room Size: <span id="roomsize-${nodeId}">0.5</span></label>
<input type="range" data-node="${nodeId}" data-param="0" min="0" max="1" value="0.5" step="0.01">
</div>
<div class="node-param">
<label>Damping: <span id="damping-${nodeId}">0.5</span></label>
<input type="range" data-node="${nodeId}" data-param="1" min="0" max="1" value="0.5" step="0.01">
</div>
<div class="node-param">
<label>Wet/Dry: <span id="wetdry-${nodeId}">0.3</span></label>
<input type="range" data-node="${nodeId}" data-param="2" min="0" max="1" value="0.3" step="0.01">
</div>
</div>
`
},
Chorus: {
name: 'Chorus',
category: NodeCategory.EFFECT,
description: 'Chorus effect with modulated delay',
inputs: [
{ name: 'Audio In', type: SignalType.AUDIO, index: 0 }
],
outputs: [
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
],
parameters: [
{ id: 0, name: 'rate', label: 'Rate', min: 0.1, max: 5.0, default: 1.0, unit: 'Hz' },
{ id: 1, name: 'depth', label: 'Depth', min: 0, max: 1, default: 0.5, unit: '' },
{ id: 2, name: 'wet_dry', label: 'Wet/Dry', min: 0, max: 1, default: 0.5, unit: '' }
],
getHTML: (nodeId) => `
<div class="node-content">
<div class="node-title">Chorus</div>
<div class="node-param">
<label>Rate: <span id="chorusrate-${nodeId}">1.0</span>Hz</label>
<input type="range" data-node="${nodeId}" data-param="0" min="0.1" max="5" value="1.0" step="0.1">
</div>
<div class="node-param">
<label>Depth: <span id="chorusdepth-${nodeId}">0.5</span></label>
<input type="range" data-node="${nodeId}" data-param="1" min="0" max="1" value="0.5" step="0.01">
</div>
<div class="node-param">
<label>Wet/Dry: <span id="choruswetdry-${nodeId}">0.5</span></label>
<input type="range" data-node="${nodeId}" data-param="2" min="0" max="1" value="0.5" step="0.01">
</div>
</div>
`
},
Flanger: {
name: 'Flanger',
category: NodeCategory.EFFECT,
description: 'Flanger effect with feedback',
inputs: [
{ name: 'Audio In', type: SignalType.AUDIO, index: 0 }
],
outputs: [
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
],
parameters: [
{ id: 0, name: 'rate', label: 'Rate', min: 0.1, max: 10.0, default: 0.5, unit: 'Hz' },
{ id: 1, name: 'depth', label: 'Depth', min: 0, max: 1, default: 0.7, unit: '' },
{ id: 2, name: 'feedback', label: 'Feedback', min: -0.95, max: 0.95, default: 0.5, unit: '' },
{ id: 3, name: 'wet_dry', label: 'Wet/Dry', min: 0, max: 1, default: 0.5, unit: '' }
],
getHTML: (nodeId) => `
<div class="node-content">
<div class="node-title">Flanger</div>
<div class="node-param">
<label>Rate: <span id="flangerrate-${nodeId}">0.5</span>Hz</label>
<input type="range" data-node="${nodeId}" data-param="0" min="0.1" max="10" value="0.5" step="0.1">
</div>
<div class="node-param">
<label>Depth: <span id="flangerdepth-${nodeId}">0.7</span></label>
<input type="range" data-node="${nodeId}" data-param="1" min="0" max="1" value="0.7" step="0.01">
</div>
<div class="node-param">
<label>Feedback: <span id="flangerfeedback-${nodeId}">0.5</span></label>
<input type="range" data-node="${nodeId}" data-param="2" min="-0.95" max="0.95" value="0.5" step="0.01">
</div>
<div class="node-param">
<label>Wet/Dry: <span id="flangerwetdry-${nodeId}">0.5</span></label>
<input type="range" data-node="${nodeId}" data-param="3" min="0" max="1" value="0.5" step="0.01">
</div>
</div>
`
},
FMSynth: {
name: 'FM Synth',
category: NodeCategory.GENERATOR,
description: '4-operator FM synthesizer',
inputs: [
{ name: 'V/Oct', type: SignalType.CV, index: 0 },
{ name: 'Gate', type: SignalType.CV, index: 1 }
],
outputs: [
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
],
parameters: [
{ id: 0, name: 'algorithm', label: 'Algorithm', min: 0, max: 3, default: 0, unit: '' },
{ id: 1, name: 'op1_ratio', label: 'Op1 Ratio', min: 0.25, max: 16, default: 1.0, unit: '' },
{ id: 2, name: 'op1_level', label: 'Op1 Level', min: 0, max: 1, default: 1.0, unit: '' },
{ id: 3, name: 'op2_ratio', label: 'Op2 Ratio', min: 0.25, max: 16, default: 2.0, unit: '' },
{ id: 4, name: 'op2_level', label: 'Op2 Level', min: 0, max: 1, default: 0.8, unit: '' },
{ id: 5, name: 'op3_ratio', label: 'Op3 Ratio', min: 0.25, max: 16, default: 3.0, unit: '' },
{ id: 6, name: 'op3_level', label: 'Op3 Level', min: 0, max: 1, default: 0.6, unit: '' },
{ id: 7, name: 'op4_ratio', label: 'Op4 Ratio', min: 0.25, max: 16, default: 4.0, unit: '' },
{ id: 8, name: 'op4_level', label: 'Op4 Level', min: 0, max: 1, default: 0.4, unit: '' }
],
getHTML: (nodeId) => `
<div class="node-content">
<div class="node-title">FM Synth</div>
<div class="node-param">
<label>Algorithm: <span id="fmalgo-${nodeId}">0</span></label>
<select data-node="${nodeId}" data-param="0" style="width: 100%; padding: 2px;">
<option value="0">Stack (1→2→3→4)</option>
<option value="1">Parallel</option>
<option value="2">Bell (1→2, 3→4)</option>
<option value="3">Dual (1→2, 3→4)</option>
</select>
</div>
<div style="font-size: 10px; margin-top: 4px; font-weight: bold;">Operator 1</div>
<div class="node-param">
<label>Ratio: <span id="op1ratio-${nodeId}">1.0</span></label>
<input type="range" data-node="${nodeId}" data-param="1" min="0.25" max="16" value="1.0" step="0.25">
</div>
<div class="node-param">
<label>Level: <span id="op1level-${nodeId}">1.0</span></label>
<input type="range" data-node="${nodeId}" data-param="2" min="0" max="1" value="1.0" step="0.01">
</div>
<div style="font-size: 10px; margin-top: 4px; font-weight: bold;">Operator 2</div>
<div class="node-param">
<label>Ratio: <span id="op2ratio-${nodeId}">2.0</span></label>
<input type="range" data-node="${nodeId}" data-param="3" min="0.25" max="16" value="2.0" step="0.25">
</div>
<div class="node-param">
<label>Level: <span id="op2level-${nodeId}">0.8</span></label>
<input type="range" data-node="${nodeId}" data-param="4" min="0" max="1" value="0.8" step="0.01">
</div>
<div style="font-size: 10px; margin-top: 4px; font-weight: bold;">Operator 3</div>
<div class="node-param">
<label>Ratio: <span id="op3ratio-${nodeId}">3.0</span></label>
<input type="range" data-node="${nodeId}" data-param="5" min="0.25" max="16" value="3.0" step="0.25">
</div>
<div class="node-param">
<label>Level: <span id="op3level-${nodeId}">0.6</span></label>
<input type="range" data-node="${nodeId}" data-param="6" min="0" max="1" value="0.6" step="0.01">
</div>
<div style="font-size: 10px; margin-top: 4px; font-weight: bold;">Operator 4</div>
<div class="node-param">
<label>Ratio: <span id="op4ratio-${nodeId}">4.0</span></label>
<input type="range" data-node="${nodeId}" data-param="7" min="0.25" max="16" value="4.0" step="0.25">
</div>
<div class="node-param">
<label>Level: <span id="op4level-${nodeId}">0.4</span></label>
<input type="range" data-node="${nodeId}" data-param="8" min="0" max="1" value="0.4" step="0.01">
</div>
</div>
`
},
WavetableOscillator: {
name: 'Wavetable',
category: NodeCategory.GENERATOR,
description: 'Wavetable oscillator with preset waveforms',
inputs: [
{ name: 'V/Oct', type: SignalType.CV, index: 0 }
],
outputs: [
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
],
parameters: [
{ id: 0, name: 'wavetable', label: 'Wavetable', min: 0, max: 7, default: 0, unit: '' },
{ id: 1, name: 'fine_tune', label: 'Fine Tune', min: -1, max: 1, default: 0, unit: '' },
{ id: 2, name: 'position', label: 'Position', min: 0, max: 1, default: 0, unit: '' }
],
getHTML: (nodeId) => `
<div class="node-content">
<div class="node-title">Wavetable</div>
<div class="node-param">
<label>Waveform: <span id="wavetable-${nodeId}">Sine</span></label>
<select data-node="${nodeId}" data-param="0" style="width: 100%; padding: 2px;">
<option value="0">Sine</option>
<option value="1">Saw</option>
<option value="2">Square</option>
<option value="3">Triangle</option>
<option value="4">PWM</option>
<option value="5">Harmonic</option>
<option value="6">Inharmonic</option>
<option value="7">Digital</option>
</select>
</div>
<div class="node-param">
<label>Fine: <span id="finetune-${nodeId}">0.00</span></label>
<input type="range" data-node="${nodeId}" data-param="1" min="-1" max="1" value="0" step="0.01">
</div>
<div class="node-param">
<label>Position: <span id="position-${nodeId}">0.00</span></label>
<input type="range" data-node="${nodeId}" data-param="2" min="0" max="1" value="0" step="0.01">
</div>
</div>
`
},
SimpleSampler: {
name: 'Sampler',
category: NodeCategory.GENERATOR,
description: 'Simple sample playback with pitch shifting',
inputs: [
{ name: 'V/Oct', type: SignalType.CV, index: 0 },
{ name: 'Gate', type: SignalType.CV, index: 1 }
],
outputs: [
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
],
parameters: [
{ id: 0, name: 'gain', label: 'Gain', min: 0, max: 2, default: 1.0, unit: '' },
{ id: 1, name: 'loop', label: 'Loop', min: 0, max: 1, default: 0, unit: '' },
{ id: 2, name: 'pitch_shift', label: 'Pitch Shift', min: -12, max: 12, default: 0, unit: 'semi' }
],
getHTML: (nodeId) => `
<div class="node-content">
<div class="node-title">Sampler</div>
<div class="node-param">
<label>Gain: <span id="gain-${nodeId}">1.00</span></label>
<input type="range" data-node="${nodeId}" data-param="0" min="0" max="2" value="1.0" step="0.01">
</div>
<div class="node-param">
<label>Loop: <span id="loop-${nodeId}">Off</span></label>
<input type="checkbox" class="node-checkbox" data-node="${nodeId}" data-param="1">
</div>
<div class="node-param">
<label>Pitch: <span id="pitch-${nodeId}">0</span> semi</label>
<input type="range" data-node="${nodeId}" data-param="2" min="-12" max="12" value="0" step="1">
</div>
<div class="node-param" style="margin-top: 4px;">
<button class="load-sample-btn" data-node="${nodeId}" style="width: 100%; padding: 4px; font-size: 10px;">Load Sample</button>
</div>
<div id="sample-info-${nodeId}" style="font-size: 9px; color: #888; margin-top: 2px; text-align: center;">No sample loaded</div>
</div>
`
},
MultiSampler: {
name: 'Multi Sampler',
category: NodeCategory.GENERATOR,
description: 'Multi-sample instrument with velocity layers and key zones',
inputs: [
{ name: 'MIDI In', type: SignalType.MIDI, index: 0 }
],
outputs: [
{ name: 'Audio Out', type: SignalType.AUDIO, index: 0 }
],
parameters: [
{ id: 0, name: 'gain', label: 'Gain', min: 0, max: 2, default: 1.0, unit: '' },
{ id: 1, name: 'attack', label: 'Attack', min: 0.001, max: 1, default: 0.01, unit: 's' },
{ id: 2, name: 'release', label: 'Release', min: 0.01, max: 5, default: 0.1, unit: 's' },
{ id: 3, name: 'transpose', label: 'Transpose', min: -24, max: 24, default: 0, unit: 'semi' }
],
getHTML: (nodeId) => `
<div class="node-content">
<div class="node-title">Multi Sampler</div>
<div class="node-param">
<label>Gain: <span id="gain-${nodeId}">1.00</span></label>
<input type="range" data-node="${nodeId}" data-param="0" min="0" max="2" value="1.0" step="0.01">
</div>
<div class="node-param">
<label>Attack: <span id="attack-${nodeId}">0.01</span>s</label>
<input type="range" data-node="${nodeId}" data-param="1" min="0.001" max="1" value="0.01" step="0.001">
</div>
<div class="node-param">
<label>Release: <span id="release-${nodeId}">0.10</span>s</label>
<input type="range" data-node="${nodeId}" data-param="2" min="0.01" max="5" value="0.1" step="0.01">
</div>
<div class="node-param">
<label>Transpose: <span id="transpose-${nodeId}">0</span> semi</label>
<input type="range" data-node="${nodeId}" data-param="3" min="-24" max="24" value="0" step="1">
</div>
<div class="node-param" style="margin-top: 4px;">
<button class="add-layer-btn" data-node="${nodeId}" style="width: 100%; padding: 4px; font-size: 10px;">Add Sample Layer</button>
</div>
<div id="sample-layers-container-${nodeId}" class="sample-layers-container">
<table id="sample-layers-table-${nodeId}" class="sample-layers-table">
<thead>
<tr>
<th>File</th>
<th>Range</th>
<th>Root</th>
<th>Vel</th>
<th></th>
</tr>
</thead>
<tbody id="sample-layers-list-${nodeId}">
<tr><td colspan="5" class="sample-layers-empty">No layers loaded</td></tr>
</tbody>
</table>
</div>
</div>
`
+229
View File
@@ -0,0 +1,229 @@
const { basename, dirname, join } = window.__TAURI__.path;
let startScreenContainer;
let onProjectStartCallback;
/**
* Creates the start screen UI
* @param {Function} callback - Called when user selects a project type or opens a file
* callback receives: { type: 'new'|'reopen'|'recent', projectFocus?: string, filePath?: string, width?: number, height?: number, fps?: number }
*/
export function createStartScreen(callback) {
onProjectStartCallback = callback;
startScreenContainer = document.createElement('div');
startScreenContainer.id = 'startScreen';
startScreenContainer.className = 'start-screen';
// Create welcome title
const title = document.createElement('h1');
title.textContent = 'Welcome to Lightningbeam!';
title.className = 'start-screen-title';
startScreenContainer.appendChild(title);
// Create main content container
const contentContainer = document.createElement('div');
contentContainer.className = 'start-screen-content';
startScreenContainer.appendChild(contentContainer);
// Left panel - Recent files
const leftPanel = createLeftPanel();
contentContainer.appendChild(leftPanel);
// Right panel - New project
const rightPanel = createRightPanel();
contentContainer.appendChild(rightPanel);
document.body.appendChild(startScreenContainer);
}
function createLeftPanel() {
const leftPanel = document.createElement('div');
leftPanel.className = 'start-screen-left-panel';
// Reopen last session section
const reopenSection = document.createElement('div');
reopenSection.className = 'start-screen-section';
const reopenTitle = document.createElement('h3');
reopenTitle.textContent = 'Reopen last session';
reopenTitle.className = 'start-screen-section-title';
reopenSection.appendChild(reopenTitle);
const lastSessionDiv = document.createElement('div');
lastSessionDiv.id = 'lastSessionFile';
lastSessionDiv.className = 'start-screen-file-item';
lastSessionDiv.textContent = 'No recent session';
reopenSection.appendChild(lastSessionDiv);
leftPanel.appendChild(reopenSection);
// Recent projects section
const recentSection = document.createElement('div');
recentSection.className = 'start-screen-section';
const recentTitle = document.createElement('h3');
recentTitle.textContent = 'Recent projects';
recentTitle.className = 'start-screen-section-title';
recentSection.appendChild(recentTitle);
const recentList = document.createElement('ul');
recentList.id = 'recentProjectsList';
recentList.className = 'start-screen-recent-list';
recentSection.appendChild(recentList);
leftPanel.appendChild(recentSection);
return leftPanel;
}
function createRightPanel() {
const rightPanel = document.createElement('div');
rightPanel.className = 'start-screen-right-panel';
const heading = document.createElement('h2');
heading.textContent = 'Create a new project';
heading.className = 'start-screen-heading';
rightPanel.appendChild(heading);
// Project focus options container
const focusContainer = document.createElement('div');
focusContainer.className = 'start-screen-focus-grid';
const focusTypes = [
{
name: 'Animation',
value: 'animation',
iconSvg: '<svg width="80" height="80" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><path d="M20,80 Q30,60 50,50 T80,20" stroke="currentColor" stroke-width="4" fill="none" stroke-linecap="round"/><circle cx="30" cy="70" r="8" fill="currentColor"/></svg>',
description: 'Drawing tools and timeline'
},
{
name: 'Music',
value: 'audioDaw',
iconSvg: '<svg width="80" height="80" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><rect x="10" y="20" width="18" height="60" fill="none" stroke="currentColor" stroke-width="3"/><rect x="30" y="20" width="18" height="60" fill="none" stroke="currentColor" stroke-width="3"/><rect x="50" y="20" width="18" height="60" fill="none" stroke="currentColor" stroke-width="3"/><rect x="70" y="20" width="18" height="60" fill="none" stroke="currentColor" stroke-width="3"/><rect x="24" y="20" width="12" height="35" fill="currentColor"/><rect x="44" y="20" width="12" height="35" fill="currentColor"/><rect x="74" y="20" width="12" height="35" fill="currentColor"/></svg>',
description: 'Audio tracks and mixer'
},
{
name: 'Video editing',
value: 'videoEditing',
iconSvg: '<svg width="80" height="80" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><rect x="15" y="40" width="70" height="45" fill="currentColor" rx="4"/><rect x="15" y="25" width="70" height="15" fill="none" stroke="currentColor" stroke-width="3" rx="4"/><rect x="20" y="25" width="7" height="15" fill="currentColor"/><rect x="35" y="25" width="7" height="15" fill="currentColor"/><rect x="50" y="25" width="7" height="15" fill="currentColor"/><rect x="65" y="25" width="7" height="15" fill="currentColor"/></svg>',
description: 'Clip timeline and effects'
}
];
focusTypes.forEach(focus => {
const focusCard = createFocusCard(focus);
focusContainer.appendChild(focusCard);
});
rightPanel.appendChild(focusContainer);
return rightPanel;
}
function createFocusCard(focus) {
const card = document.createElement('div');
card.className = 'focus-card';
// Icon container
const iconContainer = document.createElement('div');
iconContainer.className = 'focus-card-icon-container';
const iconWrapper = document.createElement('div');
iconWrapper.className = 'focus-card-icon';
iconWrapper.innerHTML = focus.iconSvg;
iconContainer.appendChild(iconWrapper);
card.appendChild(iconContainer);
// Label
const label = document.createElement('div');
label.textContent = focus.name;
label.className = 'focus-card-label';
card.appendChild(label);
// Click handler
card.addEventListener('click', () => {
onProjectStartCallback({
type: 'new',
projectFocus: focus.value,
width: 800,
height: 600,
fps: 24
});
});
return card;
}
/**
* Updates the recent files list and last session
*/
export async function updateStartScreen(config) {
if (!startScreenContainer) return;
// Update last session
const lastSessionDiv = document.getElementById('lastSessionFile');
if (lastSessionDiv) {
if (config.recentFiles && config.recentFiles.length > 0) {
const lastFile = config.recentFiles[0];
const filename = await basename(lastFile);
lastSessionDiv.textContent = filename;
lastSessionDiv.onclick = () => {
onProjectStartCallback({
type: 'reopen',
filePath: lastFile
});
};
lastSessionDiv.classList.add('clickable');
} else {
lastSessionDiv.textContent = 'No recent session';
lastSessionDiv.classList.remove('clickable');
lastSessionDiv.onclick = null;
}
}
// Update recent projects list
const recentList = document.getElementById('recentProjectsList');
if (recentList) {
recentList.innerHTML = '';
if (config.recentFiles && config.recentFiles.length > 1) {
// Show up to 4 recent files (excluding the most recent which is shown as last session)
const recentFiles = config.recentFiles.slice(1, 5);
for (const filePath of recentFiles) {
const filename = await basename(filePath);
const listItem = document.createElement('li');
listItem.textContent = filename;
listItem.className = 'start-screen-file-item clickable';
listItem.onclick = () => {
onProjectStartCallback({
type: 'recent',
filePath: filePath
});
};
recentList.appendChild(listItem);
}
}
}
}
/**
* Shows the start screen
*/
export function showStartScreen() {
if (startScreenContainer) {
startScreenContainer.style.display = 'flex';
}
}
/**
* Hides the start screen
*/
export function hideStartScreen() {
if (startScreenContainer) {
startScreenContainer.style.display = 'none';
}
}
+548 -144
View File
File diff suppressed because it is too large Load Diff