add BPM detection

This commit is contained in:
Skyler Lehmkuhl
2025-11-02 09:53:34 -05:00
parent 66c4746767
commit 9702a501bd
11 changed files with 684 additions and 15 deletions
+31
View File
@@ -536,6 +536,37 @@ export const actions = {
if (context.timelineWidget) {
context.timelineWidget.requestRedraw();
}
// Make this the active track
if (context.activeObject) {
context.activeObject.activeLayer = newAudioTrack;
updateLayers(); // Refresh to show active state
// Reload node editor to show the new track's graph
if (context.reloadNodeEditor) {
await context.reloadNodeEditor();
}
}
// Prompt user to set BPM if detected
if (metadata.detected_bpm && context.timelineWidget) {
const currentBpm = context.timelineWidget.timelineState.bpm;
const detectedBpm = metadata.detected_bpm;
const shouldSetBpm = confirm(
`Detected BPM: ${detectedBpm}\n\n` +
`Current project BPM: ${currentBpm}\n\n` +
`Would you like to set the project BPM to ${detectedBpm}?`
);
if (shouldSetBpm) {
context.timelineWidget.timelineState.bpm = detectedBpm;
context.timelineWidget.requestRedraw(); // Redraw to show updated BPM
console.log(`Project BPM set to ${detectedBpm}`);
// Notify all registered listeners of BPM change
if (context.notifyBpmChange) {
context.notifyBpmChange(detectedBpm);
}
}
}
} catch (error) {
console.error('Failed to load audio:', error);
// Update clip to show error