Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const findClosest = (note, samplesByNote) => {
const noteMidi = Note.midi(note);
const maxInterval = 96;
let interval = 0;
while (interval <= maxInterval) {
const higherNote = Note.fromMidi(noteMidi + interval);
if (samplesByNote[higherNote]) {
return higherNote;
}
const lowerNote = Note.fromMidi(noteMidi - interval);
if (samplesByNote[lowerNote]) {
return lowerNote;
}
interval += 1;
}
return note;
};
const findClosest = (samplesByNote, note) => {
const noteMidi = Note.midi(note);
const maxInterval = 96;
let interval = 0;
while (interval <= maxInterval) {
const higherNote = Note.fromMidi(noteMidi + interval);
if (samplesByNote[higherNote]) {
return higherNote;
}
const lowerNote = Note.fromMidi(noteMidi - interval);
if (samplesByNote[lowerNote]) {
return lowerNote;
}
interval += 1;
}
return note;
};
const findClosest = (note, samplesByNote) => {
const noteMidi = Note.midi(note);
const maxInterval = 96;
let interval = 0;
while (interval <= maxInterval) {
const higherNote = Note.fromMidi(noteMidi + interval);
if (samplesByNote[higherNote]) {
return higherNote;
}
const lowerNote = Note.fromMidi(noteMidi - interval);
if (samplesByNote[lowerNote]) {
return lowerNote;
}
interval += 1;
}
return note;
};
const findClosest = (samplesByNote, note) => {
const noteMidi = Note.midi(note);
const maxInterval = 96;
let interval = 0;
while (interval <= maxInterval) {
const higherNote = Note.fromMidi(noteMidi + interval);
if (samplesByNote[higherNote]) {
return higherNote;
}
const lowerNote = Note.fromMidi(noteMidi - interval);
if (samplesByNote[lowerNote]) {
return lowerNote;
}
interval += 1;
}
return note;
};
const findClosest = (note, samplesByNote) => {
const noteMidi = Note.midi(note);
const maxInterval = 96;
let interval = 0;
while (interval <= maxInterval) {
const higherNote = Note.fromMidi(noteMidi + interval);
if (samplesByNote[higherNote]) {
return higherNote;
}
const lowerNote = Note.fromMidi(noteMidi - interval);
if (samplesByNote[lowerNote]) {
return lowerNote;
}
interval += 1;
}
return note;
};
const findClosest = (samplesByNote, note) => {
const noteMidi = Note.midi(note);
const maxInterval = 96;
let interval = 0;
while (interval <= maxInterval) {
const higherNote = Note.fromMidi(noteMidi + interval);
if (samplesByNote[higherNote]) {
return higherNote;
}
const lowerNote = Note.fromMidi(noteMidi - interval);
if (samplesByNote[lowerNote]) {
return lowerNote;
}
interval += 1;
}
return note;
};
const findClosest = (samplesByNote, note) => {
const noteMidi = Note.midi(note);
const maxInterval = 96;
let interval = 0;
while (interval <= maxInterval) {
const higherNote = Note.fromMidi(noteMidi + interval);
if (samplesByNote[higherNote]) {
return higherNote;
}
const lowerNote = Note.fromMidi(noteMidi - interval);
if (samplesByNote[lowerNote]) {
return lowerNote;
}
interval += 1;
}
return note;
};
const findClosest = (samplesByNote, note) => {
const noteMidi = Note.midi(note);
const maxInterval = 96;
let interval = 0;
while (interval <= maxInterval) {
const higherNote = Note.fromMidi(noteMidi + interval);
if (samplesByNote[higherNote]) {
return higherNote;
}
const lowerNote = Note.fromMidi(noteMidi - interval);
if (samplesByNote[lowerNote]) {
return lowerNote;
}
interval += 1;
}
return note;
};