-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#715 Make realearn_timestamp sample-accurate for MIDI events
- calculate timestamp based on audio callbacks - respect the frame offset for MIDI events
- Loading branch information
Showing
16 changed files
with
178 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule helgoboss-learn
updated
4 files
+1 −12 | src/base/control_value.rs | |
+9 −0 | src/base/unit.rs | |
+5 −5 | src/mode/mode_struct.rs | |
+1 −1 | src/mode/transformation.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::sync::atomic::{AtomicU32, AtomicU64, Ordering}; | ||
|
||
use atomic::Atomic; | ||
use reaper_medium::Hz; | ||
use static_assertions::const_assert; | ||
|
||
use crate::domain::AudioBlockProps; | ||
|
||
pub static GLOBAL_AUDIO_STATE: GlobalAudioState = GlobalAudioState::new(); | ||
|
||
#[derive(Debug)] | ||
pub struct GlobalAudioState { | ||
block_count: AtomicU64, | ||
block_size: AtomicU32, | ||
sample_rate: Atomic<f64>, | ||
} | ||
|
||
impl Default for GlobalAudioState { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl GlobalAudioState { | ||
pub const fn new() -> Self { | ||
const_assert!(Atomic::<f64>::is_lock_free()); | ||
Self { | ||
block_count: AtomicU64::new(0), | ||
block_size: AtomicU32::new(0), | ||
sample_rate: Atomic::new(1.0), | ||
} | ||
} | ||
|
||
/// Returns previous block count | ||
pub fn advance(&self, block_props: AudioBlockProps) -> u64 { | ||
let prev_block_count = self.block_count.fetch_add(1, Ordering::Relaxed); | ||
self.block_size | ||
.store(block_props.block_length as u32, Ordering::Relaxed); | ||
self.sample_rate | ||
.store(block_props.frame_rate.get(), Ordering::Relaxed); | ||
prev_block_count | ||
} | ||
|
||
pub fn load_block_count(&self) -> u64 { | ||
self.block_count.load(Ordering::Relaxed) | ||
} | ||
|
||
pub fn load_block_size(&self) -> u32 { | ||
self.block_size.load(Ordering::Relaxed) | ||
} | ||
|
||
pub fn load_sample_rate(&self) -> Hz { | ||
Hz::new_panic(self.sample_rate.load(Ordering::Relaxed)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,3 +170,6 @@ mod playtime_util; | |
|
||
mod hex; | ||
pub use hex::*; | ||
|
||
mod global_audio_state; | ||
pub use global_audio_state::*; |
Oops, something went wrong.