Skip to content

Commit

Permalink
Merge pull request #28 from hchiam/fix-pan
Browse files Browse the repository at this point in the history
1.12.3: fix #27 (clamp pan range)
  • Loading branch information
hchiam authored Jan 20, 2021
2 parents 0c809fa + 6553f35 commit 4c926ac
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ You can think of the y dimension as the "proximity dimension" (louder = closer t

```html
<script
src="https://cdn.jsdelivr.net/gh/hchiam/[email protected].0/_2DNote.min.js"
integrity="sha384-WdS+mavw33iD6+LA5WvOOdklYxzu60nE9DdK9RlJITvWzSJPeF8pF1ln7VrWa+yC"
src="https://cdn.jsdelivr.net/gh/hchiam/[email protected].3/_2DNote.min.js"
integrity="sha384-e0d2dNwg3F9WTJ3jZBF5iUeuVyAtx+zwMnCAvKMiCHtwO2l2dzo3cIMO4+Xqwn5p"
crossorigin="anonymous"
></script>
```
Expand All @@ -57,8 +57,8 @@ For quick setup on the `body` tag:
```html
<body>
<script
src="https://cdn.jsdelivr.net/gh/hchiam/[email protected].0/_2DNote.min.js"
integrity="sha384-WdS+mavw33iD6+LA5WvOOdklYxzu60nE9DdK9RlJITvWzSJPeF8pF1ln7VrWa+yC"
src="https://cdn.jsdelivr.net/gh/hchiam/[email protected].3/_2DNote.min.js"
integrity="sha384-e0d2dNwg3F9WTJ3jZBF5iUeuVyAtx+zwMnCAvKMiCHtwO2l2dzo3cIMO4+Xqwn5p"
crossorigin="anonymous"
></script>
<script>
Expand All @@ -77,8 +77,8 @@ For quick setup of a custom 2D click/touch area:
<div id="2d-area" style="width: 100vw; height: 100vh;">...</div>
...
<script
src="https://cdn.jsdelivr.net/gh/hchiam/[email protected].0/_2DNote.min.js"
integrity="sha384-WdS+mavw33iD6+LA5WvOOdklYxzu60nE9DdK9RlJITvWzSJPeF8pF1ln7VrWa+yC"
src="https://cdn.jsdelivr.net/gh/hchiam/[email protected].3/_2DNote.min.js"
integrity="sha384-e0d2dNwg3F9WTJ3jZBF5iUeuVyAtx+zwMnCAvKMiCHtwO2l2dzo3cIMO4+Xqwn5p"
crossorigin="anonymous"
></script>
<script>
Expand Down
9 changes: 7 additions & 2 deletions _2DNote.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ var _2DNote = (function () {
// e = event or element
var x = this.getX(e);
// technically getting gain (which ranges 0 to 1)
var pan = this.normalize(x, this.viewYRange, this.panRange);
var pan = this.normalize(x, this.viewXRange, this.panRange);
return pan;
}

Expand Down Expand Up @@ -179,7 +179,12 @@ var _2DNote = (function () {
var ratioAdjustment =
(outputRangeMax - outputRangeMin) / (inputRangeMax - inputRangeMin);
var outputBias = outputRangeMin;
return inputBias * ratioAdjustment + outputBias;
var output = inputBias * ratioAdjustment + outputBias;
var clampedOutput = Math.min(
Math.max(output, outputRangeMin),
outputRangeMax
);
return clampedOutput;
}

function copy() {
Expand Down
4 changes: 2 additions & 2 deletions _2DNote.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example-include.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ <h1 id="audio-reminder" aria-hidden="true">Make sure audio is on</h1>

<!-- INCLUDE _2DNote! -->
<script
src="https://cdn.jsdelivr.net/gh/hchiam/_2DNote@1.9.0/_2DNote.min.js"
integrity="sha384-w9KzgKC5k/00txI3ng7+D2iZ/1HiglYG7YpmTdR8NnwbCr+0qcGiaZC1JGzgOWgD"
src="https://cdn.jsdelivr.net/gh/hchiam/_2DNote@1.12.3/_2DNote.min.js"
integrity="sha384-e0d2dNwg3F9WTJ3jZBF5iUeuVyAtx+zwMnCAvKMiCHtwO2l2dzo3cIMO4+Xqwn5p"
crossorigin="anonymous"
></script>
<!-- <script src="_2DNote.min.js"></script> -->
Expand Down
4 changes: 2 additions & 2 deletions example-pong.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@

<!-- INCLUDE _2DNote! -->
<script
src="https://cdn.jsdelivr.net/gh/hchiam/_2DNote@1.9.0/_2DNote.min.js"
integrity="sha384-w9KzgKC5k/00txI3ng7+D2iZ/1HiglYG7YpmTdR8NnwbCr+0qcGiaZC1JGzgOWgD"
src="https://cdn.jsdelivr.net/gh/hchiam/_2DNote@1.12.3/_2DNote.min.js"
integrity="sha384-e0d2dNwg3F9WTJ3jZBF5iUeuVyAtx+zwMnCAvKMiCHtwO2l2dzo3cIMO4+Xqwn5p"
crossorigin="anonymous"
></script>
<!-- <script src="_2DNote.min.js"></script> -->
Expand Down
4 changes: 2 additions & 2 deletions example-two-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ <h1 id="audio-reminder" aria-hidden="true">Make sure audio is on</h1>

<!-- INCLUDE _2DNote! -->
<script
src="https://cdn.jsdelivr.net/gh/hchiam/_2DNote@1.9.0/_2DNote.min.js"
integrity="sha384-w9KzgKC5k/00txI3ng7+D2iZ/1HiglYG7YpmTdR8NnwbCr+0qcGiaZC1JGzgOWgD"
src="https://cdn.jsdelivr.net/gh/hchiam/_2DNote@1.12.3/_2DNote.min.js"
integrity="sha384-e0d2dNwg3F9WTJ3jZBF5iUeuVyAtx+zwMnCAvKMiCHtwO2l2dzo3cIMO4+Xqwn5p"
crossorigin="anonymous"
></script>
<!-- <script src="_2DNote.min.js"></script> -->
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hchiam/2dnote",
"version": "1.12.2",
"version": "1.12.3",
"main": "_2DNote.js",
"unpkg": "_2DNote.min.js",
"author": "hchiam",
Expand Down

0 comments on commit 4c926ac

Please sign in to comment.