mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-24 02:27:37 +00:00
Add winamp-eqf
This commit is contained in:
parent
8c83b78582
commit
0c7b22d7f9
3 changed files with 60 additions and 43 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import parser from "winamp-eqf";
|
||||
import MyFile from "./myFile";
|
||||
import skinParser from "./skinParser";
|
||||
import { BANDS } from "./constants";
|
||||
|
|
@ -94,13 +95,32 @@ export function toggleShuffle() {
|
|||
return { type: TOGGLE_SHUFFLE };
|
||||
}
|
||||
|
||||
const normalize = hrz => hrz / 63 * 100;
|
||||
function setEqFromFile(file) {
|
||||
return dispatch => {
|
||||
file.processBuffer(arrayBuffer => {
|
||||
const eqf = parser(arrayBuffer);
|
||||
const preset = eqf.presets[0];
|
||||
|
||||
// TODO: Fix normalize. Currently these numbers are kinda wrong.
|
||||
dispatch(setPreamp(normalize(preset.preamp)));
|
||||
BANDS.forEach(band => {
|
||||
dispatch(setEqBand(band, normalize(preset[`hz${band}`])));
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const SKIN_FILENAME_MATCHER = new RegExp("(wsz|zip)$", "i");
|
||||
const EQF_FILENAME_MATCHER = new RegExp("eqf$", "i");
|
||||
export function loadFileFromReference(fileReference) {
|
||||
return dispatch => {
|
||||
const file = new MyFile();
|
||||
file.setFileReference(fileReference);
|
||||
if (SKIN_FILENAME_MATCHER.test(fileReference.name)) {
|
||||
dispatch(setSkinFromFile(file));
|
||||
} else if (EQF_FILENAME_MATCHER.test(fileReference.name)) {
|
||||
dispatch(setEqFromFile(file));
|
||||
} else {
|
||||
dispatch({ type: LOAD_AUDIO_FILE, file });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue