Skip to content

Commit

Permalink
Merge pull request #530 from vcync/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
TimPietrusky authored Dec 31, 2020
2 parents 14d5cea + 8d10241 commit d8e29dd
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"animated-gif-detector": "^1.2.0",
"animejs": "3.2.0",
"aws-sdk": "^2.580.0",
"canvas-text-wrapper": "^0.10.2",
"canvas-text-wrapper": "github:cyberj/canvas-text-wrapper#master",
"color": "^3.1.2",
"core-js": "^2.6.10",
"dotenv": "^8.2.0",
Expand Down
37 changes: 25 additions & 12 deletions src/application/sample-modules/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,26 @@ export default {
}
},

positionX: {
offsetX: {
type: "float",
default: 0.5,
max: 1,
min: 0,
strict: true
default: 0,
max: 100,
min: -100,
step: 1,
set(args) {
this.drawText(args);
}
},

positionY: {
offsetY: {
type: "float",
default: 0.5,
max: 1,
min: 0,
strict: true
default: 0,
max: 100,
min: -100,
step: 1,
set(args) {
this.drawText(args);
}
},

strokeSize: {
Expand Down Expand Up @@ -132,7 +138,9 @@ export default {
stroke,
strokeColor,
fillColor,
fill
fill,
offsetX,
offsetY
} = props;

const {
Expand All @@ -150,11 +158,16 @@ export default {
context.lineWidth = strokeSize;
context.clearRect(0, 0, width, height);

const calculatedOffsetX = (width / 100) * offsetX;
const calculatedOffsetY = (height / 100) * offsetY;

CanvasTextWrapper(canvas, text, {
font: `${weight} ${size}px ${font}`,
verticalAlign: "middle",
textAlign: "center",
strokeText: stroke
strokeText: stroke,
offsetX: calculatedOffsetX,
offsetY: calculatedOffsetY
});
}
};
54 changes: 47 additions & 7 deletions src/application/setup-midi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ let store;
const clockHistory = [];
const diffHistory = [];
let nextBpmUpdate = 0;
const TYPE_NOTEON = 144;
const TYPE_CC = 176;

// create a new audioContext to use intead of modV's
// existing context - we get timing jitters otherwise
Expand Down Expand Up @@ -30,7 +32,7 @@ function handleInput(message) {
return;
}

const { listenForClock, listenForInput } = device;
const { listenForClock, listenForInput, ccLatch, noteOnLatch } = device;

// clock
if (type === 248 && listenForClock) {
Expand Down Expand Up @@ -78,14 +80,52 @@ function handleInput(message) {
}
}
} else if (listenForInput) {
store.commit("midi/WRITE_DATA", {
id: `${id}-${name}-${manufacturer}`,
type,
channel,
data: type === 176 ? data / 127 : data
});
let commitValue = true;
let _data = data;
let _type = type;

// Overwrite the default behavior for ControlChange messages so that they
// behave like NoteOn
if (_type === TYPE_CC && ccLatch) {
_type = TYPE_NOTEON;
}

if (_type === TYPE_NOTEON) {
// We want to know when the button was pressed
if (data > 0) {
if (device.channelData !== undefined && device.channelData[channel]) {
_data = device.channelData[channel][_type] === 1 ? 0 : 1;

// Set the inital value if no value exists yet
} else {
_data = 1;
}

// Don't commit the value as this is "NoteOff" and we want
// to make sure that the button is not deactivated when it's
// released by the user
} else if (noteOnLatch) {
commitValue = false;
}
}

if (_type === TYPE_CC) {
_data = _data / 127;
}

if (commitValue) {
store.commit("midi/WRITE_DATA", {
id: `${id}-${name}-${manufacturer}`,
type: _type,
channel,
data: _data
});
}

if (store.state.midi.learning) {
// Make sure to use the overwritten type
message.data[0] = _type;

store.state.midi.learning(message);
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/application/worker/store/modules/midi.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ const mutations = {
manufacturer,
channelData: {},
listenForInput: true,
listenForClock: false
listenForClock: false,
ccLatch: false,
noteOnLatch: false
});
},

Expand All @@ -58,7 +60,13 @@ const mutations = {
},

SET_STATE(state, newState) {
state = { ...newState };
const keys = Object.keys(newState);

for (let i = 0, len = keys.length; i < len; i++) {
const key = keys[i];

state[key] = newState[key];
}
}
};

Expand Down
38 changes: 36 additions & 2 deletions src/components/InputDeviceConfig/MIDI.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
>
<c span="1">MIDI Inputs</c>
<c span="1..">
<grid columns="4">
<grid columns="5">
<c>Name</c>
<c>Input</c>
<c>Clock</c>
<c>CC Latch</c>
<c>NoteOn Latch</c>
</grid>
</c>
<c span="1.." v-for="(device, deviceId) in devices" :key="deviceId">
<grid columns="4">
<grid columns="5">
<c>{{ device.name }}</c>
<c>
<Button
Expand All @@ -36,6 +38,22 @@
{{ device.listenForClock ? "On" : "Off" }}
</Button>
</c>
<c>
<Button
class="light"
@click="toggleCcLatch(deviceId, !device.ccLatch)"
>
{{ device.ccLatch ? "On" : "Off" }}
</Button>
</c>
<c>
<Button
class="light"
@click="toggleNoteOnLatch(deviceId, !device.noteOnLatch)"
>
{{ device.noteOnLatch ? "On" : "Off" }}
</Button>
</c>
</grid>
</c>
</grid>
Expand Down Expand Up @@ -72,6 +90,22 @@ export default {
key: "listenForClock",
value
});
},
toggleCcLatch(id, value) {
this.$modV.store.commit("midi/UPDATE_DEVICE", {
id,
key: "ccLatch",
value
});
},
toggleNoteOnLatch(id, value) {
this.$modV.store.commit("midi/UPDATE_DEVICE", {
id,
key: "noteOnLatch",
value
});
}
}
};
Expand Down
7 changes: 3 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2632,10 +2632,9 @@ caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001043, caniuse-lite@^1.0.30001061:
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001084.tgz#00e471931eaefbeef54f46aa2203914d3c165669"
integrity sha512-ftdc5oGmhEbLUuMZ/Qp3mOpzfZLCxPYKcvGv6v2dJJ+8EdqcvZRbAGOiLmkM/PV1QGta/uwBs8/nCl6sokDW6w==

canvas-text-wrapper@^0.10.2:
version "0.10.2"
resolved "https://registry.yarnpkg.com/canvas-text-wrapper/-/canvas-text-wrapper-0.10.2.tgz#cf00996c131c0eac3de25cbf4a56d07d1da2b0c3"
integrity sha512-nFnN8q8ydtkBUWVn/dAdetpwNOkz3KtyD6jTI2HGD43ant2FQcnLugAVaGLJloyRTNK/exn7efpYy2zPV5bHiQ==
"canvas-text-wrapper@github:cyberj/canvas-text-wrapper#master":
version "0.11.0"
resolved "https://codeload.github.com/cyberj/canvas-text-wrapper/tar.gz/5335c7bd6ecadc32756c66137dba6360f67dcffd"

capture-stack-trace@^1.0.0:
version "1.0.1"
Expand Down

0 comments on commit d8e29dd

Please sign in to comment.