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 = (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 timeout = setTimeout(() => {
playNote(instrument, sineSynth, onTimeoutCreated, Note.midi(note));
}, Math.random() * 10000 + 10000);
onTimeoutCreated(timeout);
return notes.map(note => Note.fromMidi(Note.midi(note) + Number(capo)))
} else {
items () {
const items = []
const startCode = Note.midi(this.root)
for (let i = 0; i < this.length; i++) {
const note = Note.props(Note.fromMidi(startCode + i))
const item = {
fret: i,
octave: note.oct,
name: note.pc
}
const enharmonic = Note.enharmonic(item.name)
if (enharmonic !== item.name) {
item.flatName = item.name.replace('b', '♭')
item.name = enharmonic.replace('#', '♯')
}
items.push(item)
}
return items
}
Tone.Transport.scheduleOnce(() => {
playNote(instrument, sineSynth, Note.midi(note));
}, `+${Math.random() * 10 + 10}`);
};
const keyAdjuster = () => (
Note.midi(notes[0]) > Note.midi(`${denominator}${baseKey}`) ? 0 : -1
)
const newRoot = `${denominator}${baseKey + keyAdjuster()}`
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;
};
stringNotes (root) {
const notes = []
const startCode = Note.midi(root)
for (let i = 0; i <= this.frets; i++) {
const note = Note.props(Note.fromMidi(startCode + i))
const item = {
fret: i,
octave: note.oct,
name: note.pc
}
const enharmonic = Note.enharmonic(item.name)
if (enharmonic !== item.name) {
item.flatName = item.name.replace('b', '♭')
item.name = enharmonic.replace('#', '♯')
}
notes.push(item)
}
return notes
},
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;
};