-
Notifications
You must be signed in to change notification settings - Fork 164
Update MIDI.js #493
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
base: main
Are you sure you want to change the base?
Update MIDI.js #493
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
plz |
|
bump ig |
|
|
|
:3 |
|
MERGE PLEASEEEEEEEE |
|
PLEASE PENGUINMOD I NEED THIS |
Ianyourgod
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small code review. note that this is just a quality of code review - i have not verified that the extension works
| noteNumberToName(args) { | ||
| const noteNumber = args.NOTE; | ||
| if (!Number.isInteger(noteNumber) || noteNumber < 0 || noteNumber > 127) return ''; | ||
| const names = ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am being a hater, but use " not '
not really necessary but whatever
| const channel = args.CHANNEL; | ||
| const arr = []; | ||
| if(this.activeNotes.has(channel)) arr.push(...this.activeNotes.get(channel).keys()); | ||
| if(this.activePads.has(channel)) arr.push(...this.activePads.get(channel).keys()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is personal preference, but i find it a lot more readable when the condition and the body are on separate lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
unless it's something extremely short like i++ in which case that's just unnecessarily taking up space
| return; | ||
| } | ||
| /* ======= MIDI Setup ======= */ | ||
| _onMIDISuccess(access) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you dont need underscores in front of function names. dont listen to the lies by big javascript!!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can confirm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but its pretty
| /* ======= MIDI Setup ======= */ | ||
| _onMIDISuccess(access) { | ||
| this.inputs = Array.from(access.inputs.values()); | ||
| this.inputs.forEach(input => input.onmidimessage = e => this._onMIDIMessage(e)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use the startlistening function
| const channel = (status & 0x0f) + 1; | ||
| const isPad = (note >= 36 && note <= 51); // MPK Mini pads | ||
|
|
||
| if (command === 0x90 && velocity > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no magic numbers please. make constants that reflect what the numbers mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THIS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
que
| } | ||
|
|
||
| _noteOn(channel, note, velocity) { | ||
| if (!this.activeNotes.has(channel)) this.activeNotes.set(channel, new Map()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i find it more readable when conditions and bodies are on separate lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't you already say that but yeah
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can read my code :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the point is so others can read your code.
| } | ||
| }); | ||
| /* ======= Listeners ======= */ | ||
| startListening() { this.inputs.forEach(input => input.onmidimessage = e => this._onMIDIMessage(e)); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont put an entire function on one line.
also, this is a big mess of closures. parentheses would be greatly appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:'(
| if(!this.visualizerEl) return; | ||
| const arr = []; | ||
| for(const [ch, notes] of this.activeNotes.entries()){ for(const note of notes.keys()) arr.push(`N Ch${ch}:${note}`); } | ||
| for(const [ch, pads] of this.activePads.entries()){ for(const pad of pads.keys()) arr.push(`P Ch${ch}:${pad}`); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are way too long and confusing. dont put a bunch of control flow on one line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:(
| notesPressed() { | ||
| const arr = []; | ||
| for(const notes of this.activeNotes.values()){ for(const note of notes.keys()) arr.push(note); } | ||
| for(const pads of this.activePads.values()){ for(const pad of pads.keys()) arr.push(pad); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as a bit above. too much on one line. also the braces are unneccesary.
personal note. pretty please include a space between the brace and whatevers using it
like dont do if (blahblahblah){...
do if (blahblahblah) {... <-- notice the space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes to the split it to multiple lines
yes to the space
no to the brace removal
i think braces make it more readable
ian do i realyyyyyyyy gotta change allat to get it accepted |
|
yes. its not that much. |
awwwwwwwwwww ok :( |
|
i edited it |
Adds channel reporters, notes on channel array reporter, note to name reporter, and fixes a bug involving note reporter keeping the note value after the note was released