Skip to content

Commit

Permalink
feat: re-arrange instruments in UI. smaller beat grid
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanleiby committed Jul 9, 2024
1 parent f8894ba commit c03a633
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

## working on

- [..] support more drum types (not just kick, snare, open/closed hat)
- [x] support more drum types (not just kick, snare, open/closed hat)
- [x] ride, pedal HH, [x] crash, 3 toms.. or arbitrary mappings
- hacking in RIDE, by following the compiler. Almost works except JSON is strict and missing field borks it. Can I avoid?
- [ ] Add sounds for more instruments (ride, bell, pedal HH, crash, etc)
- [x] Add sounds for more instruments (ride, bell, pedal HH, crash, etc)
- samples MVP: https://www.reddit.com/r/edmproduction/comments/4ew9ut/free_sample_pack_of_my_acoustic_drum_kit_real/
- https://www.dropbox.com/scl/fi/60funlj95o1i8hg/Real-Drums-Vol.-1.zip

Expand Down
13 changes: 7 additions & 6 deletions src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub const WINDOW_HEIGHT: i32 = 720;

pub const BEATS_PER_LOOP: f64 = 16.;

pub const BEAT_WIDTH_PX: f64 = 64.0;
pub const BEAT_WIDTH_PX: f64 = 48.0;
pub const BEAT_PADDING: f64 = 4.;

pub const GRID_WIDTH: f64 = BEAT_WIDTH_PX * 16.;
Expand All @@ -25,15 +25,16 @@ pub const TICK_SCHEDULE_AHEAD: f64 = 2.; // schedule audio this many (N) ticks a

// General use
pub const ALL_INSTRUMENTS: [Instrument; 9] = [
Instrument::ClosedHihat,
Instrument::Snare,
Instrument::Kick,
Instrument::OpenHihat,
Instrument::Ride,
Instrument::Crash,
Instrument::Ride,
Instrument::OpenHihat,
Instrument::ClosedHihat,
Instrument::Tom1,
Instrument::Tom2,
Instrument::Tom3,
Instrument::Snare,
Instrument::Kick,
// Pedal Hi-hat
];

pub const NUM_ROWS_IN_GRID: usize = ALL_INSTRUMENTS.len();
23 changes: 10 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::input::*;
use crate::ui::*;
use crate::voices::Voices;

use consts::{WINDOW_HEIGHT, WINDOW_WIDTH};
use consts::{ALL_INSTRUMENTS, WINDOW_HEIGHT, WINDOW_WIDTH};
use score::compute_last_loop_summary;
use simple_logger;

Expand Down Expand Up @@ -199,19 +199,16 @@ fn process_input_events(
}
Events::ToggleBeat { row, beat } => {
// map from UI display to instrument
let ins = match *row as usize {
0 => Instrument::ClosedHihat,
1 => Instrument::Snare,
2 => Instrument::Kick,
3 => Instrument::OpenHihat,
4 => Instrument::Ride,
5 => Instrument::Crash,
6 => Instrument::Tom1,
7 => Instrument::Tom2,
8 => Instrument::Tom3,
_ => panic!("invalid instrument idx"),
let res = ALL_INSTRUMENTS
.iter()
.enumerate()
.find(|x| x.0 == *row as usize);
let ins = match res {
Some(x) => x.1,
None => panic!("invalid instrument idx"),
};
voices.toggle_beat(ins, *beat);

voices.toggle_beat(*ins, *beat);
}
Events::TrackForCalibration => {
let updated_val = audio.track_for_calibration();
Expand Down

0 comments on commit c03a633

Please sign in to comment.