Skip to content
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
77 changes: 33 additions & 44 deletions js/widgets/sampler.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ function SampleWidget() {
this.activity.blocks.blockList[mainSampleBlock].text.text
) {
// Append cent adjustment to the block text if possible
const currentText = this.activity.blocks.blockList[mainSampleBlock].text
.text;
const currentText =
this.activity.blocks.blockList[mainSampleBlock].text.text;
if (!currentText.includes("¢")) {
this.activity.blocks.blockList[mainSampleBlock].text.text +=
" " + centText;
Expand Down Expand Up @@ -522,29 +522,25 @@ function SampleWidget() {
}
};

widgetWindow.addButton(
"load-media.svg",
ICONSIZE,
_("Upload sample"),
""
).onclick = function () {
stopTuner();
const fileChooser = docById("myOpenAll");
widgetWindow.addButton("load-media.svg", ICONSIZE, _("Upload sample"), "").onclick =
function () {
stopTuner();
const fileChooser = docById("myOpenAll");

// eslint-disable-next-line no-unused-vars
const __readerAction = function (event) {
window.scroll(0, 0);
const sampleFile = fileChooser.files[0];
that.handleFiles(sampleFile);
fileChooser.removeEventListener("change", __readerAction);
};

// eslint-disable-next-line no-unused-vars
const __readerAction = function (event) {
fileChooser.addEventListener("change", __readerAction, false);
fileChooser.focus();
fileChooser.click();
window.scroll(0, 0);
const sampleFile = fileChooser.files[0];
that.handleFiles(sampleFile);
fileChooser.removeEventListener("change", __readerAction);
};

fileChooser.addEventListener("change", __readerAction, false);
fileChooser.focus();
fileChooser.click();
window.scroll(0, 0);
};

// Create a container for the pitch button and frequency display
this.pitchBtnContainer = document.createElement("div");
this.pitchBtnContainer.className = "wfbtItem";
Expand Down Expand Up @@ -576,22 +572,18 @@ function SampleWidget() {
};

this._save_lock = false;
widgetWindow.addButton(
"export-chunk.svg",
ICONSIZE,
_("Save sample"),
""
).onclick = function () {
stopTuner();
// Debounce button
if (!that._get_save_lock()) {
that._save_lock = true;
that._saveSample();
setTimeout(function () {
that._save_lock = false;
}, 1000);
}
};
widgetWindow.addButton("export-chunk.svg", ICONSIZE, _("Save sample"), "").onclick =
function () {
stopTuner();
// Debounce button
if (!that._get_save_lock()) {
that._save_lock = true;
that._saveSample();
setTimeout(function () {
that._save_lock = false;
}, 1000);
}
};

this._recordBtn = widgetWindow.addButton("mic.svg", ICONSIZE, _("Toggle Mic"), "");

Expand Down Expand Up @@ -1783,9 +1775,8 @@ function SampleWidget() {

const __selectionChanged = () => {
const label = this._pitchWheel.navItems[this._pitchWheel.selectedNavItemIndex].title;
const attr = this._accidentalsWheel.navItems[
this._accidentalsWheel.selectedNavItemIndex
].title;
const attr =
this._accidentalsWheel.navItems[this._accidentalsWheel.selectedNavItemIndex].title;
const octave = Number(
this._octavesWheel.navItems[this._octavesWheel.selectedNavItemIndex].title
);
Expand Down Expand Up @@ -2047,9 +2038,8 @@ function SampleWidget() {
const playbackRate = TunerUtils.calculatePlaybackRate(0, this.centsValue);
// Apply the playback rate to the sample
if (instruments[0]["customsample_" + this.originalSampleName]) {
instruments[0][
"customsample_" + this.originalSampleName
].playbackRate.value = playbackRate;
instruments[0]["customsample_" + this.originalSampleName].playbackRate.value =
playbackRate;
}
}
};
Expand Down Expand Up @@ -2336,7 +2326,6 @@ function SampleWidget() {
instruments[0][instrumentName].playbackRate.value = playbackRate;
} else {
// If the instrument doesn't exist yet, we'll apply the adjustment when playing
console.log("Instrument not found, will apply cent adjustment during playback");
}
}

Expand Down
2 changes: 1 addition & 1 deletion sw.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
global

offlineFallbackPage
*/

// This is the "Offline page" service worker
Expand All @@ -11,6 +10,7 @@ const precacheFiles = [
/* Add an array of files to precache for your app */
"./index.html"
];
const offlineFallbackPage = "./index.html";

self.addEventListener("install", function (event) {
// eslint-disable-next-line no-console
Expand Down
Loading