From 1e1b5eb6287165805e55c489fb5212561da457bc Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Fri, 2 Jun 2017 19:43:54 -0700 Subject: [PATCH] Fix eqf value normalization --- js/actionCreators.js | 3 ++- js/actionCreators.test.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/js/actionCreators.js b/js/actionCreators.js index 2edbe737..354f34f8 100644 --- a/js/actionCreators.js +++ b/js/actionCreators.js @@ -95,7 +95,8 @@ export function toggleShuffle() { return { type: TOGGLE_SHUFFLE }; } -const normalize = hrz => hrz / 63 * 100; +export const normalize = hrz => Math.round((hrz - 1) / 63 * 100); + function setEqFromFile(file) { return dispatch => { file.processBuffer(arrayBuffer => { diff --git a/js/actionCreators.test.js b/js/actionCreators.test.js index 9d9b026b..51f5eca7 100644 --- a/js/actionCreators.test.js +++ b/js/actionCreators.test.js @@ -18,7 +18,8 @@ import { setEqBand, setEqToMax, setEqToMin, - setEqToMid + setEqToMid, + normalize } from "./actionCreators"; test("stop", () => { @@ -123,3 +124,8 @@ test("setEqToMid", () => { ]); expect(mockDispatch.mock.calls).toEqual(expectedCalls); }); + +test("normalize", () => { + expect(normalize(1)).toBe(0); + expect(normalize(64)).toBe(100); +});