Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove duplicate/dead code #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
24 changes: 0 additions & 24 deletions shared/audio/scratch.ts

This file was deleted.

55 changes: 1 addition & 54 deletions shared/midi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,57 +125,4 @@ export type MidiSubjectMessage<T extends MidiMessage = MidiMessage> = {
name: MidiInstrumentName;
type: MidiMessageType;
msg: T;
}

export const equalControlButton = (button: ControlButtonMapping | undefined, msg: MidiSubjectMessage) => {
if (!button) {
return false;
}

const noteMsg = msg.msg as easymidi.Note;
return button.channel === noteMsg.channel && button.note === noteMsg.note;
};

export const equalKeyboard = (keyboard: KeyboardMapping | undefined, msg: MidiSubjectMessage) => {
if (!keyboard) {
return false;
}

const noteMsg = msg.msg as easymidi.Note;
return keyboard.channel === noteMsg.channel;
};

export const isNoteOnEvent = (msg: MidiSubjectMessage): msg is MidiSubjectMessage<NoteOnEvent> => {
return msg.type === 'noteon';
}

export const isNoteOffEvent = (msg: MidiSubjectMessage): msg is MidiSubjectMessage<NoteOffEvent> => {
return msg.type === 'noteoff';
}

export const isControlChangeEvent = (msg: MidiSubjectMessage): msg is MidiSubjectMessage<ControlChangeEvent> => {
return msg.type === 'cc';
}

export const equalChords = (chord1: Note[], chord2: Note[]) => {
const set1 = new Set(chord1);
const set2 = new Set(chord2);

if (set1.size !== set2.size) {
return false;
}

for (const c of set1.values()) {
if (!set2.has(c)) {
return false;
}
}

return true;
}

export type MidiSubjectMessage<T extends MidiMessage = MidiMessage> = {
name: MidiInstrumentName;
type: MidiMessageType
msg: T;
}
}
Loading