mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 13:16:44 +01:00
ui thrashing
This commit is contained in:
parent
acb952736e
commit
20b7267225
18 changed files with 695 additions and 233 deletions
|
|
@ -6,7 +6,7 @@ pub struct Mixer {
|
|||
pub selected_track: usize,
|
||||
pub selected_column: usize,
|
||||
}
|
||||
render!(Mixer = crate::view::mixer::render);
|
||||
//render!(Mixer = crate::view::mixer::render);
|
||||
handle!(Mixer = crate::control::mixer::handle);
|
||||
process!(Mixer = process);
|
||||
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@ impl Sampler {
|
|||
fn process_midi_in (&mut self, scope: &ProcessScope) {
|
||||
for RawMidi { time, bytes } in self.ports.midi_ins.get("midi").unwrap().iter(scope) {
|
||||
if let LiveEvent::Midi { message, .. } = LiveEvent::parse(bytes).unwrap() {
|
||||
if let MidiMessage::NoteOn { ref key, .. } = message {
|
||||
if let MidiMessage::NoteOn { ref key, ref vel } = message {
|
||||
if let Some(sample) = self.samples.get(key) {
|
||||
self.voices.push(sample.play(time as usize));
|
||||
self.voices.push(sample.play(time as usize, vel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -143,11 +143,12 @@ impl Sample {
|
|||
pub fn new (name: &str, start: usize, end: usize, channels: Vec<Vec<f32>>) -> Arc<Self> {
|
||||
Arc::new(Self { name: name.to_string(), start, end, channels })
|
||||
}
|
||||
pub fn play (self: &Arc<Self>, after: usize) -> Voice {
|
||||
pub fn play (self: &Arc<Self>, after: usize, velocity: &u7) -> Voice {
|
||||
Voice {
|
||||
sample: self.clone(),
|
||||
after,
|
||||
position: self.start
|
||||
position: self.start,
|
||||
velocity: velocity.as_int() as f32 / 127.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -156,6 +157,7 @@ pub struct Voice {
|
|||
pub sample: Arc<Sample>,
|
||||
pub after: usize,
|
||||
pub position: usize,
|
||||
pub velocity: f32,
|
||||
}
|
||||
|
||||
const BUFFER: [f32;64] = [0.0f32;64];
|
||||
|
|
@ -171,8 +173,8 @@ impl Iterator for Voice {
|
|||
let position = self.position;
|
||||
self.position = self.position + 1;
|
||||
return Some([
|
||||
self.sample.channels[0][position],
|
||||
self.sample.channels[0][position],
|
||||
self.sample.channels[0][position] * self.velocity,
|
||||
self.sample.channels[0][position] * self.velocity,
|
||||
])
|
||||
}
|
||||
None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue