Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux on Mac Development via Docker with Audio/GFX Forwarding #2

Merged
merged 4 commits into from
Mar 2, 2022
Merged
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
Binary file removed .DS_Store
Binary file not shown.
130 changes: 128 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,128 @@
tests/rendered_audio
soundfonts/piano.sf2
# https://github.com/github/gitignore/blob/master/Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Mac / Jetbrain specific ignores
.idea
*.swp
*.DS_Store
src/models

# C extensions
*.so

# Distribution / packaging
.Python
develop-eggs/
dist/
downloads/
eggs/
.eggs/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
102 changes: 102 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
FROM ubuntu:20.04
LABEL maintainer "Nick Bryan <nibryan@adobe.com>"

RUN apt-get update && apt-get install -y \
alsa-utils \
libasound2 \
libasound2-plugins \
pulseaudio \
pulseaudio-utils \
curl \
gnupg \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

# LV2 plugin installs
RUN apt-get update && apt-get install apt-utils -y && apt-get install pkg-config -y && apt-get install wget -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install ubuntustudio-audio-plugins -y && apt-get install libsndfile-dev -y \
&& wget https://sourceforge.net/projects/lsp-plugins/files/lsp-plugins/1.1.19/Linux-x86_64/lsp-plugins-lv2-1.1.19-Linux-x86_64.tar.gz -P /home/temp/ \
&& tar -C /home/temp/ -xvf /home/temp/lsp-plugins-lv2-1.1.19-Linux-x86_64.tar.gz \
&& cp -rf /home/temp/lsp-plugins-lv2-1.1.19-Linux-x86_64/usr/local/lib/lv2/lsp-plugins.lv2 /usr/lib/lv2/ \
&& rm -rf /home/temp \
&& apt-get install dh-autoreconf -y \
&& apt-get install meson -y

# Install lilv from source and other tools
RUN apt-get update && apt-get install lv2proc -y \
&& apt-get install lilv-utils -y \
&& apt-get install lv2-dev -y \
&& apt-get install liblilv-dev -y \
&& apt-get install audacity -y

# Install REAPER
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
&& wget https://www.reaper.fm/files/6.x/reaper649_linux_x86_64.tar.xz \
&& tar -xf reaper649_linux_x86_64.tar.xz \
&& cd reaper_linux_x86_64 \
&& ./install-reaper.sh --install /opt --integrate-desktop --usr-local-bin-symlink --quiet \
&& rm -rf reaper_linux_x86_64 \
&& rm -rf reaper649_linux_x86_64.tar.xz

####### miniconda
ENV PATH /opt/conda/bin:$PATH
RUN wget --quiet https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
RUN /bin/bash ~/miniconda.sh -b -p /opt/conda
RUN rm ~/miniconda.sh
RUN ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh
RUN echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc
RUN echo "conda activate base" >> ~/.bashrc

# Install Carla
# RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
# && wget https://github.com/falkTX/Carla/releases/download/v2.2.0/Carla_2.2.0-linux64.tar.xz \
# && tar -xf Carla_2.2.0-linux64.tar.xz

# Attempt to install OpenGL stuff
# See https://github.com/jessfraz/dockerfiles/issues/253#issuecomment-313995830
RUN apt-get update && apt-get install -y mesa-utils libgl1-mesa-glx


# Supervisor setup
RUN apt-get update && apt-get install -y supervisor openssh-client
RUN mkdir -p /var/log/supervisord
COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY docker/jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py

# Upgrade pip
RUN /bin/bash -c "python -m pip install --upgrade pip"

# Install the JupyterLab IDE
RUN /bin/bash -c "pip install jupyterlab"

# ####### INSTALL CODE SERVER
# # via https://github.com/cdr/code-server/issues/2341#issuecomment-740892890
# RUN /bin/bash -c "curl -fL https://github.com/cdr/code-server/releases/download/v3.8.0/code-server-3.8.0-linux-amd64.tar.gz | tar -C /usr/local/bin -xz"
# RUN /bin/bash -c "mv /usr/local/bin/code-server-3.8.0-linux-amd64 /usr/local/bin/code-server-3.8.0"
# RUN /bin/bash -c "ln -s /usr/local/bin/code-server-3.8.0/bin/code-server /usr/local/bin/code-server"
# # Install Python extension
# RUN /bin/bash -c "wget https://github.com/microsoft/vscode-python/releases/download/2020.10.332292344/ms-python-release.vsix \
# && code-server --install-extension ./ms-python-release.vsix || true"
# # Install C++ extension
# RUN /bin/bash -c "wget https://github.com/microsoft/vscode-cpptools/releases/download/1.1.3/cpptools-linux.vsix \
# && code-server --install-extension ./cpptools-linux.vsix || true"
# # Set VS Code password to None
# #RUN /bin/bash -c "sed -i.bak 's/auth: password/auth: none/' ~/.config/code-server/config.yaml"
# COPY docker/code-server-config.yaml /root/.config/code-server/config.yaml
# # Fix broken python plugin # https://github.com/cdr/code-server/issues/2341
# RUN /bin/bash -c "mkdir -p ~/.local/share/code-server/ && mkdir -p ~/.local/share/code-server/User"
# COPY docker/settings.json /root/.local/share/code-server/User/settings.json
# ####### DONE INSTALL CODE SERVER

ENV HOME /home
RUN usermod -aG audio,pulse,pulse-access root \
&& chown -R root:root $HOME
WORKDIR $HOME

COPY docker/default.pa /etc/pulse/default.pa
COPY docker/client.conf /etc/pulse/client.conf
COPY docker/daemon.conf /etc/pulse/daemon.conf

EXPOSE 8080 8888 8887 443

ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
104 changes: 104 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,107 @@
## msynth

We are using a python package. Therefore, please run : pip install -e msynth , in the directory that is the parent of the msynth folder.



## Developer


### Install pip package

```
# Create a clean conda env
conda create -n msynth python=3.7 -y
conda activate msynth

cd <msynth git repo>

# Install package
pip install -e .

```



## Linux Development on MacOS

* Install [Docker Desktop](https://www.docker.com/products/docker-desktop)
* Install X11 for macOS via [X Quartz](https://github.com/XQuartz/XQuartz/releases/download/XQuartz-2.8.1/XQuartz-2.8.1.dmg)
* Install PulseAudio via homebrew, start the PulseAudio deamon, and verify status:

```
# Install
brew install pulseaudio

# Start daemon
pulseaudio --load=module-native-protocol-tcp --exit-idle-time=-1 --daemon

# Check pulse audio status
pulseaudio --check -v
```

* Configure PulseAudio output via:

```
# List default outputs for pulse audio
pacmd list-sinks

# Set the default output
pacmd set-default-sink <index of sink>
```

* Try to play an audio file via:

```
paplay -p <testfile>.wav
```

* Start Xquartz

```
open -a Xquartz
```

* Configure Xquartz to "Allow connections from network clients"

<!-- * Attempt to allow OpenGL X11 forwarding (doesn't work for me yet)

```
defaults write `quartz-wm --help | awk '/default:.*X11/ { gsub(/\)/, "", $2); print $2}'` enable_iglx -bool true
``` -->

* Whitelist localhost for X11 network connections via paste below on command line

```
/opt/X11/bin/xhost + "127.0.0.1"
```

* Build the docker image into a container
docker-compose up --build -d

* Specify a shared data directory between your local machine and docker to share data
```
export MSYNTH=<path/for/shared/data>
```

* Run an existing image
```
docker-compose up
```

* Open your IDE of choice
* For Jupyter, open a web browser at http://127.0.0.1:8888 (password is dsp).
* For VS Code, install the Docker extension, then attach to the msyth container and use VS Code.
* For command line SSH access, open a second terminal, find the running container id, and enter it
```
docker container ls
docker exec -it <CONTAINER ID> bash
```
* Run Linux applications with audio and graphics forwarding.

Enter your container via the SSH access instructions above and launch. Try running reaper within your Linux container on mac via

```
audacity
reaper
```
23 changes: 23 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: "3.9"
services:
dev:
build: .
ports:
- 8887:8887
- 8888:8888
- 22700:22700
- 8896:8896
- 6006:6006
tty: true
privileged: true
volumes:
- $PWD:/home/code
- $MSYNTH_DATA/:/home/data
- $HOME/.config/pulse:/home/.config/pulse
- $HOME/:/home/mac
environment:
- PULSE_SERVER=docker.for.mac.localhost
- DISPLAY=host.docker.internal:0
user: "0"
volumes:
data:
Loading