Fix sampled instrument loading
This commit is contained in:
@@ -1003,6 +1003,8 @@ impl Engine {
|
||||
if let Some(TrackNode::Midi(track)) = self.project.get_track_mut(track_id) {
|
||||
track.instrument_graph = Some(graph);
|
||||
let _ = self.event_tx.push(AudioEvent::GraphStateChanged(track_id));
|
||||
// Emit preset loaded event after everything is loaded
|
||||
let _ = self.event_tx.push(AudioEvent::GraphPresetLoaded(track_id));
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
|
||||
@@ -861,7 +861,9 @@ impl InstrumentGraph {
|
||||
} else if let Some(ref path) = file_path {
|
||||
// Fall back to loading from file (resolve path relative to preset)
|
||||
let resolved_path = resolve_sample_path(path);
|
||||
let _ = sampler_node.load_sample_from_file(&resolved_path);
|
||||
if let Err(e) = sampler_node.load_sample_from_file(&resolved_path) {
|
||||
eprintln!("Failed to load sample from {}: {}", resolved_path, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -901,14 +903,16 @@ impl InstrumentGraph {
|
||||
} else if let Some(ref path) = layer.file_path {
|
||||
// Fall back to loading from file (resolve path relative to preset)
|
||||
let resolved_path = resolve_sample_path(path);
|
||||
let _ = multi_sampler_node.load_layer_from_file(
|
||||
if let Err(e) = multi_sampler_node.load_layer_from_file(
|
||||
&resolved_path,
|
||||
layer.key_min,
|
||||
layer.key_max,
|
||||
layer.root_key,
|
||||
layer.velocity_min,
|
||||
layer.velocity_max,
|
||||
);
|
||||
) {
|
||||
eprintln!("Failed to load sample layer from {}: {}", resolved_path, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +196,8 @@ pub enum AudioEvent {
|
||||
GraphConnectionError(TrackId, String),
|
||||
/// Graph state changed (for full UI sync)
|
||||
GraphStateChanged(TrackId),
|
||||
/// Preset fully loaded (track_id) - emitted after all nodes and samples are loaded
|
||||
GraphPresetLoaded(TrackId),
|
||||
}
|
||||
|
||||
/// Synchronous queries sent from UI thread to audio thread
|
||||
|
||||
Reference in New Issue
Block a user