Skip to content

Commit

Permalink
Merge branch 'pyinstaller' for version v2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jobor019 committed Apr 26, 2021
2 parents c7d7abf + 427cc37 commit 45f1a22
Show file tree
Hide file tree
Showing 19 changed files with 3,150 additions and 358 deletions.
Binary file modified Introduction Somax.pdf
Binary file not shown.
158 changes: 94 additions & 64 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
PYLIBPATH = python/somax
MAXLIBPATH = max/somax
PY_LIB_PATH = python/somax
MAX_LIB_PATH = max/somax

PYINSTALLER_PATH = pyinstaller
PYINSTALLER_TARGET = $(PYLIBPATH)/somax_server.py
PYINSTALLER_TARGET = $(PY_LIB_PATH)/somax_server.py
PYINSTALLER_TARGET_NAME = somax_server

MAX_PYINSTALLER_LIBRARY = dist/max_pyinstaller_pkg

MAX_PYTHON_RELEASE_PATH = release
MAX_PYTHON_RELEASE_FOLDER = $(MAX_PYTHON_RELEASE_PATH)/Somax2
MAX_PYTHON_RELEASE_DMG = release_dmg
LIB_BUILD_PATH=build/$(MAX_PYTHON_RELEASE_PATH)
LIB_BUILD_FOLDER=build/$(MAX_PYTHON_RELEASE_FOLDER)


MAX_STANDALONE_FOLDER = dist/standalone
MAX_STANDALONE = ${MAX_STANDALONE_FOLDER}/Somax.app
MAX_BUILD_PARENT_FOLDER = build/somax
MAX_BUILD_PATH = $(MAX_BUILD_PARENT_FOLDER)/Somax2
DMG_NAME = Somax2
DMG_PATH = dist/$(DMG_NAME).dmg



Expand All @@ -28,64 +21,101 @@ pyinstaller:
--noconsole \
--name $(PYINSTALLER_TARGET_NAME) \
--exclude-module matplotlib \
--add-data="$(PYLIBPATH)/somax/classification/tables:somax/classification/tables" \
--add-data="$(PYLIBPATH)/log:log" \
--add-data="$(PY_LIB_PATH)/somax/classification/tables:somax/classification/tables" \
--add-data="$(PY_LIB_PATH)/log:log" \
--hidden-import="sklearn.utils._weight_vector" \
--hidden-import="cmath"

max-pyinstaller: pyinstaller
if [ -d $(MAX_PYINSTALLER_LIBRARY) ]; then rm -r $(MAX_PYINSTALLER_LIBRARY); fi
mkdir -p $(MAX_PYINSTALLER_LIBRARY)
cp -r $(MAXLIBPATH) $(MAX_PYINSTALLER_LIBRARY)/somax
cp -r dist/$(PYINSTALLER_TARGET_NAME) $(MAX_PYINSTALLER_LIBRARY)/somax/misc

max-standalone:
@echo "\033[1m####### Optimizing max standalone at ${MAX_STANDALONE} ########\033[0m"
mkdir -p "${MAX_STANDALONE_FOLDER}"
if [ ! -d $(MAX_STANDALONE) ]; then echo "\033[0;31;1mERROR: Manually build a max standalone to ${MAX_STANDALONE} before executing this command\033[0m" && exit 1; fi
rm $(MAX_STANDALONE)/Contents/Resources/MaxPluginScanner
rm -r "${MAX_STANDALONE}/Contents/Resources/C74/media"
rm -r "${MAX_STANDALONE}/Contents/Resources/C74/externals/jitter"
rm -r "${MAX_STANDALONE}/Contents/Resources/C74/externals/m4l"
rm -r "${MAX_STANDALONE}/Contents/Resources/C74/externals/max"
mkdir -p "${MAX_STANDALONE}/Contents/Resources/misc"
cp -r "dist/${PYINSTALLER_TARGET_NAME}" "${MAX_STANDALONE}/Contents/Resources/misc/${PYINSTALLER_TARGET_NAME}"
cp "${MAXLIBPATH}/misc/launch_server" "${MAX_STANDALONE}/Contents/Resources/misc"

max-standalone-dmg:
codesignature:
codesign --deep --timestamp -s "Developer ID Application: INST RECHER COORD ACOUST MUSICALE" --options=runtime --entitlements codesign/somax.entitlements dist/"$(PYINSTALLER_TARGET_NAME)".app
hdiutil create dist/Somax2.dmg -fs HFS+ -srcfolder dist/somax_server.app -ov
xcrun altool --notarize-app --primary-bundle-id "ircam.repmus.somax" -u "[email protected]" -p $(security find-generic-password -w -a $LOGNAME -s "somax_app_specific") --file "(DMG_PATH)"
@echo "\033[1mNOTE: You will still have to do the final step manually once notarization has been approved:\n xcrun stapler staple dist/somax_server.app\033[0m"

max-package: clean
@echo "\033[1mMAKE SURE THAT THE EXTERNAL HAS BEEN CODESIGNED BEFORE CALLING THIS COMMAND. ORDER SHOULD BE:\n make pyinstaller\n make codesignature (+ stapler once finished)\n make max-package\033[0m"
mkdir -p "$(MAX_BUILD_PARENT_FOLDER)"
cp -r "$(MAX_LIB_PATH)" "$(MAX_BUILD_PATH)"
# clean up local items
rm -rf "$(MAX_BUILD_PATH)"/state/*
rm -rf "$(MAX_BUILD_PATH)"/corpus/_*
rm -rf "$(MAX_BUILD_PATH)/misc/launch_local"
# copy binary (should already be codesigned)
cp -r "dist/$(PYINSTALLER_TARGET_NAME).app" "$(MAX_BUILD_PATH)/misc/"
cp LICENSE README.md "Introduction Somax.pdf" "$(MAX_BUILD_PATH)"
create-dmg \
--volname "Somax Installer" \
--volname "$(DMG_NAME)" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--icon "Somax.app" 200 190 \
--hide-extension "Somax.app" \
--app-drop-link 600 185 \
"Somax-Installer.dmg" \
"${MAX_STANDALONE_FOLDER}"
# --volicon "application_icon.icns" \
# --background "installer_background.png"
mv Somax-Installer.dmg "${MAX_STANDALONE_FOLDER}"

max-python-dmg:
if [ -d $(LIB_BUILD_PATH) ]; then rm -r $(LIB_BUILD_PATH); fi
mkdir -p $(LIB_BUILD_FOLDER)
cp -RP max python README.md LICENSE somax2.maxpat tutorial.maxpat $(LIB_BUILD_FOLDER)
cp dist/$(PYINSTALLER_TARGET_NAME) $(LIB_BUILD_FOLDER)/max/somax/misc/
create-dmg \
--volname "Somax2" \
--window-pos 200 120 \
--window-size 800 400 \
--icon "Somax2" 200 190 \
--icon "$(DMG_NAME)" 200 190 \
--hide-extension "$(DMG_NAME)" \
--background "media/dmg_installer_background.png" \
"Somax2.dmg" \
$(LIB_BUILD_PATH)
mkdir -p dist/somax2-release/
mv Somax2.dmg dist/somax2-release
"$(DMG_PATH)" \
"$(MAX_BUILD_PARENT_FOLDER)"

clean:
rm -rf build
rm -rf "$(PYINSTALLER_TARGET_NAME)".spec
rm -rf "dist/rw.$(DMG_NAME).dmg"
rm -rf "$(DMG_PATH)"
@echo "\033[1mNOTE: This command does not remove the dist/ folder to avoid accidental removal of the codesigned external.\nTo perform a full clean, run make clean-all\033[0m"


clean-all: clean
rm -rf dist



# max-pyinstaller: pyinstaller
# if [ -d $(MAX_PYINSTALLER_LIBRARY) ]; then rm -r $(MAX_PYINSTALLER_LIBRARY); fi
# mkdir -p $(MAX_PYINSTALLER_LIBRARY)
# cp -r $(MAXLIBPATH) $(MAX_PYINSTALLER_LIBRARY)/somax
# cp -r dist/$(PYINSTALLER_TARGET_NAME) $(MAX_PYINSTALLER_LIBRARY)/somax/misc
#
# max-standalone:
# @echo "\033[1m####### Optimizing max standalone at ${MAX_STANDALONE} ########\033[0m"
# mkdir -p "${MAX_STANDALONE_FOLDER}"
# if [ ! -d $(MAX_STANDALONE) ]; then echo "\033[0;31;1mERROR: Manually build a max standalone to ${MAX_STANDALONE} before executing this command\033[0m" && exit 1; fi
# rm $(MAX_STANDALONE)/Contents/Resources/MaxPluginScanner
# rm -r "${MAX_STANDALONE}/Contents/Resources/C74/media"
# rm -r "${MAX_STANDALONE}/Contents/Resources/C74/externals/jitter"
# rm -r "${MAX_STANDALONE}/Contents/Resources/C74/externals/m4l"
# rm -r "${MAX_STANDALONE}/Contents/Resources/C74/externals/max"
# mkdir -p "${MAX_STANDALONE}/Contents/Resources/misc"
# cp -r "dist/${PYINSTALLER_TARGET_NAME}" "${MAX_STANDALONE}/Contents/Resources/misc/${PYINSTALLER_TARGET_NAME}"
# cp "${MAXLIBPATH}/misc/launch_server" "${MAX_STANDALONE}/Contents/Resources/misc"
#
# max-standalone-dmg:
# create-dmg \
# --volname "Somax Installer" \
# --window-pos 200 120 \
# --window-size 800 400 \
# --icon-size 100 \
# --icon "Somax.app" 200 190 \
# --hide-extension "Somax.app" \
# --app-drop-link 600 185 \
# "Somax-Installer.dmg" \
# "${MAX_STANDALONE_FOLDER}"
# # --volicon "application_icon.icns" \
# # --background "installer_background.png"
# mv Somax-Installer.dmg "${MAX_STANDALONE_FOLDER}"
#
# max-python-dmg:
# if [ -d $(LIB_BUILD_PATH) ]; then rm -r $(LIB_BUILD_PATH); fi
# mkdir -p $(LIB_BUILD_FOLDER)
# cp -RP max python README.md LICENSE somax2.maxpat tutorial.maxpat $(LIB_BUILD_FOLDER)
# cp dist/$(PYINSTALLER_TARGET_NAME) $(LIB_BUILD_FOLDER)/max/somax/misc/
# create-dmg \
# --volname "Somax2" \
# --window-pos 200 120 \
# --window-size 800 400 \
# --icon "Somax2" 200 190 \
# --background "media/dmg_installer_background.png" \
# "Somax2.dmg" \
# $(LIB_BUILD_PATH)
# mkdir -p dist/somax2-release/
# mv Somax2.dmg dist/somax2-release



clean:
rm -r dist
rm -r build
rm *.spec
72 changes: 39 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,71 @@
# Somax II
Somax II is an application for musical improvisation and composition. It is implemented in [Max](https://cycling74.com/products/max/) and is based on a generative model using a process similar to concatenative synthesis to provide stylistically coherent improvisation, while in real-time listening to and adapting to a musician (or any other type of audio or MIDI source). The model is operating in the symbolic domain and is trained on a musical corpus, consisting of one or mulitple MIDI files, from which it draws its material used for improvisation. The model can be used with little configuration to autonomously interact with a musician, but it also allows manual control of its generative process, effectively letting the model serve as an instrument that can be played in its own right.
Somax II is an application for musical improvisation and composition. It is implemented in [Max](https://cycling74.com/products/max/) and is based on a generative model using a process similar to concatenative synthesis to provide stylistically coherent improvisation, while in real-time listening to and adapting to a musician (or any other type of audio or MIDI source). The model is operating in the symbolic domain and is trained on a musical corpus, consisting of one or multiple MIDI files, from which it draws its material used for improvisation. The model can be used with little configuration to autonomously interact with a musician, but it also allows manual control of its generative process, effectively letting the model serve as an instrument that can be played in its own right.

While the application can be used straight out of the box with little configuration (see [Getting Started](#Getting-started)), it is also designed as a library, allowing the user to create custom models as well as set up networks of multiple models and sources that are listening to and interacting with each other.

This project is under development. Documentation will be added continuously.

## Requirements

* macOS 10.14 or later (may work with earlier versions but has not been tested)
* macOS 10.15 or later (may work with earlier versions but has not been tested)
* Max 7 or later
* Python 3.7 or later
* ~~Python 3.7 or later~~ (only needed for manual installation)
* CNMAT Externals for Max (can be installed through the Max Package Manager)

## Installation

### Step 1: Install Somax
* Go to [Releases](https://github.com/DYCI2/Somax2/releases) and download the latest version of Somax
### Easy Installation
This is the path recommended for most users, unless you explicitly want to modify the python code.
* Go to [Releases](https://github.com/DYCI2/Somax2/releases) and download the latest version of Somax 2 (`Somax-v2_x_x.dmg`)
* Copy the extracted `Somax2` folder into the `Packages` folder in your Max folder (by default, this is `"~/Documents/Max 8/Packages"`)
* Depending on your Max configuration, you may have to go into Max and add the path to the `Somax2` folder to your file path. This is done by selecting Options -> File Preferences..., pressing the "+" button followed by the "choose" button, navigating to the `Somax2` folder. Also make sure that the "Subfolders" box is checked.

### Step 2: Install Python
*This step can be skipped if you already have Python 3.7+ installed*
* Go to [https://www.python.org/downloads/](https://www.python.org/downloads/) to download the latest version of Python (currently 3.9.0)
* Install Python by following the steps in the downloaded installer

### Step 3: Install Python Requirements
* From a Terminal app window, change directory (`cd`) to the `python/somax` folder inside the `Somax2` folder
* Install the requirements with `pip3 install -r requirements.txt`

For example, using the default Max folder, type :
* Go to the Max Package Manager inside Max and install the «CNMAT Externals for Max» package
* You're done! Now, have a look at the [Getting Started](#getting-started) section on where to go next!

cd ~/Documents/Max\ 8/Packages/Somax2/python/somax

pip3 install -r requirements.txt
### Manual Installation:
If you want to modify the python code, you will need a manual installation. This assumes you already have python 3.7+ installed.
#### Step 1: Install Somax
* Clone the master branch of this repository or go to [Releases](https://github.com/DYCI2/Somax2/releases) and download the latest version of the Somax source code.
* Add the `max/somax` folder to your Max path, either by symlinking it to `~/Documents/Max 8/Packages` or through Options -> File Preferences in Max. If the latter, make sure that the `subfolders` option is checked.

A number of packages should now be installing. If the installation terminates without any errors, somax and all of its dependencies will now be successfully installed
#### Step 2: Install Python Requirements
* From the root folder, install the requirements with `pip3 install -r python/somax/requirements.txt`

### Step 4: Install Max requirements
#### Step 3: Install Max requirements
* If not already installed, make sure to go to the package manager inside Max and install CNMAT Externals

## Getting Started
A good starting point is the file `Introduction Somax.pdf`, which gives a brief overview of how the Somax interaction model works. For those who prefer a hands-on experience, it's also possible to jump directly into the tutorial, found in the file `tutorial.maxpat` in the root folder. This tutorial gives a brief introduction to the different modules of Somax II and introduces the first steps towards interacting with the model.
The main Somax application is the patch `somax2.maxpat`. You can open this patch from inside Max or by opening it directly from Finder.

It is recommended to first follow the interactive tutorial by opening the `tutorial.maxpat` patch. This tutorial gives a brief introduction to the different modules of Somax and introduces the first steps towards interacting with the model.

A good starting point in understanding Somax is the document `Introduction Somax.pdf`, which gives a brief overview of how the Somax interaction model works.

**Note that the first time you launch Somax, depending on your security settings you may be presented with a number of dialogues asking you to give permission to a number of externals (shell, bonk, ircamdescriptor, bc.virfun and bc.yinstats) that Somax requires to be able to run. You may also be asked for permission the first time you launch the server (but this step is explained in the tutorial).**

## Resources

* **Introduction to Somax:** The file `Introduction Somax.pdf` is intended as a starting point to give an understanding of how the interaction model of somax.
* **Max help files:** Individual help files exists for each Max object, outlining how to use the object, its parametric controls as well as a number of use cases. The help files can be accessed by pressing the «?» button available in each of the objects or by right-clicking (ctrl-click) the object (inside Max) in the unlocked patcher and selecting "Open Help".
* **Introduction to Somax:** The document `Introduction Somax.pdf` is intended as a starting point to give an understanding of how the interaction model of somax.
* **Max help files:** The main documentation of Somax. Individual help files exists for each Max object, outlining how to use the object, its parametric controls as well as a number of use cases. The help files can be accessed by pressing the «?» button available in each of the objects or by right-clicking (ctrl-click) the object (inside Max) in the unlocked patcher and selecting "Open Help".
* **Videos, Reports and Publications**: Can be found [here](http://repmus.ircam.fr/somax/home).
* **Additional Corpora**: A number of pre-built corpora to use for experimentation are available initially. Further corpora can be found in `max/somax/corpus/Additional-Corpora.zip`. To use those in Somax, extract the archive and move the content of the extracted folder to the `max/somax/corpus/` folder.

Further documentation will be added continuously
Further documentation will be added continuously.

## Credits
Somax (c) Ircam 2012 - 2021
Somax is an original co-creative interaction concept by Gérard Assayag
Early java prototype by Olivier Delerue
Versions 0.1 to 1.3 by Laurent Bonnasse-Gahot
Versions 1.4 to 1.9  by Axel Chemla-Romeu-Santos
Version 2.0 and following by Joakim Borg
Somax 2 (c) Ircam 2012-2021

Somax 2 is a renewed version of the Somax reactive co-improvisation paradigm by G. Assayag.
Architecture, UI and code completely redesigned and written by Joakim Borg in Max and Python.

Legacy:
* Early Java prototype by Olivier Delerue: adding reactivity to OMax.
* Versions 0.1 to 1.3 by Laurent Bonnasse-Gahot: conception of the reactive memory and  influence  dimensions model.
* Versions 1.4 to 1.9  by Axel Chemla-Romeu-Santos: separation of the Python server and object oriented design.

The Somax 2 project  is part of the ANR project MERCI (Mixed Musical Reality with Creative Instruments) and the ERC project REACH (Raising Co-creativity in Cyber-Human Musicianship).

PI : Gérard Assayag
Music Representation Team
IRCAM STMS Lab (CNRS, Sorbonne University, Ministry of Culture).

Original corpus creation: B. Borron & B. Magnien, (improvisation on ten jazz standards)
Original corpus creation: Carine Bonnefoy (Improvisation on Intuition by C. Bonnnefoy)
Loading

0 comments on commit 45f1a22

Please sign in to comment.