Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function noteToMidi(note){
return Frequency(note).toMidi()
}
let notes = m[this.melodiesIndex].notes.map(note => {
const s = note.quantizedStartStep;
return {
'time': `${Math.floor(s / 16)}:${Math.floor(s / 4) % 4}:${(s % 4)}`,
'note': Tone.Frequency(note.pitch, 'midi'),
'isDrum': false,
'chord': false,
};
});
undefined,
1
)
firstNote = false
}
if (enableHighQualityAudio) {
if (velocity > 0.25) {
synth.triggerAttackRelease(
Tone.Frequency(seq.recent()).transpose(Math.random() > 0.5 ? +12 : 0),
"32n",
undefined,
velocity)
synth.triggerAttackRelease(
Tone.Frequency(seq.recent()).transpose(velocity > 0.4 ? +12 : 0),
"16n",
undefined,
velocity * 0.5
)
}
}
shouldTrigger = false
}
time => {
this.drumSampler.triggerAttack(
Tone.Frequency(beatInstrumentNumber, "midi").toNote(),
time
);
},
beat.notes.map(_beat => ({
private playNote(time: number, note: NoteSequence.INote) {
if (note.isDrum) {
this.drumKit.playNote(note.pitch, time);
} else {
const freq = new Tone.Frequency(note.pitch, 'midi');
const dur = note.endTime - note.startTime;
this.getSynth(note.instrument, note.program)
.triggerAttackRelease(freq, dur, time);
}
}
export function noteToMidi(note: string): number {
return Frequency(note).toMidi()
}
let rollover = () => {
if (!getEnableUISoundEffects()) return
let note = chords[currentChord][currentNote % (chords[0].length)]
let bassnote = chords[currentChord][0]
let onote = chords2[currentChord][currentNote % (chords[0].length)]
synth.triggerAttackRelease(Tone.Frequency(note).transpose(+12), "16n", undefined, 0.03);
if (currentNote == 0) {
bassSynth2.triggerAttackRelease(Tone.Frequency(note).transpose(+12*1), "8n", undefined, 0.03);
}
synth.triggerAttackRelease(Tone.Frequency(onote).transpose(+24), "16n", undefined, 0.05);
advanceNote(1)
}
setTimeout(()=>{
bassSynth.triggerAttackRelease(Tone.Frequency(bassnote).transpose((-12*3)), 0.2, undefined, 0.2);
synth.triggerAttackRelease(Tone.Frequency(bassnote).transpose((+12*2)), "16n", undefined, 0.4);
}, 150)
advanceNote(1)
let bip = (note) => {
if (!getEnableUISoundEffects()) return
bipSynth.triggerAttackRelease(Tone.Frequency(note).transpose(-12), "16n", undefined, 0.25)
advanceNote(1)
}
document.onkeydown = (evt: KeyboardEvent) => {
if (Tone.context.state !== 'running') {
Tone.context.resume();
}
const key = evt.keyCode;
const button = key - 49;
if (button >= 0 && button < NUM_BUTTONS) {
if (heldButtonToMidiNote.has(button)) {
return;
}
const output = genie.next(button, TEMPERATURE);
const note = output + LOWEST_PIANO_KEY_MIDI_NOTE;
synth.triggerAttack(Tone.Frequency(note, 'midi'));
heldButtonToMidiNote.set(button, note);
}
};