Skip to content

Commit

Permalink
Collaborate in Mercury via FLOK!
Browse files Browse the repository at this point in the history
  • Loading branch information
tmhglnd committed Dec 5, 2020
1 parent e105a4e commit de38e48
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 12 deletions.
46 changes: 43 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Programmed in the Cycling'74 Max8 node-based creative coding environment, as an
- [Newest Features](#-newest-features)
- [About](#-about)
- [Vision & Goals](#-vision--goals)
- [Collaborative Coding](#-collaborative-coding)
- [Install](#-install)
- [Quick Start](/docs/quick-start.md)
- [Tutorial](/docs/tutorial.md)
Expand All @@ -45,12 +46,13 @@ Programmed in the Cycling'74 Max8 node-based creative coding environment, as an

## 🎉 Newest Features

**Sample can now change the pitch with the note method instead of using speed by setting useNote to true**
**Control external midi devices or send midi to other Applications with the new `midi` instrument**

```java
ring aMelody [0 5 7 3 -1]
set midi getPorts
//=> prints the available devices to the console

new sample pluck_c time(1/4) useNote(1) note(aMelody 0)
new midi "Your Awesome Midi Device" time(1/4) note(7 1) length(100) gain(0.8)
```

**Input OSC addresses as arguments or output osc-messages in a similar way as using instruments**
Expand Down Expand Up @@ -101,6 +103,44 @@ Mercury uses the [Total Serialism NodeJS](https://github.com/tmhglnd/total-seria

Mercury is a development-in-progress and the language is still very much fluid, with changes made to the language/environment/libraries almost weekly. Feel free the clone/fork this repository, but you might also want to watch and/or star the repo to keep up-to-date with the latest changes whenever they're made.

## 👩‍💻👨‍💻 Collaborative Coding

It is now possible to code together in Mercury using the amazing [**Flok**](https://flok.clic.cf/) live coding environment for the browser.

There are 3 options for how you can use Flok with Mercury:
1. Use Flok to combine Mercury with Hydra visuals (or other languages like Tidal, Foxdot and SuperCollider) on a localhost
2. Collaborate together in the same room (only requires 1 computer to run Mercury)
3. Collaborate remotely over a network (all computers need to run Mercury)

Install NodeJS v.12 [for Mac](https://nodejs.org/dist/latest-v12.x/node-v12.20.0.pkg) or [for Windows](https://nodejs.org/dist/latest-v12.x/node-v12.20.0-x64.msi).

Install the latest version of Mercury via the [quick start quide](https://github.com/tmhglnd/mercury/blob/master/docs/quick-start.md).

Install Flok via the Terminal with `npm install -g flok-web flok-repl`

**Localhost**

1. Run `flok-web` in the terminal
2. Open Google Chrome and go to `localhost:3000`
3. Setup Flok with target `mercury` (and optionally other targets like `hydra`) and click **Create session**.
4. Copy the `flok-repl -H xxx -s xxx -t mercury` command and run in the terminal.
5. **Join** the Flok with your nickname.

**Collaborate**

Now follow these steps for a succesful setup.
1. Open Google Chrome and go to [https://flok.clic.cf/](https://flok.clic.cf/)
1. Setup Flok with target `mercury` and click **Create session**.
2. Copy the `flok-repl -H xxx -s xxx -t mercury` command and run in the terminal.
4. **Join** the Flok with your nickname.

Now start typing some code! 🎵

- `Ctrl/Alt + Return` to evaluate
- `Ctrl/Alt + .` to silence

Flok will send the entire code via OSC messaging to port 4880. Mercury should be listening to this port automatically. Bug reports are very much welcome in the issues!

## 💻 Install

- Follow the [Quick Start](./docs/quick-start.md) guide (for experienced computer users)
Expand Down
7 changes: 6 additions & 1 deletion mercury_ide/code/mercury.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,15 @@ function mainParse(lines){

let cleaned = [];
lines.forEach((line) => {
// post('@input', line);
// remove comments from code
line = line.replace(/\/{2,}.+/g, '');

// remove linebreaks and split into array
// split double coded lines via '&' symbol
line = line.split('&');
line = line.match(/[^&\r\n]+/g);
if (!line) { return; }
// line = line.split('&');

line.forEach((l) => {
// remove double whitespaces
Expand Down
16 changes: 8 additions & 8 deletions mercury_ide/patchers/_mercury_main.maxpat
Original file line number Diff line number Diff line change
Expand Up @@ -44686,7 +44686,7 @@
}
,
"classnamespace" : "box",
"rect" : [ 34.0, 185.0, 789.0, 639.0 ],
"rect" : [ 34.0, 184.0, 789.0, 639.0 ],
"bglocked" : 0,
"openinpresentation" : 0,
"default_fontsize" : 12.0,
Expand Down Expand Up @@ -44752,12 +44752,12 @@
, {
"box" : {
"id" : "obj-14",
"linecount" : 3,
"linecount" : 4,
"maxclass" : "comment",
"numinlets" : 1,
"numoutlets" : 0,
"patching_rect" : [ 480.0, 60.0, 139.0, 47.0 ],
"text" : "Get code from Troop Collaborative livecoding environment"
"patching_rect" : [ 480.0, 60.0, 139.0, 60.0 ],
"text" : "Get code from external Collaborative livecoding environment via OSC\nlike Troop or Flok"
}

}
Expand Down Expand Up @@ -45095,8 +45095,6 @@
"saved_object_attributes" : {
"autostart" : 1,
"defer" : 0,
"node_bin_path" : "",
"npm_bin_path" : "",
"watch" : 1
}
,
Expand Down Expand Up @@ -51898,6 +51896,8 @@
"saved_object_attributes" : {
"autostart" : 0,
"defer" : 1,
"node_bin_path" : "",
"npm_bin_path" : "",
"watch" : 1
}
,
Expand Down Expand Up @@ -66535,13 +66535,13 @@
"presentation_rect" : [ 210.0, 259.5, 135.0, 47.0 ],
"saved_attribute_attributes" : {
"valueof" : {
"parameter_shortname" : "volume",
"parameter_type" : 0,
"parameter_unitstyle" : 4,
"parameter_mmin" : -70.0,
"parameter_longname" : "volume",
"parameter_mmax" : 6.0,
"parameter_initial" : [ 0.0 ]
"parameter_initial" : [ 0.0 ],
"parameter_shortname" : "volume"
}

}
Expand Down

0 comments on commit de38e48

Please sign in to comment.