
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-riffs
Advanced tools
React Hooks + MIDI 🎹 = 🎶 Riffs 🎶
React Riffs exposes several hooks for use with the WebMIDI API. It wraps the excellent WebMidi.js, so refer to their documentation for event reference, etc.
useMidiInputsIn order to make use of Riffs, you first need to invoke the useMidiInputs hook. This will bootstrap WebMidi and return an array of connected Inputs:
let [myInput] = useMidiInputs();
console.log(myInput);
//=> Input {_userHandlers: {...}, _midiInput: MIDIInput, ...}
useMidiInputs takes an optional debug flag, which will add listeners to log the following events to the console: noteon, pitchbend, start, stop
let [myInput] = useMidiInputs({ debug: true });
Once you have your input, you can start reading from your input device. Just remember to pass your input object each time you invoke an event hook.
Each of the following takes an optional channel as the last parameter. If no channel is specified, it will default to 'all'.
useClockReturns the current timestamp from the input device along with a boolean representing whether or not the clock is currently running
let [timestamp, isRunning] = useClock(myInput);
console.log(timestamp);
//=> 1234.1234567890123
console.log(isRunning);
//=> false
useControlReturns the integer value of a controlchange event: 0-127
This hook accepts as an optional second parameter, a string indicating the control to listen for. If this is not supplied, it will default to modulationwheelcoarse.
A list of valid control types will be printed to the console if useMidiInputs is initialized with the debug flag.
let mod = useControl(myInput);
console.log(mod);
//=> 64
useNoteNOTE: You probably want useNotes
Returns the most recent noteon/noteoff event, along with a Boolean flag for whether the note is being played
let [noteEvent, isOn] = useNote(myInput);
console.log(noteEvent);
//=> {target: Input, data: Uint8Array(3), type: "noteon", ...}
console.log(isOn);
//=> true
useNotesReturns an array of noteon events for all of the notes currently being played
let pressedKeys = useNotes(myInput);
console.log(pressedKeys);
//=> [{target: Input, data: Uint8Array(3), type: "noteon" ...}]
usePitchbendReturns a float between -1.0 and 1.0 for the current pitchbend value. No bend is 0.0
let bend = usePitchbend(myInput);
console.log(bend);
//=> 0
FAQs
React Hooks for WebMidi.js
We found that react-riffs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.