mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
fix compiler warnings (half)
This commit is contained in:
parent
c51bcbfaa8
commit
7fb9369012
9 changed files with 50 additions and 221 deletions
30
Cargo.lock
generated
30
Cargo.lock
generated
|
|
@ -127,21 +127,6 @@ version = "2.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
|
||||
|
||||
[[package]]
|
||||
name = "bloop"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"better-panic",
|
||||
"clap",
|
||||
"crossterm",
|
||||
"jack",
|
||||
"microxdg",
|
||||
"midly",
|
||||
"ratatui",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cassowary"
|
||||
version = "0.3.0"
|
||||
|
|
@ -737,6 +722,21 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tek"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"better-panic",
|
||||
"clap",
|
||||
"crossterm",
|
||||
"jack",
|
||||
"microxdg",
|
||||
"midly",
|
||||
"ratatui",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.14"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "bloop"
|
||||
name = "tek"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ impl Chain {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn process (state: &mut Chain, client: &Client, scope: &ProcessScope) -> Control {
|
||||
pub fn process (_: &mut Chain, _: &Client, _: &ProcessScope) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
||||
pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
||||
-> Usually<Rect>
|
||||
{
|
||||
let Rect { x, y, width, height } = area;
|
||||
let Rect { x, y, .. } = area;
|
||||
let area = Rect { x, y, width: 40, height: 30 };
|
||||
let mut y = area.y;
|
||||
buf.set_string(area.x, y, "│", Style::default().black());
|
||||
|
|
@ -51,6 +51,6 @@ pub fn render (state: &Chain, buf: &mut Buffer, area: Rect)
|
|||
Ok(Rect { x: area.x, y: area.y, width: x, height: y })
|
||||
}
|
||||
|
||||
pub fn handle (state: &mut Chain, event: &AppEvent) -> Result<(), Box<dyn Error>> {
|
||||
pub fn handle (_: &mut Chain, _: &AppEvent) -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,41 +40,3 @@ pub fn handle (state: &mut Looper, event: &AppEvent) -> Result<(), Box<dyn Error
|
|||
pub const ACTIONS: [(&'static str, &'static str);1] = [
|
||||
("Ins/Del", "Add/remove loop"),
|
||||
];
|
||||
|
||||
pub struct Notifications;
|
||||
|
||||
impl NotificationHandler for Notifications {
|
||||
fn thread_init (&self, _: &Client) {
|
||||
}
|
||||
|
||||
fn shutdown (&mut self, status: ClientStatus, reason: &str) {
|
||||
}
|
||||
|
||||
fn freewheel (&mut self, _: &Client, is_enabled: bool) {
|
||||
}
|
||||
|
||||
fn sample_rate (&mut self, _: &Client, _: Frames) -> Control {
|
||||
Control::Quit
|
||||
}
|
||||
|
||||
fn client_registration (&mut self, _: &Client, name: &str, is_reg: bool) {
|
||||
}
|
||||
|
||||
fn port_registration (&mut self, _: &Client, port_id: PortId, is_reg: bool) {
|
||||
}
|
||||
|
||||
fn port_rename (&mut self, _: &Client, id: PortId, old: &str, new: &str) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
||||
fn ports_connected (&mut self, _: &Client, id_a: PortId, id_b: PortId, are: bool) {
|
||||
}
|
||||
|
||||
fn graph_reorder (&mut self, _: &Client) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
||||
fn xrun (&mut self, _: &Client) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,53 +206,6 @@ impl Track {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct MixerJack;
|
||||
|
||||
impl MixerJack {
|
||||
fn activate <P> (self, client: Client, handler: P) -> Usually<AsyncClient<Self, P>>
|
||||
where P: 'static + Send + ::jack::ProcessHandler
|
||||
{
|
||||
Ok(client.activate_async(self, handler)?)
|
||||
}
|
||||
}
|
||||
|
||||
impl NotificationHandler for MixerJack {
|
||||
fn thread_init (&self, _: &Client) {
|
||||
}
|
||||
|
||||
fn shutdown (&mut self, status: ClientStatus, reason: &str) {
|
||||
}
|
||||
|
||||
fn freewheel (&mut self, _: &Client, is_enabled: bool) {
|
||||
}
|
||||
|
||||
fn sample_rate (&mut self, _: &Client, _: Frames) -> Control {
|
||||
Control::Quit
|
||||
}
|
||||
|
||||
fn client_registration (&mut self, _: &Client, name: &str, is_reg: bool) {
|
||||
}
|
||||
|
||||
fn port_registration (&mut self, _: &Client, port_id: PortId, is_reg: bool) {
|
||||
}
|
||||
|
||||
fn port_rename (&mut self, _: &Client, id: PortId, old: &str, new: &str) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
||||
fn ports_connected (&mut self, _: &Client, id_a: PortId, id_b: PortId, are: bool) {
|
||||
}
|
||||
|
||||
fn graph_reorder (&mut self, _: &Client) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
||||
fn xrun (&mut self, _: &Client) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//impl<W: Write> Input<TUI<W>, bool> for Mixer {
|
||||
//fn handle (&mut self, engine: &mut TUI<W>) -> Result<Option<bool>> {
|
||||
//Ok(None)
|
||||
|
|
|
|||
|
|
@ -211,49 +211,3 @@ pub fn handle (state: &mut Sampler, event: &AppEvent) -> Result<(), Box<dyn Erro
|
|||
//}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub struct SamplerJack;
|
||||
|
||||
impl SamplerJack {
|
||||
fn activate <P> (self, client: Client, handler: P) -> Usually<AsyncClient<Self, P>>
|
||||
where P: 'static + Send + ::jack::ProcessHandler
|
||||
{
|
||||
Ok(client.activate_async(self, handler)?)
|
||||
}
|
||||
}
|
||||
|
||||
impl NotificationHandler for SamplerJack {
|
||||
fn thread_init (&self, _: &Client) {
|
||||
}
|
||||
|
||||
fn shutdown (&mut self, status: ClientStatus, reason: &str) {
|
||||
}
|
||||
|
||||
fn freewheel (&mut self, _: &Client, is_enabled: bool) {
|
||||
}
|
||||
|
||||
fn sample_rate (&mut self, _: &Client, _: Frames) -> Control {
|
||||
Control::Quit
|
||||
}
|
||||
|
||||
fn client_registration (&mut self, _: &Client, name: &str, is_reg: bool) {
|
||||
}
|
||||
|
||||
fn port_registration (&mut self, _: &Client, port_id: PortId, is_reg: bool) {
|
||||
}
|
||||
|
||||
fn port_rename (&mut self, _: &Client, id: PortId, old: &str, new: &str) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
||||
fn ports_connected (&mut self, _: &Client, id_a: PortId, id_b: PortId, are: bool) {
|
||||
}
|
||||
|
||||
fn graph_reorder (&mut self, _: &Client) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
||||
fn xrun (&mut self, _: &Client) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ impl Sequencer {
|
|||
DynamicDevice::new(render, handle, process, Self {
|
||||
name: name.into(),
|
||||
mode: SequencerView::Vertical,
|
||||
note_axis: (36, 60),
|
||||
note_axis: (36, 68),
|
||||
note_cursor: 0,
|
||||
time_axis: (0, 64),
|
||||
time_cursor: 0,
|
||||
|
|
@ -63,7 +63,7 @@ impl Sequencer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn process (state: &mut Sequencer, client: &Client, scope: &ProcessScope) -> Control {
|
||||
pub fn process (state: &mut Sequencer, _: &Client, scope: &ProcessScope) -> Control {
|
||||
process_out(state, scope);
|
||||
process_in(state, scope);
|
||||
Control::Continue
|
||||
|
|
@ -78,8 +78,8 @@ fn process_in (state: &mut Sequencer, scope: &ProcessScope) {
|
|||
|
||||
for event in state.input_port.iter(scope) {
|
||||
match midly::live::LiveEvent::parse(event.bytes).unwrap() {
|
||||
midly::live::LiveEvent::Midi { channel, message } => match message {
|
||||
midly::MidiMessage::NoteOn { key, vel } => {
|
||||
midly::live::LiveEvent::Midi { channel: _, message } => match message {
|
||||
midly::MidiMessage::NoteOn { key, vel: _ } => {
|
||||
state.notes_on[key.as_int() as usize] = true;
|
||||
if state.sequence.contains_key(&(tick as u32)) {
|
||||
state.sequence.get_mut(&(tick as u32)).unwrap().push(message.clone());
|
||||
|
|
@ -87,7 +87,7 @@ fn process_in (state: &mut Sequencer, scope: &ProcessScope) {
|
|||
state.sequence.insert(tick as u32, vec![message.clone()]);
|
||||
}
|
||||
},
|
||||
midly::MidiMessage::NoteOff { key, vel } => {
|
||||
midly::MidiMessage::NoteOff { key, vel: _ } => {
|
||||
state.notes_on[key.as_int() as usize] = false;
|
||||
if state.sequence.contains_key(&(tick as u32)) {
|
||||
state.sequence.get_mut(&(tick as u32)).unwrap().push(message.clone());
|
||||
|
|
@ -104,18 +104,22 @@ fn process_in (state: &mut Sequencer, scope: &ProcessScope) {
|
|||
|
||||
fn process_out (state: &mut Sequencer, scope: &ProcessScope) {
|
||||
if state.playing {
|
||||
let size = scope.n_frames();
|
||||
let start = scope.last_frame_time();
|
||||
let end = start + size;
|
||||
let mut writer = state.output_port.writer(scope);
|
||||
let pulse_usec = state.tempo.usec_per_step(state.ppq as u64).0;
|
||||
let tick_start = Frame(start).to_usec(&state.rate).0 / pulse_usec;
|
||||
let tick_end = Frame(end).to_usec(&state.rate).0 / pulse_usec;
|
||||
for (i, (t, events)) in state.sequence.range(tick_start as u32..tick_end as u32).enumerate() {
|
||||
if events.len() > 0 {
|
||||
panic!("{events:?}");
|
||||
}
|
||||
}
|
||||
let pps = state.ppq / state.divisions;
|
||||
let ups = state.tempo.usec_per_step(state.divisions as u64).0;
|
||||
let start_usecs = Frame(scope.last_frame_time()).to_usec(&state.rate).0;
|
||||
let start_steps = start_usecs / ups;
|
||||
let start_step = start_steps % state.steps;
|
||||
let end_usecs = Frame(scope.last_frame_time() + scope.n_frames()).to_usec(&state.rate).0;
|
||||
let end_steps = end_usecs / ups;
|
||||
let end_step = end_steps % state.steps;
|
||||
let mut writer = state.output_port.writer(scope);
|
||||
//for (i, (t, events)) in state.sequence.range(
|
||||
//(step * pps) as u32..((step + 1) * pps) as u32
|
||||
//).enumerate() {
|
||||
//if events.len() > 0 {
|
||||
//panic!("{events:?}");
|
||||
//}
|
||||
//}
|
||||
//for time in start..end {
|
||||
//let usecs = Frame(time).to_usec(&state.rate).0;
|
||||
//let ticks = usecs / state.tempo.usec_per_step(state.ppq as u64).0;
|
||||
|
|
@ -124,39 +128,16 @@ fn process_out (state: &mut Sequencer, scope: &ProcessScope) {
|
|||
}
|
||||
}
|
||||
|
||||
impl NotificationHandler for Sequencer {
|
||||
fn thread_init (&self, _: &Client) {}
|
||||
fn shutdown (&mut self, status: ClientStatus, reason: &str) {}
|
||||
fn freewheel (&mut self, _: &Client, is_enabled: bool) {}
|
||||
fn sample_rate (&mut self, _: &Client, _: Frames) -> Control {
|
||||
Control::Quit
|
||||
}
|
||||
fn client_registration (&mut self, _: &Client, name: &str, is_reg: bool) {}
|
||||
fn port_registration (&mut self, _: &Client, port_id: PortId, is_reg: bool) {}
|
||||
fn port_rename (&mut self, _: &Client, id: PortId, old: &str, new: &str) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
fn ports_connected (&mut self, _: &Client, id_a: PortId, id_b: PortId, are: bool) {}
|
||||
fn graph_reorder (&mut self, _: &Client) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
fn xrun (&mut self, _: &Client) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
}
|
||||
|
||||
fn render (state: &Sequencer, buf: &mut Buffer, mut area: Rect)
|
||||
fn render (state: &Sequencer, buf: &mut Buffer, area: Rect)
|
||||
-> Usually<Rect>
|
||||
{
|
||||
let Rect { x, y, width, height } = area;
|
||||
let Rect { x, y, width, .. } = area;
|
||||
let (time0, time1) = state.time_axis;
|
||||
let (note0, note1) = state.note_axis;
|
||||
let pos = state.transport.query().unwrap().pos;
|
||||
let frame = pos.frame();
|
||||
let rate = pos.frame_rate().unwrap();
|
||||
let usecs = Frame(frame).to_usec(&Hz(rate)).0;
|
||||
let usec_per_beat = state.tempo.usec_per_beat().0;
|
||||
let usec_per_tick = state.tempo.usec_per_step(state.ppq).0;
|
||||
let usec_per_step = state.tempo.usec_per_step(state.divisions as u64).0;
|
||||
let steps = usecs / usec_per_step;
|
||||
let header = draw_state_header(state, buf, area, steps)?;
|
||||
|
|
@ -191,7 +172,7 @@ fn draw_state_header (state: &Sequencer, buf: &mut Buffer, area: Rect, beat: u64
|
|||
let step = beat % state.steps;
|
||||
let reps = state.steps / state.divisions;
|
||||
let steps = state.steps % state.divisions;
|
||||
let Rect { x, y, width, height } = area;
|
||||
let Rect { x, y, .. } = area;
|
||||
let style = Style::default().gray();
|
||||
buf.set_string(x + 1, y + 1, &format!(" │ {rep}.{step:2} / {reps}.{steps}"), style);
|
||||
buf.set_string(x + 2, y + 1, &format!("{}", &state.name), style.white().bold());
|
||||
|
|
@ -242,7 +223,7 @@ fn draw_state_vertical (state: &Sequencer, buf: &mut Buffer, area: Rect, beat: u
|
|||
let (note0, note1) = state.note_axis;
|
||||
let bw = Style::default().dim();
|
||||
let bg = Style::default().on_black();
|
||||
for key in note0..note1.max(note0+32) {
|
||||
for key in note0..note1 {
|
||||
let x = x + 5 + key - note0;
|
||||
if key % 12 == 0 {
|
||||
let octave = format!("C{}", (key / 12) as i8 - 4);
|
||||
|
|
@ -271,7 +252,7 @@ fn draw_state_vertical (state: &Sequencer, buf: &mut Buffer, area: Rect, beat: u
|
|||
if step % state.divisions == 0 {
|
||||
buf.set_string(x + 2, y, &format!("{:2} ", step + 1), Style::default());
|
||||
}
|
||||
for k in note0..note1.max(note0+32) {
|
||||
for k in note0..note1 {
|
||||
let key = ::midly::num::u7::from_int_lossy(k as u8);
|
||||
if step % 2 == 0 {
|
||||
let (a, b, c) = (
|
||||
|
|
@ -292,8 +273,8 @@ fn draw_state_vertical (state: &Sequencer, buf: &mut Buffer, area: Rect, beat: u
|
|||
}
|
||||
}
|
||||
if beat % state.steps == step as u64 {
|
||||
buf.set_string(x + 1, y, if beat % 2 == 0 { "▀" } else { "▄" }, Style::default().yellow());
|
||||
for key in note0..note1.max(note0+32) {
|
||||
buf.set_string(x + 39 - 2, y, if beat % 2 == 0 { "▀" } else { "▄" }, Style::default().yellow());
|
||||
for key in note0..note1 {
|
||||
let color = if state.notes_on[key as usize] {
|
||||
Style::default().red()
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ impl Transport {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn process (state: &mut Transport, client: &Client, scope: &ProcessScope) -> Control {
|
||||
pub fn process (_: &mut Transport, _: &Client, _: &ProcessScope) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ pub fn render (state: &Transport, buf: &mut Buffer, mut area: Rect)
|
|||
//Ok(())
|
||||
//}
|
||||
|
||||
pub fn handle (state: &mut Transport, event: &AppEvent) -> Result<(), Box<dyn Error>> {
|
||||
pub fn handle (_: &mut Transport, _: &AppEvent) -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -232,24 +232,3 @@ pub const ACTIONS: [(&'static str, &'static str);4] = [
|
|||
("Arrows", "Navigate"),
|
||||
("(Shift-)Space", "⯈ Play/pause"),
|
||||
];
|
||||
|
||||
impl NotificationHandler for Transport {
|
||||
fn thread_init (&self, _: &Client) {}
|
||||
fn shutdown (&mut self, status: ClientStatus, reason: &str) {}
|
||||
fn freewheel (&mut self, _: &Client, is_enabled: bool) {}
|
||||
fn sample_rate (&mut self, _: &Client, _: Frames) -> Control {
|
||||
Control::Quit
|
||||
}
|
||||
fn client_registration (&mut self, _: &Client, name: &str, is_reg: bool) {}
|
||||
fn port_registration (&mut self, _: &Client, port_id: PortId, is_reg: bool) {}
|
||||
fn port_rename (&mut self, _: &Client, id: PortId, old: &str, new: &str) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
fn ports_connected (&mut self, _: &Client, id_a: PortId, id_b: PortId, are: bool) {}
|
||||
fn graph_reorder (&mut self, _: &Client) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
fn xrun (&mut self, _: &Client) -> Control {
|
||||
Control::Continue
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use crate::device::{Sequencer, Transport};
|
|||
use crate::layout::Rows;
|
||||
|
||||
fn main () -> Result<(), Box<dyn Error>> {
|
||||
let cli = cli::Cli::parse();
|
||||
let _cli = cli::Cli::parse();
|
||||
let xdg = microxdg::XdgApp::new("dawdle")?;
|
||||
crate::config::create_dirs(&xdg)?;
|
||||
//crate::device::run(Sequencer::new("Rhythm#000")?)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue