The PS4 dualshock controller has 1 byte values for the left and right rumble packs, so this basically works like 8 bit music.
Most of these are behind an NDA, so it's very hard to get any information about this (even the information above was hard to get, I only figured it out from a third party SDK for node.js). These are the informations I pieced together:
The process is literally like making 1 byte stereo music (and it's supposedly made by a music artist). It involves connecting a PS4 controller to the computer and using a program to create the rumble patterns. They make one based on guessing, then run it, then tweak it and repeat these steps until the pattern feels good.
Some of the rumbles are generated programatically (like when a car goes off the road), but these are usually either a simple function (like sinus) or a constant value similar to how phones do it. Even the most complex effects consist of multiplying a normalized rumble pattern by the strength you want.
The PS4 SDK also comes with some predefined patterns. Some examples are: a sawtooth pattern (constantly increasing, then going from 255 to 0), a sinus wave and triangles (it increases to 255 linearly, then back down to 0 linearly).
I couldn't find any details about other controllers (especially Switch's HD rumble, not even the patent describes how that works). But they're probably using a similar approach with more precise rumble packs.
###Sources:
Sources:
- the networking protocol of the PS4 controller including the 1 byte sized rumble values(thanks to DMGregory for finding this)