mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
record sample (y no playback?)
This commit is contained in:
parent
ae3099847a
commit
97920d7063
3 changed files with 31 additions and 12 deletions
2
Justfile
2
Justfile
|
|
@ -80,7 +80,7 @@ groovebox-release-ext:
|
||||||
-l "Komplete Audio 6 Pro:capture_AUX1" \
|
-l "Komplete Audio 6 Pro:capture_AUX1" \
|
||||||
-r "Komplete Audio 6 Pro:capture_AUX1" \
|
-r "Komplete Audio 6 Pro:capture_AUX1" \
|
||||||
-L "Komplete Audio 6 Pro:playback_AUX1" \
|
-L "Komplete Audio 6 Pro:playback_AUX1" \
|
||||||
-R "Komplete Audio 6 Pro:playback_AUX1"
|
-R "Komplete Audio 6 Pro:playback_AUX2"
|
||||||
|
|
||||||
sequencer:
|
sequencer:
|
||||||
reset
|
reset
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ render!(<Tui>|self: GrooveboxSamples<'a>|{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Tui::bg(bg, if let Some(sample) = &self.0.sampler.mapped[note] {
|
Tui::bg(bg, if let Some(sample) = &self.0.sampler.mapped[note] {
|
||||||
todo!()
|
Tui::fg(fg, format!("{note:3} ????? "))
|
||||||
} else {
|
} else {
|
||||||
Tui::fg(fg, format!("{note:3} (none) "))
|
Tui::fg(fg, format!("{note:3} (none) "))
|
||||||
})
|
})
|
||||||
|
|
@ -153,9 +153,11 @@ input_to_command!(GrooveboxCommand: <Tui>|state: GrooveboxTui, input|match input
|
||||||
// 0: Enqueue phrase 0 (stop all)
|
// 0: Enqueue phrase 0 (stop all)
|
||||||
key_pat!(Char('0')) => Enqueue(Some(state.pool.phrases()[0].clone())),
|
key_pat!(Char('0')) => Enqueue(Some(state.pool.phrases()[0].clone())),
|
||||||
|
|
||||||
key_pat!(Shift-Char('R')) => Sampler(
|
key_pat!(Shift-Char('R')) => Sampler(if state.sampler.recording.is_some() {
|
||||||
|
SamplerCommand::RecordFinish
|
||||||
|
} else {
|
||||||
SamplerCommand::RecordBegin(u7::from(state.editor.note_point() as u8))
|
SamplerCommand::RecordBegin(u7::from(state.editor.note_point() as u8))
|
||||||
),
|
}),
|
||||||
|
|
||||||
// e: Toggle between editing currently playing or other phrase
|
// e: Toggle between editing currently playing or other phrase
|
||||||
key_pat!(Char('e')) => if let Some((_, Some(playing))) = state.player.play_phrase() {
|
key_pat!(Char('e')) => if let Some((_, Some(playing))) = state.player.play_phrase() {
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,33 @@ audio!(|self: SamplerAudio<'a>, _client, scope|{
|
||||||
self.0.clear_output_buffer();
|
self.0.clear_output_buffer();
|
||||||
self.0.process_audio_out(scope);
|
self.0.process_audio_out(scope);
|
||||||
self.0.write_output_buffer(scope);
|
self.0.write_output_buffer(scope);
|
||||||
self.0.update_input_meter(scope);
|
self.0.process_audio_in(scope);
|
||||||
Control::Continue
|
Control::Continue
|
||||||
});
|
});
|
||||||
|
|
||||||
impl Sampler {
|
impl Sampler {
|
||||||
|
|
||||||
pub fn update_input_meter (&mut self, scope: &ProcessScope) {
|
pub fn process_audio_in (&mut self, scope: &ProcessScope) {
|
||||||
let Sampler { audio_ins, input_meter, .. } = self;
|
let Sampler { audio_ins, input_meter, recording, .. } = self;
|
||||||
if audio_ins.len() != input_meter.len() {
|
if audio_ins.len() != input_meter.len() {
|
||||||
*input_meter = vec![0.0;audio_ins.len()];
|
*input_meter = vec![0.0;audio_ins.len()];
|
||||||
}
|
}
|
||||||
|
if let Some((_, sample)) = recording {
|
||||||
|
if sample.channels.len() != audio_ins.len() {
|
||||||
|
panic!("channel count mismatch");
|
||||||
|
}
|
||||||
|
let iterator = audio_ins.iter().zip(input_meter).zip(sample.channels.iter_mut());
|
||||||
|
let mut length = 0;
|
||||||
|
for ((input, meter), channel) in iterator {
|
||||||
|
let slice = input.as_slice(scope);
|
||||||
|
length = length.max(slice.len());
|
||||||
|
let total: f32 = slice.iter().map(|x|x.abs()).sum();
|
||||||
|
let count = slice.len() as f32;
|
||||||
|
*meter = 10. * (total / count).log10();
|
||||||
|
channel.extend_from_slice(slice);
|
||||||
|
}
|
||||||
|
sample.end += length;
|
||||||
|
} else {
|
||||||
for (input, meter) in audio_ins.iter().zip(input_meter) {
|
for (input, meter) in audio_ins.iter().zip(input_meter) {
|
||||||
let slice = input.as_slice(scope);
|
let slice = input.as_slice(scope);
|
||||||
let total: f32 = slice.iter().map(|x|x.abs()).sum();
|
let total: f32 = slice.iter().map(|x|x.abs()).sum();
|
||||||
|
|
@ -29,6 +45,7 @@ impl Sampler {
|
||||||
*meter = 10. * (total / count).log10();
|
*meter = 10. * (total / count).log10();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Create [Voice]s from [Sample]s in response to MIDI input.
|
/// Create [Voice]s from [Sample]s in response to MIDI input.
|
||||||
pub fn process_midi_in (&mut self, scope: &ProcessScope) {
|
pub fn process_midi_in (&mut self, scope: &ProcessScope) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue