Skip to content

Commit 04494de

Browse files
committed
POC: Neothesia Web
1 parent 25f809a commit 04494de

File tree

13 files changed

+354
-9
lines changed

13 files changed

+354
-9
lines changed

Cargo.lock

Lines changed: 47 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ members = [
66
"neothesia-cli",
77
"neothesia-core",
88
"neothesia-pipelines",
9-
"midi-file",
9+
"neothesia-web",
1010
"midi-io",
1111
]
1212

1313
default-members = ["neothesia"]
1414

1515
[workspace.dependencies]
16-
wgpu = "0.16.1"
16+
wgpu = { version = "0.16.1", features = ["webgl"] }
1717
log = "0.4"
1818
bytemuck = { version = "1.5", features = ["derive"] }
1919
env_logger = "0.10"

midi-file/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ authors = ["Poly <[email protected]>"]
55
edition = "2021"
66

77
[dependencies]
8-
midly = "0.5"
8+
midly = { version = "0.5", default-features = false, features = ["std"] }

midi-file/src/midi.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ impl Midi {
1616
Err(_) => return Err(String::from("Could Not Open File")),
1717
};
1818

19+
Self::new_from_bytes(&data)
20+
}
21+
22+
pub fn new_from_bytes(data: &[u8]) -> Result<Self, String> {
1923
let smf = match Smf::parse(&data) {
2024
Ok(smf) => smf,
2125
Err(_) => return Err(String::from("Midi Parsing Error (midly lib)")),

neothesia-core/src/utils/resources.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ pub fn default_sf2() -> Option<PathBuf> {
4848

4949
#[cfg(target_os = "macos")]
5050
return bundled_resource_path("default", "sf2").map(PathBuf::from);
51+
52+
#[cfg(target_family = "wasm")]
53+
return None;
5154
}
5255

5356
pub fn settings_ron() -> Option<PathBuf> {
@@ -59,6 +62,9 @@ pub fn settings_ron() -> Option<PathBuf> {
5962

6063
#[cfg(target_os = "macos")]
6164
return bundled_resource_path("settings", "ron").map(PathBuf::from);
65+
66+
#[cfg(target_family = "wasm")]
67+
return None;
6268
}
6369

6470
#[cfg(target_os = "macos")]

neothesia-pipelines/src/waterfall/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl<'a> WaterfallPipeline {
2626
let shader = gpu
2727
.device
2828
.create_shader_module(wgpu::ShaderModuleDescriptor {
29-
label: Some("RectanglePipeline::shader"),
29+
label: Some("waterfall::shader"),
3030
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!(
3131
"./shader.wgsl"
3232
))),
@@ -41,7 +41,7 @@ impl<'a> WaterfallPipeline {
4141
let render_pipeline_layout =
4242
&gpu.device
4343
.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
44-
label: None,
44+
label: Some("waterfall::pipeline"),
4545
bind_group_layouts: &[
4646
&transform_uniform.bind_group_layout,
4747
&time_uniform.bind_group_layout,
@@ -106,10 +106,18 @@ impl<'a> WaterfallPipeline {
106106
#[derive(Clone, Copy, Pod, Zeroable)]
107107
struct TimeUniform {
108108
time: f32,
109+
_pad1: f32,
110+
_pad2: f32,
111+
_pad3: f32,
109112
}
110113

111114
impl Default for TimeUniform {
112115
fn default() -> Self {
113-
Self { time: 0.0 }
116+
Self {
117+
time: 0.0,
118+
_pad1: 0.0,
119+
_pad2: 0.0,
120+
_pad3: 0.0,
121+
}
114122
}
115123
}

neothesia-pipelines/src/waterfall/shader.wgsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ struct ViewUniform {
66

77
struct TimeUniform {
88
time: f32,
9+
_pad1: f32,
10+
_pad2: f32,
11+
_pad3: f32,
912
}
1013

1114
@group(0) @binding(0)

neothesia-web/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

neothesia-web/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[package]
2+
name = "neothesia-web"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
neothesia-core = { workspace = true }
8+
wgpu = { version = "0.16.1", features = ["webgl"] }
9+
wgpu-jumpstart = { workspace = true }
10+
11+
winit = { version = "0.28.2" }
12+
env_logger = { workspace = true }
13+
pollster = "0.2"
14+
console_log = "0.2"
15+
web-sys = "0.3.61"
16+
wasm-bindgen-futures = "0.4.34"
17+
console_error_panic_hook = "0.1.7"
18+
19+
midi-file = { workspace = true }
20+
piano-math = { workspace = true }
21+
log = "0.4.18"
22+
instant = "0.1.12"
23+
24+
getrandom = { version = "0.2", features = ["js"] }

neothesia-web/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Run
2+
```
3+
trunk serve --open
4+
```

0 commit comments

Comments
 (0)