Record audio
This commit is contained in:
@@ -250,6 +250,10 @@ impl Action for AddClipInstanceAction {
|
||||
_ => Err("Unexpected query response".to_string()),
|
||||
}
|
||||
}
|
||||
AudioClipType::Recording => {
|
||||
// Recording clips are not synced to backend until finalized
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -250,6 +250,9 @@ impl Action for MoveClipInstancesAction {
|
||||
_ => return Err("Expected audio instance ID for sampled clip".to_string()),
|
||||
}
|
||||
}
|
||||
AudioClipType::Recording => {
|
||||
// Recording clips cannot be moved - skip
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,6 +320,9 @@ impl Action for MoveClipInstancesAction {
|
||||
_ => return Err("Expected audio instance ID for sampled clip".to_string()),
|
||||
}
|
||||
}
|
||||
AudioClipType::Recording => {
|
||||
// Recording clips cannot be moved - skip
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,6 +443,10 @@ impl Action for SplitClipInstanceAction {
|
||||
_ => Err("Unexpected query response".to_string()),
|
||||
}
|
||||
}
|
||||
AudioClipType::Recording => {
|
||||
// Recording clips cannot be split
|
||||
Err("Cannot split a clip that is currently recording".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,6 +496,9 @@ impl Action for SplitClipInstanceAction {
|
||||
controller.trim_clip(track_id, *orig_backend_id, orig_internal_start, orig_internal_end);
|
||||
}
|
||||
}
|
||||
AudioClipType::Recording => {
|
||||
// Recording clips - nothing to rollback
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,6 +404,9 @@ impl Action for TrimClipInstancesAction {
|
||||
_ => return Err("Expected audio instance ID for sampled clip".to_string()),
|
||||
}
|
||||
}
|
||||
AudioClipType::Recording => {
|
||||
// Recording clips cannot be trimmed - skip
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -481,6 +484,9 @@ impl Action for TrimClipInstancesAction {
|
||||
_ => return Err("Expected audio instance ID for sampled clip".to_string()),
|
||||
}
|
||||
}
|
||||
AudioClipType::Recording => {
|
||||
// Recording clips cannot be trimmed - skip
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,6 +362,11 @@ pub enum AudioClipType {
|
||||
/// This allows sharing MIDI data between multiple clip instances
|
||||
midi_clip_id: u32,
|
||||
},
|
||||
/// Recording in progress
|
||||
///
|
||||
/// Placeholder for a clip that is currently being recorded.
|
||||
/// The audio_pool_index will be assigned when recording stops.
|
||||
Recording,
|
||||
}
|
||||
|
||||
/// Audio clip
|
||||
@@ -426,6 +431,38 @@ impl AudioClip {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new recording-in-progress clip
|
||||
///
|
||||
/// This is a placeholder clip for audio currently being recorded.
|
||||
/// Call `finalize_recording` when recording stops to set the pool index.
|
||||
pub fn new_recording(name: impl Into<String>) -> Self {
|
||||
Self {
|
||||
id: Uuid::new_v4(),
|
||||
name: name.into(),
|
||||
duration: 0.0, // Will be updated as recording progresses
|
||||
clip_type: AudioClipType::Recording,
|
||||
folder_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Finalize a recording clip with the actual audio pool index and duration
|
||||
///
|
||||
/// Returns true if the clip was a Recording type and was successfully finalized.
|
||||
pub fn finalize_recording(&mut self, audio_pool_index: usize, duration: f64) -> bool {
|
||||
if matches!(self.clip_type, AudioClipType::Recording) {
|
||||
self.clip_type = AudioClipType::Sampled { audio_pool_index };
|
||||
self.duration = duration;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if this clip is a recording in progress
|
||||
pub fn is_recording(&self) -> bool {
|
||||
matches!(self.clip_type, AudioClipType::Recording)
|
||||
}
|
||||
|
||||
/// Get the audio pool index if this is a sampled audio clip
|
||||
pub fn audio_pool_index(&self) -> Option<usize> {
|
||||
match &self.clip_type {
|
||||
|
||||
Reference in New Issue
Block a user