Skip to content

Commit

Permalink
add sources
Browse files Browse the repository at this point in the history
  • Loading branch information
dszakallas committed Feb 27, 2019
1 parent 1df12b1 commit 276f0dc
Show file tree
Hide file tree
Showing 82 changed files with 13,175 additions and 1,077 deletions.
10 changes: 0 additions & 10 deletions res/controllers/novation-launchpad/.babelrc

This file was deleted.

1 change: 1 addition & 0 deletions res/controllers/novation-launchpad/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
node_modules
flow-typed
2 changes: 1 addition & 1 deletion res/controllers/novation-launchpad/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016 - forever Dávid Szakállas (szdavid92@users.github.com)
Copyright (c) 2018 Dávid Szakállas
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
Expand Down
65 changes: 45 additions & 20 deletions res/controllers/novation-launchpad/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SHELL := $(shell which zsh || which bash)
SHELL := $(shell which bash) -O globstar -O extglob -c

empty :=
space := $(empty) $(empty)
Expand All @@ -7,64 +7,89 @@ join-with = $(subst $(space),$1,$(strip $2))

device = $(call join-with,\ ,$(shell jq -r .controller.device packages/$(1)/package.json))
manufacturer = $(call join-with,\ ,$(shell jq -r .controller.manufacturer packages/$(1)/package.json))
mapping = $(buildDir)/$(call manufacturer,$(1))\ $(call device,$(1)).midi.xml
script = $(buildDir)/$(call manufacturer,$(1))-$(call device,$(1))-scripts.js
path = $(call join-with,\ ,$(shell jq -r .controller.path packages/$(1)/package.json))
mapping = $(builddir)/$(call manufacturer,$(1))\ $(call device,$(1)).midi.xml
script = $(builddir)/$(call manufacturer,$(1))-$(call device,$(1))-scripts.js

arch := $(shell uname)

# List the default Resource directories of Mixxx on different architectures
installDirDarwin := $(HOME)/Library/Application\ Support/Mixxx
installDirLinux := $(HOME)/.mixxx

installDir ?= $(installDir$(arch))

package := ./package.json
buildDir := ./dist
builddir ?= ./dist
version := $(shell jq -r .version package.json)

scriptFiles = $(shell ls packages/*/!(node_modules)/**/*.js)
mappingFiles = $(package) packages/$(1)/$(path)/buttons.js packages/$(1)/$(path)/template.xml.ejs

targets := $(shell jq -r '.controllers | join (" ")' package.json)

define targetScriptRules
$(call script,$(1)) : $(shell ls packages/**/*.js)
$(call script,$(1)) : $(scriptFiles)
./scripts/compile-scripts.js $(1) "$$@"
endef

define targetMappingRules
$(call mapping,$(1)) : $(package) packages/$(1)/buttons.js packages/$(1)/template.xml.ejs
$(call mapping,$(1)) : $(mappingFiles)
./scripts/compile-mapping.js $(1) "$$@"
endef

define compileRule
compile : $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target)))
.DEFAULT : compile
.PHONY : compile
endef

define installRule
install : install_$(arch)

install_Darwin : $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target)))
cp $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target))) $$(HOME)/Library/Application\ Support/Mixxx/controllers
.PHONY : install_Darwin

install_Linux : $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target)))
cp $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target))) $$(HOME)/.mixxx/controllers
.PHONY : install_Linux
install : $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target)))
cd $$(installDir) && mkdir -p controllers
cp $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target))) $$(installDir)/controllers

.PHONY : install
endef

define releaseRule
mixxx-launchpad-$(version) : $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target)))
zip -9 $$@.zip $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target)))
$(builddir)/mixxx-launchpad-$(version).zip : $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target))) | $(builddir)
zip -j -9 $$@ $(foreach target,$(1),$(call mapping,$(target)) $(call script,$(target)))
endef

default : compile
.PHONY : default

$(builddir):
mkdir -p $@

$(foreach target,$(targets),$(eval $(call targetScriptRules,$(target))))
$(foreach target,$(targets),$(eval $(call targetMappingRules,$(target))))
$(eval $(call compileRule,$(targets)))
$(eval $(call installRule,$(targets)))
$(eval $(call releaseRule,$(targets)))

release : mixxx-launchpad-$(version)
release : $(builddir)/mixxx-launchpad-$(version).zip
.PHONY : release

test :
npm run lint
npm run check
.PHONY : test

watch_install :
@echo Stop watching with Ctrl-C
@sleep 1 # Wait a bit so users can read
@$(MAKE) install
@trap exit SIGINT; fswatch -o $(scriptFiles) $(mappingFiles) | while read; do $(MAKE) install; done
.PHONY : watch_install

watch :
@echo Stop watching with Ctrl-C
@sleep 1 # Wait a bit so users can read
@$(MAKE)
@trap exit SIGINT; fswatch -o $(scriptFiles) $(mappingFiles) | while read; do $(MAKE); done
.PHONY : watch

clean :
rm -rf dist
rm -rf $(builddir) tmp
.PHONY : clean
67 changes: 40 additions & 27 deletions res/controllers/novation-launchpad/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**Flexible and (soon) customizable controller mapping for Launchpad. Make DJing
with Mixxx fun on Launchpad!**

[![Build status](https://img.shields.io/circleci/project/github/szdavid92/mixxx-launchpad.svg)](https://circleci.com/gh/szdavid92/mixxx-launchpad)
[![Build status](https://img.shields.io/circleci/project/github/dszakallas/mixxx-launchpad.svg)](https://circleci.com/gh/dszakallas/mixxx-launchpad)

There's already a Launchpad mapping shipping with Mixxx however it
has several quirks and limitations:
Expand Down Expand Up @@ -35,6 +35,12 @@ So I decided to make one that is more stable, flexible and customizable!
- library navigation 🦄
- LED lights mimic Mixxx UI ✨

## Supported controllers

- Launchpad Pro (Experimental)
- Launchpad Mk2
- Launchpad Mk1

## How to get started

💾 Download the [latest release from here](https://github.com/szdavid92/mixxx-launchpad/releases/latest).
Expand Down Expand Up @@ -199,8 +205,8 @@ Feedback
- **bright yellow**: while nudging with primary speed
- **dim yellow**: while nudging with secondary speed
- **bright red**: while permanently changing pitch with primary speed
- **dim red**: while permanently changing pitch with primary speed
- **dim amber**: while not pressing, and pitch has been altered in that direction
- **dim red**: while permanently changing pitch with secondary speed
- **dim orange**: while not pressing, and pitch has been altered in that direction

#### CUE

Expand Down Expand Up @@ -258,7 +264,7 @@ Feedback

#### KEY SHIFTS

Buttons for temporarily changing pitch, bound left to right, bottom to top. While pressed, they modify the key of
Buttons for temporarily chaning pitch, bound left to right, bottom to top. While pressed, they modify the key of
the track. When pressing multiple, the one later pressed *steals* the modification.

#### LOAD/EJECT
Expand Down Expand Up @@ -360,27 +366,11 @@ Feedback
- **bright green**: loop on
- **dim green**: loop off

## Technical details

### JavaScript

The code is written according to the [ES2015] specification. This is
incompatible with the runtime running in Mixxx so it has to be transpiled back
to ES5, which is done with [Babel] using the es2015 preset. Sadly due to the interpreter's only partial compatibility with the standard [even some ES3 transforms have to be enabled](bad-interpreter). The transpiled code
is then bundled with [browserify] into a so called [standalone] module with the
name `NovationLaunchpad`. Due to the lack of module loading system in the
environment, the bundled code is placed on the global object with the above
name. This works, because the same name is specified in the MIDI mapping XML file, so Mixxx will look for this name, and will call its `init` method upon loading.

### MIDI mapping

The controller mapping is generated from a template like
[this][mapping-template] with [ejs]. The mapping reuses config from the package
description and [buttons.js].
## For developers

### Build

To build you need to have make, a recent Node (>=4), npm and jq.
To build you need to have a make, Node (>=8), bash (>=4.0) and `jq`. Watch tasks require `fswatch`.

The multi-project build is managed with [lerna.js]. You need to install it
globally to make it available on the command line. First clone the repo and
Expand All @@ -389,25 +379,48 @@ install the dependencies:
```
git clone https://github.com/szdavid92/mixxx-launchpad
cd mixxx-launchpad
npm i --global lerna
lerna bootstrap
npm install
```

You can also invoke lerna commands through npm like `npm run lerna -- --version`.
To compile the sources run

```
make compile
make -j 4
```

(`-j 4` will enable 4 jobs to be executed in parallel which makes the build significantly faster)

Afterward the `dist` folder will contain the files that need to be
copied the Mixxx's controller folder.

```
make install
make -j 4 install
```
does this for you on macOS and Linux.

These two tasks have watch counterparts making them rerun automatically on file changes. This is handy during development:

```
make watch
make watch_install
```

### JavaScript

The code is written according to the [ES2015] specification. This is
incompatible with the runtime running in Mixxx so it has to be transpiled back
to ES5, which is done with [Babel] using the es2015 preset. Sadly due to the interpreter's only partial compatibility with the standard [even some ES3 transforms have to be enabled](bad-interpreter). The transpiled code
is then bundled with [browserify] into a so called [standalone] module with the
name `NovationLaunchpad`. Due to the lack of module loading system in the
environment, the bundled code is placed on the global object with the above
name. This works, because the same name is specified in the MIDI mapping XML file, so Mixxx will look for this name, and will call its `init` method upon loading.

### MIDI mapping

The controller mapping is generated from a template like
[this][mapping-template] with [ejs]. The mapping reuses config from the package
description and [buttons.js].

### Known Issues

#### No Windows build recipes
Expand Down
12 changes: 12 additions & 0 deletions res/controllers/novation-launchpad/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
presets: [
['@babel/preset-env', { 'modules': false }]
],
plugins: [
'transform-es3-member-expression-literals',
'transform-es3-property-literals',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-flow-strip-types',
['@babel/plugin-transform-runtime', { useESModules: true }]
]
}
2 changes: 1 addition & 1 deletion res/controllers/novation-launchpad/lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "2.0.0-beta.38",
"lerna": "2.9.1",
"packages": [
"packages/*"
],
Expand Down
Loading

0 comments on commit 276f0dc

Please sign in to comment.