[Bug]: DeviceManager doesn't work on Linux
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- audio-video-rtc
Research direction
Start from test/fake_main.cc, which reproduces the failure by calling rescanMidiDeviceList(), createVirtualMidiDevice("box_midi") and setDefaultMidiInDevice() before asserting getDefaultMidiInDevice() is non-null. Trace those paths in the DeviceManager and the JUCE ALSA virtual-MIDI backend; the log points at /dev/snd/seq being unavailable, so the real question is whether the virtual device fails silently or is never registered. Done means the assertion passes on Linux without the sequencer device present.
Written by the indexing model from the issue text.
Description
Detailed steps on how to reproduce the bug
Summary
I'm unable to set the Midi In Device with dm.setDefaultMidiInDevice() on linux devices.
- The same code runs correctly on MacOS.
Context
My use case is playing virtual midi messages with:
int note = 60; // C3
te::MidiInputDevice *dev = engine_.getDeviceManager().getDefaultMidiInDevice();
dev->keyboardState.noteOn(1, note, 1.0);
Reproducing
I created a program fake_main.cc (below) in order to reproduce this behaviour.
Even though I'm setting the default midi in device, dm.getDefaultMidiInDevice() keeps returning nullptr
Here's my log from the github runner CI:
- I truncated the raylib init messages for clarity
JUCE v8.0.3
ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
Audio block size: 256 Rate: 44100
Creating Default Controllers...
Edit loaded in: 2 ms
-----------
begin tests
ALSA::VirtualMidi begin
FakeMain: /home/runner/work/box/box/test/fake_main.cc:30: int main(): Assertion `ptr != nullptr' failed.
Aborted (core dumped)
Error: Process completed with exit code 134.
Solution?
I think this has to do with the line, since ALSA handles midi messages:
ALSA lib seq_hw.c:466:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
I saw the same error message on tracktion_engine:master.
Am I doing something wrong? Like not setting up the audio server correctly?
Note:
- I'm using int main() instead of the Juce application harness
- I would prefer to proceed this way because it's simpler. Especially since it works fine on macOS.
What is the expected behaviour?
The test should pass.
- On my Macbook (Air M1), the
FakeMainprogram runs without failing the assert.- It correctly prints out how many Midi Devices there are.
- I tested different linux platforms:
- my PC (x86 ubuntu 22.04)
- the github runner CI environment (x86 ubuntu 22.04)
- Raspberry Pi CM4 (ARM Raspberry Pi OS)
Unit test to reproduce the error?
// fake_main.cc
#include <filesystem>
#include <iostream>
#include <raylib.h>
#include <tracktion_engine/tracktion_engine.h>
namespace te = tracktion;
int main()
{
const juce::ScopedJuceInitialiser_GUI initialiser; // need this
te::Engine engine{"Tracktion Hello World"};
std::filesystem::path curr_path = std::filesystem::current_path();
juce::File my_file{juce::String{curr_path.string() + "/tmp.box"}};
std::unique_ptr<te::Edit> my_edit = createEmptyEdit(engine, my_file);
te::Edit &edit = *my_edit;
edit.ensureNumberOfAudioTracks(8);
edit.getTransport().ensureContextAllocated();
engine.getDeviceManager().rescanMidiDeviceList();
// need this line for the test to pass on macOS for some reason
InitWindow(512, 512, "fake main test");
std::cout << "-----------" << std::endl;
std::cout << "begin tests" << std::endl;
// test ALSA::VirtualMidi
{
std::cout << "ALSA::VirtualMidi begin" << std::endl;
engine.getDeviceManager().createVirtualMidiDevice("box_midi");
engine.getDeviceManager().setDefaultMidiInDevice("box_midi");
auto ptr = engine.getDeviceManager().getDefaultMidiInDevice();
assert(ptr != nullptr);
std::cout << "ALSA::VirtualMidi end" << std::endl;
}
std::cout << std::endl;
// test ALSA::PrintMidiIn
{
std::cout << "ALSA::PrintMidiIn begin:" << std::endl;
auto vec = engine.getDeviceManager().getMidiInDevices();
std::cout << "midiInputs.size(): " << vec.size() << std::endl;
for (auto &x : vec)
{
std::cout << "\t" << x->getName() << std::endl;
}
std::cout << "ALSA::PrintMidiIn end" << std::endl;
}
std::cout << "end tests" << std::endl;
std::cout << "-----------" << std::endl;
return 0;
}
Operating systems
Linux
What versions of the operating systems?
Ubuntu 22.04
Architectures
x86_64, ARM
Stacktrace
Plug-in formats (if applicable)
No response
Plug-in host applications (DAWs) (if applicable)
No response
Testing on the develop branch
The bug is present on the develop branch
Code of Conduct
- I agree to follow the Code of Conduct
- Dominant language
- C++
- Stars
- 1.5k
- Forks
- 222
- Avg merge
- 15h 44m
- Merged PRs (30d)
- 33
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Tracktion/tracktion_engine
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Tracktion/tracktion_engine#475 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Tracktion/tracktion_engine#476 · 5 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 22/100
Tracktion/tracktion_engine#474 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
Tracktion/tracktion_engine#473 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 56/100
Tracktion/tracktion_engine#460 ·
Maintainers usually reply within 1 day
All issues in Tracktion/tracktion_engine
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
eclipse-score/inc_someip_gateway#356 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
HarperFast/rocksdb-js#945 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
[Other] error detected in the compilation of Strata/src/qwen35/q36_engine.cuPossibly taken A pull request linked to this issue is open or already merged. Openneeds-format
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
Niko1221/Strata#3368 · 1 comment ·
Maintainers usually reply within 3 days