-
-
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.
- Loading branch information
Showing
7 changed files
with
72 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,5 @@ mod trafficker; | |
pub use trafficker::*; | ||
|
||
pub mod validation_util; | ||
|
||
pub mod peak_util; |
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,38 @@ | ||
use either::Either; | ||
use reaper_high::{Reaper, Track}; | ||
use reaper_medium::{MediaTrack, ReaperVolumeValue, SoloMode, TrackAttributeKey}; | ||
use std::iter; | ||
|
||
/// Returns whether the peaks should better be hidden even they are available. | ||
/// | ||
/// This is for the case if another track is soloed, reporting the peak would be misleading then. | ||
pub fn peaks_should_be_hidden(track: &Track) -> bool { | ||
let is_master = track.is_master_track(); | ||
(is_master && track.is_muted()) | ||
|| (!is_master && track.project().any_solo() && track.solo_mode() == SoloMode::Off) | ||
} | ||
|
||
/// Returns the track's peaks as iterator. | ||
/// | ||
/// This takes VU mode / channel count intricacies into account. It returns peaks even if another | ||
/// track is soloed! See [`peaks_should_be_hidden`]. | ||
pub fn get_track_peaks( | ||
track: MediaTrack, | ||
) -> impl Iterator<Item = ReaperVolumeValue> + ExactSizeIterator<Item = ReaperVolumeValue> { | ||
let reaper = Reaper::get().medium_reaper(); | ||
let vu_mode = | ||
unsafe { reaper.get_media_track_info_value(track, TrackAttributeKey::VuMode) as i32 }; | ||
let channel_count = if matches!(vu_mode, 2 | 8) { | ||
// These VU modes have multi-channel support. | ||
unsafe { reaper.get_media_track_info_value(track, TrackAttributeKey::Nchan) as i32 } | ||
} else { | ||
// Other VU modes always use stereo. | ||
2 | ||
}; | ||
if channel_count <= 0 { | ||
return Either::Left(iter::empty()); | ||
} | ||
let iter = | ||
(0..channel_count).map(move |ch| unsafe { reaper.track_get_peak_info(track, ch as u32) }); | ||
Either::Right(iter) | ||
} |
Submodule helgoboss-license-processor
updated
from dd0a7d to 894ed4
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 playtime-clip-engine
updated
from 3125f7 to d303ec