Skip to content

Commit dce6067

Browse files
authored
Add MIDI controller pass-through support (#429)
* Add MIDI controller pass-through support and update nix devshell
1 parent 3eed59d commit dce6067

3 files changed

Lines changed: 40 additions & 10 deletions

File tree

flake.nix

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@
6868
# `nix run github:PolyMeilex/Neothesia`
6969
default = inputs.self.outputs.packages.${system}.neothesia;
7070
neothesia = naersk.buildPackage {
71+
nativeBuildInputs = [
72+
pkgs.pkg-config
73+
];
74+
buildInputs = [
75+
pkgs.alsa-lib
76+
];
7177
meta.mainProgram = "neothesia";
7278
src = workspace;
7379
};
@@ -85,11 +91,38 @@
8591
};
8692
});
8793

88-
devShells = forAllSystems (system: pkgs: {
94+
devShells = forAllSystems (system: pkgs: let
95+
rustToolchain =
96+
pkgs.rust-bin.nightly.latest.default.override
97+
{extensions = ["rust-src" "rust-analyzer"];};
98+
99+
runtimeLibs = with pkgs; [
100+
wayland
101+
libxkbcommon
102+
libGL
103+
vulkan-loader
104+
alsa-lib
105+
libx11
106+
libxcursor
107+
libxrandr
108+
libxi
109+
ffmpeg_8.lib
110+
];
111+
in {
89112
# `nix develop github:PolyMeilex/Neothesia`
90113
default = pkgs.mkShell {
91-
# grab all build dependencies of all exposed packages
92-
inputsFrom = pkgs.lib.attrValues inputs.self.packages.${system};
114+
nativeBuildInputs = with pkgs; [
115+
rustToolchain
116+
pkg-config
117+
ffmpeg_8.dev
118+
];
119+
buildInputs = with pkgs; [
120+
alsa-lib
121+
] ++ runtimeLibs;
122+
shellHook = ''
123+
export PKG_CONFIG_PATH="${pkgs.alsa-lib.dev}/lib/pkgconfig:${pkgs.ffmpeg_8.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
124+
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath runtimeLibs}:$LD_LIBRARY_PATH"
125+
'';
93126
};
94127
});
95128
};

neothesia/src/scene/freeplay/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl Scene for FreeplayScene {
261261
self.keyboard.user_midi_event(message);
262262
ctx.output_manager
263263
.connection()
264-
.midi_event(0.into(), *message);
264+
.midi_event(channel.into(), *message);
265265

266266
if let MidiMessage::NoteOn { .. } = message {
267267
let start = self.keyboard.layout().range.start();

neothesia/src/scene/menu_scene/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,17 +424,14 @@ impl Scene for MenuScene {
424424
match message {
425425
MidiMessage::NoteOn { key, .. } => {
426426
self.midi_input_state.note_on(key.as_int());
427-
ctx.output_manager
428-
.connection()
429-
.midi_event(channel.into(), *message);
430427
}
431428
MidiMessage::NoteOff { key, .. } => {
432429
self.midi_input_state.note_off(key.as_int());
433-
ctx.output_manager
434-
.connection()
435-
.midi_event(channel.into(), *message);
436430
}
437431
_ => {}
438432
}
433+
ctx.output_manager
434+
.connection()
435+
.midi_event(channel.into(), *message);
439436
}
440437
}

0 commit comments

Comments
 (0)