Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an extra choice whether to use better BPM method for faster songs. #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions marketplace/cat-jam.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,13 @@
),
f.addDropDown(
"catjam-webm-bpm-method",
"Method to calculate better BPM",
"Method to calculate better BPM for slower songs",
["Track BPM", "Danceability, Energy and Track BPM"],
1
),
f.addDropDown(
"catjam-webm-bpm-method-faster-songs",
"Method to calculate better BPM for faster songs",
["Track BPM", "Danceability, Energy and Track BPM"],
1
),
Expand Down Expand Up @@ -515,8 +521,11 @@
weightedAverage: e,
betterBPM: s,
bpmWeight: o,
}),
s > a && (s = (s + a) / 2);
});
t =
"Track BPM" !==
f.getFieldValue("catjam-webm-bpm-method-faster-songs");
s > a && (s = t ? (s + a) / 2 : a);
s < a && (s = Math.max(s, 70));
return s;
})(r, s, e)))
Expand Down
10 changes: 8 additions & 2 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,13 @@ function calculateBetterBPM(danceability, energy, currentBPM) {

console.log({danceabilityWeight, energyWeight, currentBPM, weightedAverage, betterBPM, bpmWeight})

const betterBPMForFasterSongs = settings.getFieldValue("catjam-webm-bpm-method-faster-songs") !== "Track BPM";
if (betterBPM > currentBPM) {
betterBPM = (betterBPM + currentBPM) / 2;
if (betterBPMForFasterSongs){
betterBPM = (betterBPM + currentBPM) / 2;
} else {
betterBPM = currentBPM;
}
}

if (betterBPM < currentBPM) {
Expand All @@ -236,7 +241,8 @@ async function main() {
settings.addInput("catjam-webm-link", "Custom webM video URL (Link does not work if no video shows)", "");
settings.addInput("catjam-webm-bpm", "Custom default BPM of webM video (Example: 135.48)", "");
settings.addDropDown("catjam-webm-position", "Position where webM video should be rendered", ['Bottom (Player)', 'Left (Library)'], 1);
settings.addDropDown("catjam-webm-bpm-method", "Method to calculate better BPM", ['Track BPM', 'Danceability, Energy and Track BPM'], 1);
settings.addDropDown("catjam-webm-bpm-method", "Method to calculate better BPM for slower songs", ['Track BPM', 'Danceability, Energy and Track BPM'], 1);
settings.addDropDown("catjam-webm-bpm-method-faster-songs", "Method to calculate better BPM for faster songs", ['Track BPM', 'Danceability, Energy and Track BPM'], 1);
settings.addInput("catjam-webm-position-left-size", "Size of webM video on the left library (Only works for left library, Default: 100)", "");
settings.addButton("catjam-reload", "Reload custom values", "Save and reload", () => {createWebMVideo();});
settings.pushSettings();
Expand Down