VSLilyPond icon indicating copy to clipboard operation
VSLilyPond copied to clipboard

MIDI file playing in a devcontainer

Open jeandeaual opened this issue 3 years ago • 15 comments

I usually work inside a development container, and this extension works perfectly fine there, except for the MIDI file player: I get no error but no music is played. I tried installing timidity, fluid-soundfont-gm and fluid-soundfont-gs, but this didn't help (the container is based on Debian).

Here is the configuration I use (files inside .devcontainer):

  • Dockerfile:

    # [Choice] LilyPond version: 2.22.0, 2.23.0, etc.
    ARG VARIANT="2.23.0"
    FROM jeandeaual/lilypond:${VARIANT}
    
    ARG USERNAME=vscode
    ARG USER_UID=1000
    ARG USER_GID=$USER_UID
    
    RUN apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update && export DEBIAN_FRONTEND=noninteractive \
            && apt-get -y upgrade \
            && apt-get -y --no-install-recommends install sudo git vim timidity fluid-soundfont-gm fluid-soundfont-gs \
            && rm -rf /var/lib/apt/lists/*
    
    RUN groupadd --gid "${USER_GID}" "${USERNAME}"
    RUN useradd -s /bin/bash --uid "${USER_UID}" --gid "${USER_GID}" --groups sudo --create-home "${USERNAME}"
    RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
    
    RUN printf '\nexport LANG="C"\nexport LANGUAGE="C"\nexport LC_ALL="C"\n' >> "/home/${USERNAME}/.bashrc"
    
  • devcontainer.json

    {
        "name": "LilyPond",
        "build": {
            "dockerfile": "Dockerfile",
            // Update 'VARIANT' to pick an LilyPond version: 2.22.0, 2.23.0, etc.
            "args": { "VARIANT": "devel-fonts" }
        },
        // Add the IDs of extensions you want installed when the container is created.
        "extensions": [
            "lhl2617.vslilypond",
            "tomoki1207.pdf"
        ],
        // Connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
        "remoteUser": "vscode"
    }
    

Do you have any idea how to make it work?

jeandeaual avatar Jan 30 '21 14:01 jeandeaual

There is something fishy about Linux and timidity that I haven't had the time to look into -- please refer to #173 and see if that works? Happy to try running this dev container when I have time as per your other issue.

Thanks for reporting this!

lhl2617 avatar Jan 31 '21 19:01 lhl2617

Thanks for the info. Unfortunately I didn't manage to make the MIDI player nor the MIDI input feature on Linux. I'll take a look again when I have some more free time.

Meanwhile, here is the dev container I use when working on LilyPond projects.

jeandeaual avatar Mar 07 '21 09:03 jeandeaual

Sorry for putting this off for so long--I'm looking into this now

lhl2617 avatar May 13 '21 22:05 lhl2617

Hmm -- the whole devcontainer crashed for me when I tried any MIDI action from the extension

image

Is this what you see as well? @jeandeaual

lhl2617 avatar May 14 '21 00:05 lhl2617

Opened https://github.com/microsoft/vscode/issues/123836 -- it is rather annoying to debug without any logs/trace

lhl2617 avatar May 14 '21 01:05 lhl2617

This problem seems to stem from the JZZ() call failing on Docker/WSL2 envs. Will set up a repro repo and open an issue in jzz

lhl2617 avatar May 14 '21 11:05 lhl2617

@jeandeaual -- what is your host machine's OS?

lhl2617 avatar May 14 '21 11:05 lhl2617

Opened https://github.com/jazz-soft/JZZ/issues/43 for jzz failing on WSL2

lhl2617 avatar May 14 '21 11:05 lhl2617

Opened jazz-soft/JZZ#43 for jzz failing on WSL2

Fixed via jazz-midi 1.7.5; waiting for JZZ and jzz-midi-smf deps to be updated.

lhl2617 avatar May 16 '21 17:05 lhl2617

Can confirm that release 1.6.4 (#255) does not crash VSCode. However, it implies it is playing/recording even without any device present. 1.6.5 (#257) will add a fix to crash when no (in|out)puts are found

lhl2617 avatar May 18 '21 20:05 lhl2617

The crashing behavior is fixed in #257

I doubt MIDI playback/input can actually be done reliably in a devcontainer, but at least now it does not crash when the MIDI buttons are pressed.

Relevant: https://stackoverflow.com/questions/65912601/docker-container-as-midi-io-device

lhl2617 avatar May 18 '21 21:05 lhl2617

Reopening until we can have MIDI IO via docker (if that's at all possible)

lhl2617 avatar May 18 '21 21:05 lhl2617

https://stackoverflow.com/a/41084959/9723640 -- it might be possible to forward audio out of a container--I've done this with PulseAudio with WSL2.

The container would need to mount /dev/snd--I'll come back when I have time.

lhl2617 avatar May 18 '21 21:05 lhl2617

@lhl2617 Sorry I didn't get back to you earlier, and thanks for investigating this issue!

@jeandeaual -- what is your host machine's OS?

I tested on Windows 10 (x64), Arch Linux (x64) and macOS Big Sur (Apple M1).

https://stackoverflow.com/a/41084959/9723640 -- it might be possible to forward audio out of a container--I've done this with PulseAudio with WSL2.

The container would need to mount /dev/snd--I'll come back when I have time.

I tried again after uncommenting this line:

  • Windows 10 doesn't seem to work yet (maybe due to https://github.com/microsoft/WSL/issues/689)
  • On Linux I got No sound devices found even though it works fine on the host
  • On macOS I got [2021-06-14T15:36:27.974Z] docker: Error response from daemon: error gathering device information while adding custom device "/dev/snd": no such file or directory.

This is a minor inconvenience, but it'd be nice if all VSLilyPond features worked inside containers.

jeandeaual avatar Jun 14 '21 15:06 jeandeaual

but it'd be nice if all VSLilyPond features worked inside containers.

I agree--I think overall piping audio out from a container into the host system is a challenge; however, I'll look into it deeper.

I currently only have a Ubuntu 20.04 (x64) and Win10 (x64) machine. I am able to replicate the Windows 10 behaviour--I assume on Ubuntu it would be as you observed on Arch. I will soon obtain whatever 16 inch device comes with Apple silicon to test.

Thanks so much for testing this!

lhl2617 avatar Jun 14 '21 16:06 lhl2617