Skip to content

Commit

Permalink
add visual output for the scales, remove linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
SamyaDaleh committed Nov 18, 2023
1 parent 7b01600 commit bd531a5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@ env:
jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Install alsa
run: sudo apt-get install -y librust-alsa-sys-dev
- name: Install dependencies for libudev
run: sudo apt install -y pkg-config libusb-1.0-0-dev libftdi1-dev
- name: Install libudev
run: sudo apt-get install libudev-dev
- name: suggested on stack overflow to install after libudev
run: cargo install cargo-flash
- uses: actions/checkout@v3
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

publish:

runs-on: windows-latest
Expand Down
34 changes: 28 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,21 +329,44 @@ impl EventHandler<GameError> for MyGame {
Ok(())
}


fn draw(&mut self, ctx: &mut Context) -> GameResult<()> {
graphics::clear(ctx, graphics::Color::BLACK); // Clear the screen (or choose another color)
graphics::clear(ctx, graphics::Color::BLACK);

// Create a text fragment with the current scale
let scale_text = Text::new(format!("Current Scale (press tab to change): {:?}", self.scale));
let dest_point_1 = [10.0, 10.0]; // Position where the text will be drawn (x, y)
let shawzin_text = Text::new(format!("Current Shawzin (press A to change): {:?}", self.shawzin));
let dest_point_2 = [10.0, 25.0]; // Position where the text will be drawn (x, y)

// Draw the text
graphics::draw(ctx, &scale_text, DrawParam::default().dest(dest_point_1))?;
graphics::draw(ctx, &shawzin_text, DrawParam::default().dest(dest_point_2))?;

graphics::present(ctx) // Present the screen
let keys = vec!["1", "2", "3"];
let modifiers = vec![">", "v", "<", "_"];

let mut ascii_art = String::new();

for &modifier in &modifiers {
ascii_art.push_str("\n | | | \n");
let mut line = format!("{}: ", modifier);
for &key in &keys {
let combo = format!("{}{}", key, modifier);
if let Some(note) = self.get_note_from_input(&self.scale, &combo) {
let note_str = format!("{:?}", note).replace("Sharp", "#");
line.push_str(&format!("{} ", note_str));
}
}
ascii_art.push_str(&line);
}

ascii_art.push_str("\n | | |");
ascii_art.push_str("\n 1 2 3");

let scale_ascii_art = Text::new(ascii_art);
let dest_ascii_art = [10.0, 50.0];

graphics::draw(ctx, &scale_ascii_art, DrawParam::default().dest(dest_ascii_art))?;

graphics::present(ctx)
}

fn key_down_event(&mut self, _ctx: &mut Context, keycode: KeyCode, _keymods: KeyMods, _repeat: bool) {
Expand Down Expand Up @@ -392,7 +415,6 @@ impl EventHandler<GameError> for MyGame {
KeyCode::Space => self.space_pressed = false,
_ => (),
}
//self.audio_manager.stop_sound()
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ impl Note {
Note::C4 => Note::B3, //wait, BSharp3 does not exist? need to recheck with WF
Note::CSharp4 => Note::C4,
Note::D4 => Note::CSharp4,
Note::E4 => Note::D4,
Note::DSharp4 => Note::D4,
Note::E4 => Note::DSharp4,
Note::F4 => Note::E4,
Note::FSharp4 => Note::F4,
Note::G4 => Note::FSharp4,
Expand Down
1 change: 1 addition & 0 deletions src/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::time::Duration;
use crate::{Note, Shawzin};

pub struct AudioManager {
#[allow(unused)]
stream: OutputStream,
sink: Arc<Mutex<Sink>>,
}
Expand Down

0 comments on commit bd531a5

Please sign in to comment.