Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added assets/sheet-music/notation-atlas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions neothesia-core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,22 @@ impl Config {
self.waterfall.note_labels
}

pub fn sheet_music(&self) -> bool {
self.waterfall.sheet_music
}

pub fn set_sheet_music(&mut self, show: bool) {
self.waterfall.sheet_music = show;
}

pub fn sheet_music_height(&self) -> f32 {
self.waterfall.sheet_music_height
}

pub fn set_sheet_music_height(&mut self, height: f32) {
self.waterfall.sheet_music_height = height.clamp(140.0, 600.0);
}

pub fn speed_multiplier(&self) -> f32 {
self.playback.speed_multiplier
}
Expand Down
16 changes: 16 additions & 0 deletions neothesia-core/src/config/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ pub struct WaterfallConfigV1 {

#[serde(default = "default_note_labels")]
pub note_labels: bool,

#[serde(default = "default_sheet_music")]
pub sheet_music: bool,

#[serde(default = "default_sheet_music_height")]
pub sheet_music_height: f32,
}

#[derive(Serialize, Deserialize)]
Expand All @@ -44,6 +50,8 @@ impl Default for WaterfallConfig {
animation_speed: default_animation_speed(),
animation_offset: default_animation_offset(),
note_labels: default_note_labels(),
sheet_music: default_sheet_music(),
sheet_music_height: default_sheet_music_height(),
})
}
}
Expand Down Expand Up @@ -211,6 +219,14 @@ fn default_note_labels() -> bool {
false
}

fn default_sheet_music() -> bool {
true
}

fn default_sheet_music_height() -> f32 {
260.0
}

fn default_audio_gain() -> f32 {
0.2
}
Expand Down
1 change: 1 addition & 0 deletions neothesia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ futures-channel.workspace = true
cosmic-text.workspace = true

bytes.workspace = true
bytemuck.workspace = true
lilt.workspace = true
winit.workspace = true
rfd.workspace = true
Expand Down
31 changes: 31 additions & 0 deletions neothesia/src/scene/menu_scene/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,28 @@ impl super::MenuScene {
{
ctx.config.set_note_labels(!ctx.config.note_labels());
}

spacer(ui);

if nuon::settings_row_toggler()
.title("Sheet Music")
.subtitle("Display a scrolling grand staff")
.value(ctx.config.sheet_music())
.build(ui, rows)
{
ctx.config.set_sheet_music(!ctx.config.sheet_music());
}

spacer(ui);

self::update_sheet_music_height(
ctx,
nuon::settings_row_spin()
.title("Sheet Music Height")
.subtitle(format!("{} px", ctx.config.sheet_music_height().round()))
.id("sheet-music-height")
.build(ui, rows),
);
});
});
}
Expand Down Expand Up @@ -449,6 +471,15 @@ pub fn update_range_end(ctx: &mut Context, kind: nuon::SettingsRowSpinResult) {
}
}

pub fn update_sheet_music_height(ctx: &mut Context, kind: nuon::SettingsRowSpinResult) {
let height = ctx.config.sheet_music_height();
match kind {
nuon::SettingsRowSpinResult::Plus => ctx.config.set_sheet_music_height(height + 20.0),
nuon::SettingsRowSpinResult::Minus => ctx.config.set_sheet_music_height(height - 20.0),
nuon::SettingsRowSpinResult::Idle => {}
}
}

pub fn open_soundfont_picker(data: &mut UiState) -> BoxFuture<MsgFn> {
data.is_loading = true;
on_async(open_sondfont_picker_fut(), |res, data, ctx| {
Expand Down
19 changes: 19 additions & 0 deletions neothesia/src/scene/playing_scene/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ use midi_player::MidiPlayer;
mod rewind_controller;
use rewind_controller::RewindController;

mod sheet_music;
use sheet_music::SheetMusicRenderer;

mod toast_manager;
use toast_manager::ToastManager;

Expand All @@ -39,6 +42,7 @@ pub struct PlayingScene {
nuon_renderer: NuonRenderer,

note_labels: Option<NoteLabels>,
sheet_music: Option<SheetMusicRenderer>,

player: MidiPlayer,
rewind_controller: RewindController,
Expand Down Expand Up @@ -92,6 +96,10 @@ impl PlayingScene {
ctx.text_renderer_factory.new_renderer(),
));

let sheet_music = ctx.config.sheet_music().then(|| {
SheetMusicRenderer::new(ctx, &song.file.tracks, &hidden_tracks, &song.file.measures)
});

let player = MidiPlayer::new(
ctx.output_manager.connection().clone(),
song,
Expand All @@ -113,6 +121,7 @@ impl PlayingScene {
keyboard,
guidelines,
note_labels,
sheet_music,
text_renderer,
nuon_renderer: NuonRenderer::new(ctx),

Expand Down Expand Up @@ -200,6 +209,9 @@ impl Scene for PlayingScene {

let time = self.update_midi_player(ctx, delta);
self.waterfall.update(time);
if let Some(sheet_music) = self.sheet_music.as_mut() {
sheet_music.update(ctx, time);
}
self.guidelines.update(
&mut self.quad_renderer_bg,
ctx.config.animation_speed(),
Expand Down Expand Up @@ -258,6 +270,9 @@ impl Scene for PlayingScene {
if let Some(note_labels) = self.note_labels.as_mut() {
note_labels.render(rpass);
}
if let Some(sheet_music) = self.sheet_music.as_ref() {
sheet_music.render(rpass);
}
self.quad_renderer_fg.render(rpass);
if let Some(glow) = &self.glow {
glow.render(rpass);
Expand All @@ -268,6 +283,10 @@ impl Scene for PlayingScene {
}

fn window_event(&mut self, ctx: &mut Context, event: &WindowEvent) {
if let Some(sheet_music) = self.sheet_music.as_mut() {
sheet_music.handle_window_event(ctx, event);
}

self.rewind_controller
.handle_window_event(ctx, event, &mut self.player);

Expand Down
Loading