Skip to content

Commit 194d28a

Browse files
committed
Fix linting issues and finalize implementation
1 parent 6afb76f commit 194d28a

File tree

4 files changed

+104
-104
lines changed

4 files changed

+104
-104
lines changed

js/utils/musicutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3826,7 +3826,7 @@ const getNoteFromInterval = (pitch, interval) => {
38263826
interval === "up-major 7"
38273827
) {
38283828
let intervalNum;
3829-
intervalNum = interval.split(" ")[1];
3829+
intervalNum = interval.split(" ")[1];
38303830
majorNote = findMajorInterval("major " + intervalNum);
38313831
accidental = majorNote[0].substring(1, majorNote[0].length);
38323832
index1 = priorAttrs.indexOf(accidental);

js/widgets/sampler.js

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ function SampleWidget() {
804804
} else {
805805
activity.textMsg(_("Tuner stopped"), 3000);
806806
this.activity.logo.synth.stopTuner();
807-
tunerOn = false;
807+
tunerOn = false;
808808
}
809809
};
810810

@@ -1743,7 +1743,7 @@ function SampleWidget() {
17431743
const frequencyToNote = (frequency) => {
17441744
if (frequency <= 0) return { note: "---", cents: 0 };
17451745

1746-
const A4 = 440;
1746+
const A4 = 440;
17471747
const noteNames = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
17481748

17491749
const midiNote = 69 + 12 * Math.log2(frequency / A4);
@@ -1784,21 +1784,21 @@ function SampleWidget() {
17841784
if (pitch > 0) {
17851785
const { note, cents } = frequencyToNote(pitch);
17861786
document.getElementById("pitch").textContent = pitch.toFixed(2);
1787-
document.getElementById("note").textContent = cents === 0 ?
1788-
` ${note} (Perfect)` :
1787+
document.getElementById("note").textContent = cents === 0 ?
1788+
` ${note} (Perfect)` :
17891789
` ${note}, off by ${cents} cents`;
17901790
} else {
17911791
document.getElementById("pitch").textContent = "---";
17921792
document.getElementById("note").textContent = "---";
17931793
}
17941794

17951795
requestAnimationFrame(updatePitch);
1796-
};
1796+
};
17971797

17981798
updatePitch();
17991799
} catch (err) {
18001800
console.error(`${err.name}: ${err.message}`);
1801-
alert('Microphone access failed: ' + err.message);
1801+
alert("Microphone access failed: " + err.message);
18021802
}
18031803
};
18041804

@@ -1816,35 +1816,35 @@ function SampleWidget() {
18161816
container.style.padding = "20px";
18171817
container.style.boxSizing = "border-box";
18181818

1819-
const heading = document.createElement('h1');
1820-
heading.textContent = 'Tuner';
1821-
heading.style.textAlign = 'center';
1822-
heading.style.marginBottom = '20px';
1823-
1824-
const startButton = document.createElement('button');
1825-
startButton.id = 'start';
1826-
startButton.textContent = 'Start';
1827-
startButton.style.display = 'block';
1828-
startButton.style.margin = '0 auto 20px';
1829-
startButton.style.padding = '10px 20px';
1830-
startButton.style.fontSize = '16px';
1831-
startButton.style.cursor = 'pointer';
1832-
1833-
const pitchParagraph = document.createElement('p');
1834-
pitchParagraph.textContent = 'Detected Pitch: ';
1835-
pitchParagraph.style.textAlign = 'center';
1836-
pitchParagraph.style.fontSize = '18px';
1837-
const pitchSpan = document.createElement('span');
1838-
pitchSpan.id = 'pitch';
1839-
pitchSpan.textContent = '---';
1840-
1841-
const noteParagraph = document.createElement('p');
1842-
noteParagraph.textContent = 'Note: ';
1843-
noteParagraph.style.textAlign = 'center';
1844-
noteParagraph.style.fontSize = '18px';
1845-
const noteSpan = document.createElement('span');
1846-
noteSpan.id = 'note';
1847-
noteSpan.textContent = '---';
1819+
const heading = document.createElement("h1");
1820+
heading.textContent = "Tuner";
1821+
heading.style.textAlign = "center";
1822+
heading.style.marginBottom = "20px";
1823+
1824+
const startButton = document.createElement("button");
1825+
startButton.id = "start";
1826+
startButton.textContent = "Start";
1827+
startButton.style.display = "block";
1828+
startButton.style.margin = "0 auto 20px";
1829+
startButton.style.padding = "10px 20px";
1830+
startButton.style.fontSize = "16px";
1831+
startButton.style.cursor = "pointer";
1832+
1833+
const pitchParagraph = document.createElement("p");
1834+
pitchParagraph.textContent = "Detected Pitch: ";
1835+
pitchParagraph.style.textAlign = "center";
1836+
pitchParagraph.style.fontSize = "18px";
1837+
const pitchSpan = document.createElement("span");
1838+
pitchSpan.id = "pitch";
1839+
pitchSpan.textContent = "---";
1840+
1841+
const noteParagraph = document.createElement("p");
1842+
noteParagraph.textContent = "Note: ";
1843+
noteParagraph.style.textAlign = "center";
1844+
noteParagraph.style.fontSize = "18px";
1845+
const noteSpan = document.createElement("span");
1846+
noteSpan.id = "note";
1847+
noteSpan.textContent = "---";
18481848

18491849
pitchParagraph.appendChild(pitchSpan);
18501850
noteParagraph.appendChild(noteSpan);
@@ -1878,9 +1878,9 @@ function SampleWidget() {
18781878
const instrumentName = "customsample_" + this.originalSampleName;
18791879

18801880
// Check if instruments object exists and the specific instrument exists
1881-
if (typeof instruments !== 'undefined' &&
1882-
instruments[0] &&
1883-
instruments[0][instrumentName] &&
1881+
if (typeof instruments !== "undefined" &&
1882+
instruments[0] &&
1883+
instruments[0][instrumentName] &&
18841884
instruments[0][instrumentName].playbackRate) {
18851885
instruments[0][instrumentName].playbackRate.value = playbackRate;
18861886
} else {

js/widgets/timbre.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,8 +2163,8 @@ class TimbreWidget {
21632163
const mainDiv = docById("effect0");
21642164
const effects = ["Tremolo", "Vibrato", "Chorus", "Phaser", "Distortion"];
21652165
const effectsHtml = effects
2166-
.map(effect =>
2167-
`<input type="radio" name="effectsName" value="${effect}"/>${_(effect.toLowerCase())}<br>`
2166+
.map(effect =>
2167+
`<input type="radio" name="effectsName" value="${effect}"/>${_(effect.toLowerCase())}<br>`
21682168
)
21692169
.join("");
21702170
mainDiv.innerHTML = `<p>${effectsHtml}</p>`;

js/widgets/tuner.js

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,76 +6,76 @@ function TunerDisplay(canvas, width, height) {
66
this.canvas = canvas;
77
this.width = width;
88
this.height = height;
9-
this.ctx = canvas.getContext('2d');
10-
this.note = 'A';
9+
this.ctx = canvas.getContext("2d");
10+
this.note = "A";
1111
this.cents = 0;
1212
this.frequency = 440;
1313
this.chromaticMode = true; // Default to chromatic mode
1414

1515
// Create mode toggle container
16-
this.modeContainer = document.createElement('div');
16+
this.modeContainer = document.createElement("div");
1717
Object.assign(this.modeContainer.style, {
18-
position: 'absolute',
19-
top: '20px',
20-
left: '50%',
21-
transform: 'translateX(-50%)',
22-
display: 'flex',
23-
backgroundColor: '#FFFFFF',
24-
borderRadius: '20px',
25-
padding: '4px',
26-
boxShadow: '0 2px 4px rgba(0,0,0,0.1)'
18+
position: "absolute",
19+
top: "20px",
20+
left: "50%",
21+
transform: "translateX(-50%)",
22+
display: "flex",
23+
backgroundColor: "#FFFFFF",
24+
borderRadius: "20px",
25+
padding: "4px",
26+
boxShadow: "0 2px 4px rgba(0,0,0,0.1)"
2727
});
2828
canvas.parentElement.appendChild(this.modeContainer);
2929

3030
// Create mode buttons wrapper
31-
const buttonsWrapper = document.createElement('div');
31+
const buttonsWrapper = document.createElement("div");
3232
Object.assign(buttonsWrapper.style, {
33-
display: 'flex',
34-
gap: '4px',
35-
position: 'relative'
33+
display: "flex",
34+
gap: "4px",
35+
position: "relative"
3636
});
3737
this.modeContainer.appendChild(buttonsWrapper);
3838

3939
// Create chromatic mode button
40-
this.chromaticButton = document.createElement('div');
40+
this.chromaticButton = document.createElement("div");
4141
Object.assign(this.chromaticButton.style, {
42-
width: '40px',
43-
height: '32px',
44-
borderRadius: '16px',
45-
display: 'flex',
46-
alignItems: 'center',
47-
justifyContent: 'center',
48-
cursor: 'pointer',
49-
transition: 'all 0.3s ease'
42+
width: "40px",
43+
height: "32px",
44+
borderRadius: "16px",
45+
display: "flex",
46+
alignItems: "center",
47+
justifyContent: "center",
48+
cursor: "pointer",
49+
transition: "all 0.3s ease"
5050
});
51-
const chromaticIcon = document.createElement('img');
51+
const chromaticIcon = document.createElement("img");
5252
Object.assign(chromaticIcon, {
53-
src: 'header-icons/chromatic-mode.svg',
54-
width: '20',
55-
height: '20',
56-
alt: ''
53+
src: "header-icons/chromatic-mode.svg",
54+
width: "20",
55+
height: "20",
56+
alt: ""
5757
});
5858
this.chromaticButton.appendChild(chromaticIcon);
5959
buttonsWrapper.appendChild(this.chromaticButton);
6060

6161
// Create target pitch mode button
62-
this.targetPitchButton = document.createElement('div');
62+
this.targetPitchButton = document.createElement("div");
6363
Object.assign(this.targetPitchButton.style, {
64-
width: '40px',
65-
height: '32px',
66-
borderRadius: '16px',
67-
display: 'flex',
68-
alignItems: 'center',
69-
justifyContent: 'center',
70-
cursor: 'pointer',
71-
transition: 'all 0.3s ease'
64+
width: "40px",
65+
height: "32px",
66+
borderRadius: "16px",
67+
display: "flex",
68+
alignItems: "center",
69+
justifyContent: "center",
70+
cursor: "pointer",
71+
transition: "all 0.3s ease"
7272
});
73-
const targetIcon = document.createElement('img');
73+
const targetIcon = document.createElement("img");
7474
Object.assign(targetIcon, {
75-
src: 'header-icons/target-pitch-mode.svg',
76-
width: '20',
77-
height: '20',
78-
alt: ''
75+
src: "header-icons/target-pitch-mode.svg",
76+
width: "20",
77+
height: "20",
78+
alt: ""
7979
});
8080
this.targetPitchButton.appendChild(targetIcon);
8181
buttonsWrapper.appendChild(this.targetPitchButton);
@@ -101,14 +101,14 @@ function TunerDisplay(canvas, width, height) {
101101
TunerDisplay.prototype.updateButtonStyles = function() {
102102
if (this.chromaticMode) {
103103
this.chromaticButton.style.backgroundColor = platformColor.selectorBackground;
104-
this.chromaticButton.querySelector('img').style.filter = 'brightness(0) invert(1)';
105-
this.targetPitchButton.style.backgroundColor = 'transparent';
106-
this.targetPitchButton.querySelector('img').style.filter = 'none';
104+
this.chromaticButton.querySelector("img").style.filter = "brightness(0) invert(1)";
105+
this.targetPitchButton.style.backgroundColor = "transparent";
106+
this.targetPitchButton.querySelector("img").style.filter = "none";
107107
} else {
108108
this.targetPitchButton.style.backgroundColor = platformColor.selectorBackground;
109-
this.targetPitchButton.querySelector('img').style.filter = 'brightness(0) invert(1)';
110-
this.chromaticButton.style.backgroundColor = 'transparent';
111-
this.chromaticButton.querySelector('img').style.filter = 'none';
109+
this.targetPitchButton.querySelector("img").style.filter = "brightness(0) invert(1)";
110+
this.chromaticButton.style.backgroundColor = "transparent";
111+
this.chromaticButton.querySelector("img").style.filter = "none";
112112
}
113113
};
114114

@@ -143,32 +143,32 @@ TunerDisplay.prototype.draw = function() {
143143
const meterY = height - 80; // Base position of meter
144144

145145
// Draw the tuning meter background
146-
ctx.fillStyle = '#e0e0e0';
146+
ctx.fillStyle = "#e0e0e0";
147147
ctx.fillRect(meterX, meterY, meterWidth, meterHeight);
148148

149149
// Draw the center line
150-
ctx.fillStyle = '#000000';
150+
ctx.fillStyle = "#000000";
151151
ctx.fillRect(meterX + meterWidth / 2 - 1, meterY, 2, meterHeight);
152152

153153
// Draw the indicator
154154
const indicatorX = meterX + (meterWidth / 2) + (this.cents / 50) * (meterWidth / 2);
155-
ctx.fillStyle = '#ff0000';
155+
ctx.fillStyle = "#ff0000";
156156
ctx.fillRect(indicatorX - 2, meterY - 5, 4, meterHeight + 10);
157157

158158
// Position text much lower in the canvas
159159
// Draw the note
160-
ctx.font = 'bold 48px Arial';
161-
ctx.textAlign = 'center';
162-
ctx.fillStyle = '#000000';
160+
ctx.font = "bold 48px Arial";
161+
ctx.textAlign = "center";
162+
ctx.fillStyle = "#000000";
163163
ctx.fillText(this.note, width / 2, height - 200); // Much lower position
164164

165165
// Draw the cents deviation
166-
ctx.font = '24px Arial';
167-
ctx.fillText((this.cents >= 0 ? '+' : '') + Math.round(this.cents) + '¢', width / 2, height - 160); // Much lower position
166+
ctx.font = "24px Arial";
167+
ctx.fillText((this.cents >= 0 ? "+" : "") + Math.round(this.cents) + "¢", width / 2, height - 160); // Much lower position
168168

169169
// Draw the frequency
170-
ctx.font = '18px Arial';
171-
ctx.fillText(this.frequency.toFixed(1) + ' Hz', width / 2, height - 40); // Near bottom
170+
ctx.font = "18px Arial";
171+
ctx.fillText(this.frequency.toFixed(1) + " Hz", width / 2, height - 40); // Near bottom
172172
};
173173

174174
/**
@@ -183,10 +183,10 @@ const TunerUtils = {
183183
frequencyToPitch: function(frequency) {
184184
const A4 = 440;
185185
const C0 = A4 * Math.pow(2, -4.75);
186-
const noteNames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
186+
const noteNames = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"];
187187

188188
if (frequency < C0) {
189-
return ['C', 0, C0];
189+
return ["C", 0, C0];
190190
}
191191

192192
const h = Math.round(12 * Math.log2(frequency / C0));
@@ -206,4 +206,4 @@ const TunerUtils = {
206206
calculatePlaybackRate: function(baseCents, adjustment) {
207207
return Math.pow(2, (baseCents + adjustment) / 1200);
208208
}
209-
};
209+
};

0 commit comments

Comments
 (0)