1# @strudel/motion 2 3This package adds device motion sensing functionality to strudel Patterns. 4 5## Install 6 7```sh 8npm i @strudel/motion --save 9``` 10 11## Usage 12 13| Motion | Long Names & Aliases | Description | 14|----------------------------|-----------------------------------------------------------|------------------------------------------| 15| Acceleration | accelerationX (accX), accelerationY (accY), accelerationZ (accZ) | X, Y, Z-axis acceleration values | 16| Gravity | gravityX (gravX), gravityY (gravY), gravityZ (gravZ) | X, Y, Z-axis gravity values | 17| Rotation | rotationAlpha (rotA, rotZ), rotationBeta (rotB, rotX), rotationGamma (rotG, rotY) | Rotation around alpha, beta, gamma axes and mapped to X, Y, Z | 18| Orientation | orientationAlpha (oriA, oriZ), orientationBeta (oriB, oriX), orientationGamma (oriG, oriY) | Orientation alpha, beta, gamma values and mapped to X, Y, Z | 19| Absolute Orientation | absoluteOrientationAlpha (absOriA, absOriZ), absoluteOrientationBeta (absOriB, absOriX), absoluteOrientationGamma (absOriG, absOriY) | Absolute orientation alpha, beta, gamma values and mapped to X, Y, Z | 20 21## Example 22 23```js 24enableMotion() //enable DeviceMotion 25 26setcpm(200/4) 27 28$_: accX.segment(16).gain().log() 29 30$:n("0 1 3 1 5 4") 31 .scale("Bb:lydian") 32 .sometimesBy(0.5,sub(note(12))) 33 .lpf(gravityY.range(20,1000)) 34 .lpq(gravityZ.range(1,30)) 35 .lpenv(gravityX.range(2,2)) 36 .gain(oriX.range(0.2,0.8)) 37 .room(oriZ.range(0,0.5)) 38 .attack(oriY.range(0,0.3)) 39 .delay(rotG.range(0,1)) 40 .decay(rotA.range(0,1)) 41 .attack(rotB.range(0,0.1)) 42 .sound("sawtooth") 43``` 44 45## Setup SSL for Local Development 46 47`DeviceMotionEvent` only works with HTTPS, so you'll need to enable SSL for local development. 48Try installing an SSL plugin for Vite. 49 50```sh 51cd website 52pnpm install -D @vitejs/plugin-basic-ssl 53``` 54 55add the basicSsl plugin to the defineConfig block in `strudel/website/astro.config.mjs` 56 57```js 58vite: { 59 plugins: [basicSsl()], 60 server: { 61 host: '0.0.0.0', // Ensures it binds to all network interfaces 62 // https: { 63 // key: '../../key.pem', // 64 // cert: '../../cert.pem', 65 // }, 66 }, 67}, 68``` 69 70generate an SSL certificate to avoid security warnings. 71 72`openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout key.pem -out cert.pem`