mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
use iterator in sampler
This commit is contained in:
parent
81717f17b8
commit
c5369328f4
9 changed files with 175 additions and 120 deletions
60
src/model.rs
60
src/model.rs
|
|
@ -73,32 +73,9 @@ pub struct App {
|
|||
pub quant: usize,
|
||||
}
|
||||
process!(App |self, _client, scope| {
|
||||
self.chunk_size = scope.n_frames() as usize;
|
||||
let CycleTimes {
|
||||
current_frames,
|
||||
current_usecs,
|
||||
next_usecs,
|
||||
period_usecs
|
||||
} = scope.cycle_times().unwrap();
|
||||
let transport = self.transport.as_ref().unwrap().query().unwrap();
|
||||
self.playhead = transport.pos.frame() as usize;
|
||||
let mut reset = false;
|
||||
if self.playing != Some(transport.state) {
|
||||
match transport.state {
|
||||
TransportState::Rolling => {
|
||||
self.play_started = Some((
|
||||
current_frames as usize,
|
||||
current_usecs as usize,
|
||||
));
|
||||
},
|
||||
TransportState::Stopped => {
|
||||
self.play_started = None;
|
||||
reset = true;
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
self.playing = Some(transport.state);
|
||||
let (
|
||||
reset, current_frames, current_usecs, next_usecs, period_usecs
|
||||
) = self.process_update_time(&scope);
|
||||
for track in self.tracks.iter_mut() {
|
||||
track.process(
|
||||
self.midi_in.as_ref().unwrap().iter(scope),
|
||||
|
|
@ -116,6 +93,37 @@ process!(App |self, _client, scope| {
|
|||
Control::Continue
|
||||
});
|
||||
impl App {
|
||||
pub fn process_update_time (&mut self, scope: &ProcessScope) -> (bool, usize, usize, usize, f64) {
|
||||
self.chunk_size = scope.n_frames() as usize;
|
||||
let CycleTimes {
|
||||
current_frames,
|
||||
current_usecs,
|
||||
next_usecs,
|
||||
period_usecs
|
||||
} = scope.cycle_times().unwrap();
|
||||
let transport = self.transport.as_ref().unwrap().query().unwrap();
|
||||
self.playhead = transport.pos.frame() as usize;
|
||||
let mut reset = false;
|
||||
if self.playing != Some(transport.state) {
|
||||
match transport.state {
|
||||
TransportState::Rolling => {
|
||||
self.play_started = Some((
|
||||
current_frames as usize,
|
||||
current_usecs as usize,
|
||||
));
|
||||
},
|
||||
TransportState::Stopped => {
|
||||
self.play_started = None;
|
||||
reset = true;
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
self.playing = Some(transport.state);
|
||||
(
|
||||
reset, current_frames as usize, current_usecs as usize, next_usecs as usize, period_usecs as f64
|
||||
)
|
||||
}
|
||||
pub fn client (&self) -> &Client {
|
||||
self.jack.as_ref().unwrap().as_client()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue