Add virtual piano
This commit is contained in:
@@ -534,6 +534,10 @@ impl Engine {
|
||||
// Notify UI about the new MIDI track
|
||||
let _ = self.event_tx.push(AudioEvent::TrackCreated(track_id, false, name));
|
||||
}
|
||||
Command::AddMidiClipToPool(clip) => {
|
||||
// Add the clip to the pool without placing it on any track
|
||||
self.project.midi_clip_pool.add_existing_clip(clip);
|
||||
}
|
||||
Command::CreateMidiClip(track_id, start_time, duration) => {
|
||||
// Get the next MIDI clip ID from the atomic counter
|
||||
let clip_id = self.next_midi_clip_id_atomic.fetch_add(1, Ordering::Relaxed);
|
||||
@@ -2083,6 +2087,12 @@ impl EngineController {
|
||||
let _ = self.command_tx.push(Command::CreateMidiTrack(name));
|
||||
}
|
||||
|
||||
/// Add a MIDI clip to the pool without placing it on any track
|
||||
/// This is useful for importing MIDI files into a clip library
|
||||
pub fn add_midi_clip_to_pool(&mut self, clip: MidiClip) {
|
||||
let _ = self.command_tx.push(Command::AddMidiClipToPool(clip));
|
||||
}
|
||||
|
||||
/// Create a new audio track synchronously (waits for creation to complete)
|
||||
pub fn create_audio_track_sync(&mut self, name: String) -> Result<TrackId, String> {
|
||||
if let Err(_) = self.query_tx.push(Query::CreateAudioTrackSync(name)) {
|
||||
|
||||
@@ -67,6 +67,8 @@ pub enum Command {
|
||||
// MIDI commands
|
||||
/// Create a new MIDI track with a name
|
||||
CreateMidiTrack(String),
|
||||
/// Add a MIDI clip to the pool without placing it on a track
|
||||
AddMidiClipToPool(MidiClip),
|
||||
/// Create a new MIDI clip on a track (track_id, start_time, duration)
|
||||
CreateMidiClip(TrackId, f64, f64),
|
||||
/// Add a MIDI note to a clip (track_id, clip_id, time_offset, note, velocity, duration)
|
||||
|
||||
Reference in New Issue
Block a user