Skip to content

Commit

Permalink
chore: rename res/ to assets/
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanleiby committed Nov 11, 2024
1 parent 66e9ad7 commit 7afca0a
Show file tree
Hide file tree
Showing 70 changed files with 25 additions and 22 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions dev-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ set -e
rustup target add wasm32-unknown-unknown
./wasm-bindgen-macroquad.sh drum-break

## TODO: Figure out how to properly
# cp -r res dist/
# copy assets
cp -r assets dist/

# run
pushd dist/
basic-http-server -a 0.0.0.0:4001 .
popd
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file modified github_pages/drum-break_bg.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion migrate_loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import json

names = os.listdir("./res/loops")
names = os.listdir("./assets/loops")

# This migration adds `voices.ride = []`

Expand Down
2 changes: 1 addition & 1 deletion migrate_loops2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import json

prefix = "./res/loops"
prefix = "./assets/loops"
names = os.listdir(prefix)

# This migration adds `voices.crash = []`
Expand Down
2 changes: 1 addition & 1 deletion migrate_loops3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import json
import uuid

prefix = "./res/loops"
prefix = "./assets/loops"
names = os.listdir(prefix)

# This migration adds
Expand Down
6 changes: 4 additions & 2 deletions release-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ rustup target add wasm32-unknown-unknown
./wasm-bindgen-macroquad.sh --release drum-break
rm -rf github_pages

## TODO: Figure out how to properly handle resources, like audio files and images
# cp -r res dist/
# copy assets
cp -r assets dist/

# put it into a folder that will be committed and pushed
cp -r dist github_pages
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cp target/aarch64-apple-darwin/release/drum-break ./release/drum-break-aarch64
chmod 700 ./release/drum-break-aarch64

# add assets
cp -r res/ ./release/res/
cp -r assets/ ./release/assets/

# zip it up and ship the release
version="$(cat VERSION)"
Expand Down
2 changes: 1 addition & 1 deletion src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl Audio {
// TODO: play a different sound at start of each measure
// clicks on quarter notes
let metronome_notes = vec![0., 2., 4., 6., 8., 10., 12., 14.];
let sound_path = "res/sounds/click.wav"; // TODO: metronome.ogg?
let sound_path = "assets/sounds/click.wav"; // TODO: metronome.ogg?
let f = load_file(sound_path).await?;
let sound = StaticSoundData::from_cursor(Cursor::new(f))?;
let volume = 1.;
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ fn process_cli_args() -> String {

std::env::args()
.nth(1)
.unwrap_or_else(|| "res/loops/".to_string())
.unwrap_or_else(|| "assets/loops/".to_string())
}

async fn read_loops(dir_name: &str) -> Result<Vec<(String, Loop)>, Box<dyn Error>> {
Expand Down
24 changes: 12 additions & 12 deletions src/voices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ impl Voices {
pub fn get_audio_file_for_instrument(ins: &Instrument) -> &str {
// TODO: verify required sound files exist on startup- right now it fails during runtime
match ins {
Instrument::ClosedHihat => "res/sounds/closed-hihat.wav",
Instrument::Snare => "res/sounds/snare.wav",
Instrument::Kick => "res/sounds/kick.wav",
Instrument::OpenHihat => "res/sounds/open-hihat.wav",
Instrument::Ride => "res/sounds/ride.wav",
Instrument::Crash => "res/sounds/crash.wav",
Instrument::Tom1 => "res/sounds/tom-hi.wav",
Instrument::Tom2 => "res/sounds/tom-med.wav",
Instrument::Tom3 => "res/sounds/tom-low.wav",
Instrument::PedalHiHat => "res/sounds/pedal-hihat.wav",
// Instrument::Metronome => "res/sounds/click.wav",
Instrument::ClosedHihat => "assets/sounds/closed-hihat.wav",
Instrument::Snare => "assets/sounds/snare.wav",
Instrument::Kick => "assets/sounds/kick.wav",
Instrument::OpenHihat => "assets/sounds/open-hihat.wav",
Instrument::Ride => "assets/sounds/ride.wav",
Instrument::Crash => "assets/sounds/crash.wav",
Instrument::Tom1 => "assets/sounds/tom-hi.wav",
Instrument::Tom2 => "assets/sounds/tom-med.wav",
Instrument::Tom3 => "assets/sounds/tom-low.wav",
Instrument::PedalHiHat => "assets/sounds/pedal-hihat.wav",
// Instrument::Metronome => "assets/sounds/click.wav",
}
}

Expand Down Expand Up @@ -206,7 +206,7 @@ mod tests {

#[test]
fn it_can_load_a_loop_from_file() {
let result = Loop::new_from_file("res/loops/samba.json");
let result = Loop::new_from_file("assets/loops/samba.json");
let loop_data = result.unwrap();
assert_eq!(loop_data.bpm, 120);
let voices = Voices::new_from_voices_old_model(&loop_data.voices);
Expand Down

0 comments on commit 7afca0a

Please sign in to comment.