Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Bug]: DeviceManager doesn't work on Linux

Open
#246 6 comments 0 reactions 0 assignees View on GitHub

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

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 FakeMain program 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Tracktion/tracktion_engine

All issues in Tracktion/tracktion_engine

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.