mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
bye sequencer
This commit is contained in:
parent
2165e5d45d
commit
316fe45b2a
12 changed files with 510 additions and 759 deletions
65
src/main.rs
65
src/main.rs
|
|
@ -24,26 +24,24 @@ pub fn main () -> Usually<()> {
|
|||
state.modal = Some(Box::new(crate::config::SetupModal(Some(xdg.clone()))));
|
||||
}
|
||||
state.scenes = vec![
|
||||
Scene::new("Intro", vec![Some(0), Some(0), None, None]),
|
||||
Scene::new("Intro", vec![None, Some(0), None, None]),
|
||||
Scene::new("Hook", vec![Some(0), Some(0), None, None]),
|
||||
];
|
||||
let jack = jack_run("tek", &app)?;
|
||||
let timebase = &state.timebase;
|
||||
let ppq = timebase.ppq() as usize;
|
||||
state.tracks = vec![
|
||||
|
||||
Track::new("Drums", &jack.as_client(), &timebase, Some(vec![
|
||||
|
||||
Track::new("Drums", &jack.as_client(), Some(vec![
|
||||
Sampler::new("Sampler", Some(BTreeMap::from([
|
||||
sample!(36, "Kick", "/home/user/Lab/Music/pak/kik.wav"),
|
||||
sample!(40, "Snare", "/home/user/Lab/Music/pak/sna.wav"),
|
||||
sample!(44, "Hihat", "/home/user/Lab/Music/pak/chh.wav"),
|
||||
])))?.boxed(),
|
||||
|
||||
Plugin::lv2(
|
||||
"Panagement",
|
||||
"file:///home/user/.lv2/Auburn Sounds Panagement 2.lv2"
|
||||
)?.boxed(),
|
||||
|
||||
]), Some(vec![
|
||||
Phrase::new("4 kicks", ppq * 4, Some(phrase! {
|
||||
00 * ppq/4 => MidiMessage::NoteOn { key: 36.into(), vel: 100.into() },
|
||||
|
|
@ -53,7 +51,8 @@ pub fn main () -> Usually<()> {
|
|||
})),
|
||||
]))?,
|
||||
|
||||
Track::new("Bass", &jack.as_client(), &timebase, Some(vec![
|
||||
Track::new("Bass", &jack.as_client(), Some(vec![
|
||||
Plugin::lv2("Odin2", "file:///home/user/.lv2/Odin2.lv2")?.boxed(),
|
||||
]), Some(vec![
|
||||
Phrase::new("Offbeat", ppq * 4, Some(phrase! {
|
||||
00 * ppq/4 => MidiMessage::NoteOff { key: 40.into(), vel: 100.into() },
|
||||
|
|
@ -66,6 +65,7 @@ pub fn main () -> Usually<()> {
|
|||
14 * ppq/4 => MidiMessage::NoteOn { key: 40.into(), vel: 100.into() },
|
||||
})),
|
||||
]))?,
|
||||
|
||||
];
|
||||
state.track_cursor = 1;
|
||||
state.scene_cursor = 1;
|
||||
|
|
@ -100,14 +100,57 @@ pub struct App {
|
|||
pub midi_in: Option<Port<MidiIn>>,
|
||||
pub audio_outs: Option<Vec<Port<AudioOut>>>,
|
||||
pub metronome: bool,
|
||||
/// Range of notes to display
|
||||
pub note_start: usize,
|
||||
/// Position of cursor within note range
|
||||
pub note_cursor: usize,
|
||||
/// PPQ per display unit
|
||||
pub time_zoom: usize,
|
||||
/// Range of time steps to display
|
||||
pub time_start: usize,
|
||||
/// Position of cursor within time range
|
||||
pub time_cursor: usize,
|
||||
}
|
||||
|
||||
process!(App |self, client, scope| {
|
||||
let transport = self.transport.as_ref().unwrap().query().unwrap();
|
||||
self.playing = Some(transport.state);
|
||||
self.playhead = transport.pos.frame() as usize;
|
||||
for Track { sequencer, .. } in self.tracks.iter_mut() {
|
||||
sequencer.process(client, scope);
|
||||
for Track {
|
||||
sequence, phrases, midi_out, monitoring, recording, ref mut notes_on, ..
|
||||
} in self.tracks.iter_mut() {
|
||||
if sequence.is_none() { continue }
|
||||
let phrase = phrases.get_mut(sequence.unwrap());
|
||||
if phrase.is_none() { continue }
|
||||
let phrase = phrase.unwrap();
|
||||
let frame = scope.last_frame_time() as usize;
|
||||
let frames = scope.n_frames() as usize;
|
||||
let mut output: Vec<Option<Vec<Vec<u8>>>> = vec![None;frames];
|
||||
let transport = self.transport.as_ref().unwrap().query().unwrap();
|
||||
if Some(transport.state) != self.playing {
|
||||
all_notes_off(&mut output);
|
||||
}
|
||||
self.playing = Some(transport.state);
|
||||
// Play from phrase into output buffer
|
||||
if self.playing == Some(TransportState::Rolling) {
|
||||
phrase.process_out(
|
||||
&mut output,
|
||||
notes_on,
|
||||
&self.timebase,
|
||||
frame,
|
||||
frames
|
||||
);
|
||||
}
|
||||
// Play from input to monitor, and record into phrase.
|
||||
phrase.process_in(
|
||||
self.midi_in.as_ref().unwrap().iter(scope),
|
||||
notes_on,
|
||||
if *monitoring { Some(&mut output) } else { None },
|
||||
*recording && self.playing == Some(TransportState::Rolling),
|
||||
&self.timebase,
|
||||
frame,
|
||||
);
|
||||
write_output(&mut midi_out.writer(scope), &mut output, frames);
|
||||
}
|
||||
Control::Continue
|
||||
});
|
||||
|
|
@ -165,12 +208,6 @@ impl App {
|
|||
self.scenes.get_mut(id).map(|t|(id, t))
|
||||
} }
|
||||
}
|
||||
pub fn sequencer (&self) -> Option<&Sequencer> {
|
||||
Some(&self.track()?.1.sequencer)
|
||||
}
|
||||
pub fn sequencer_mut (&mut self) -> Option<&mut Sequencer> {
|
||||
Some(&mut self.track_mut()?.1.sequencer)
|
||||
}
|
||||
pub fn chain (&self) -> Option<&Chain> {
|
||||
Some(&self.track()?.1.chain)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue