update documentation
This commit is contained in:
parent
bb56ed479f
commit
443760c0d1
1 changed files with 35 additions and 14 deletions
|
|
@ -11,7 +11,8 @@ Initialize a gamepad by calling the gamepad() function with an optional index pa
|
||||||
<MiniRepl
|
<MiniRepl
|
||||||
client:idle
|
client:idle
|
||||||
tune={`// Initialize gamepad (optional index parameter, defaults to 0)
|
tune={`// Initialize gamepad (optional index parameter, defaults to 0)
|
||||||
const pad = gamepad(0)`}
|
const gp = gamepad(0)
|
||||||
|
note("c a f e").gain(gp.a)`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Available Controls
|
## Available Controls
|
||||||
|
|
@ -38,6 +39,12 @@ The gamepad module provides access to buttons and analog sticks as normalized si
|
||||||
| Right Stick | `x2`, `y2` (0 to 1 range) |
|
| Right Stick | `x2`, `y2` (0 to 1 range) |
|
||||||
| | `x2_2`, `y2_2` (-1 to 1 range) |
|
| | `x2_2`, `y2_2` (-1 to 1 range) |
|
||||||
|
|
||||||
|
### Button Sequence
|
||||||
|
|
||||||
|
| Stick | Controls |
|
||||||
|
| ----------- | ------------------------------ |
|
||||||
|
| Button Sequence | `btnSequence()`, `btnSeq()`, `btnseq()`|
|
||||||
|
|
||||||
## Using Gamepad Inputs
|
## Using Gamepad Inputs
|
||||||
|
|
||||||
Once initialized, you can use various gamepad inputs in your patterns. Here are some examples:
|
Once initialized, you can use various gamepad inputs in your patterns. Here are some examples:
|
||||||
|
|
@ -48,12 +55,16 @@ You can use button inputs to control different aspects of your music, such as ga
|
||||||
|
|
||||||
<MiniRepl
|
<MiniRepl
|
||||||
client:idle
|
client:idle
|
||||||
tune={`const pad = gamepad(0)
|
tune={`const gp = gamepad(0)
|
||||||
// Use button values to control amplitude
|
// Use button values to control amplitude
|
||||||
$: sequence([
|
$: stack(
|
||||||
s("bd").gain(pad.X), // X button controls gain
|
s("[[hh hh] oh hh oh]/2").gain(gp.tglX).bank("RolandTR909"), // X btn for HH
|
||||||
s("[hh oh]").gain(pad.tglY), // Y button toggles gain
|
s("cr*1").gain(gp.Y).bank("RolandTR909"), // LB btn for CR
|
||||||
])`}
|
s("bd").gain(gp.tglA).bank("RolandTR909"), // A btn for BD
|
||||||
|
s("[ht - - mt - - lt - ]/2").gain(gp.tglB).bank("RolandTR909"), // B btn for Toms
|
||||||
|
s("sd*4").gain(gp.RB).bank("RolandTR909"), // RB btn for SD
|
||||||
|
).cpm(120)
|
||||||
|
`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
### Analog Stick Inputs
|
### Analog Stick Inputs
|
||||||
|
|
@ -62,28 +73,38 @@ Analog sticks can be used for continuous control, such as pitch shifting or pann
|
||||||
|
|
||||||
<MiniRepl
|
<MiniRepl
|
||||||
client:idle
|
client:idle
|
||||||
tune={`const pad = gamepad(0)
|
tune={`const gp = gamepad(0)
|
||||||
// Use analog stick for continuous control
|
// Use analog stick for continuous control
|
||||||
$: note("c4*4".add(pad.y1_2.range(-24,24))) // Left stick Y controls pitch shift
|
$: note("c4 d3 a3 e3").sound("sawtooth")
|
||||||
.pan(pad.x1_2) // Left stick X controls panning`}
|
.lpf(gp.x1.range(100,4000))
|
||||||
|
.lpq(gp.y1.range(5,30))
|
||||||
|
.decay(gp.y2.range(0.1,2))
|
||||||
|
.lpenv(gp.x2.range(-5,5))
|
||||||
|
.cpm(120)
|
||||||
|
`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
### Button Sequences
|
### Button Sequences
|
||||||
|
|
||||||
You can define button sequences to trigger specific actions, like playing a sound when a sequence is detected.
|
You can define button sequences to trigger specific actions, like playing a sound when a sequence is detected.
|
||||||
|
|
||||||
<MiniRepl client:idle tune={`const pad = gamepad(0)
|
<MiniRepl client:idle tune={`const gp = gamepad(0)
|
||||||
// Define button sequences
|
// Define button sequences
|
||||||
const HADOKEN = [
|
const HADOUKEN = [
|
||||||
'd', // Down
|
'd', // Down
|
||||||
'r', // Right
|
'r', // Right
|
||||||
'a', // A
|
'a', // A
|
||||||
]
|
]
|
||||||
|
|
||||||
const KONAMI = 'uuddlrlrba' //Konami Code ↑↑↓↓←→←→BA
|
const KONAMI = 'uuddlrlrba' //Konami Code ↑↑↓↓←→←→BA
|
||||||
|
|
||||||
// Check button sequence (returns 1 when detected, 0 when not within last 1 second)
|
// Check butto-n sequence (returns 1 while detected, 0 when not within last 1 second)
|
||||||
$: sound("hadoken").gain(pad.checkSequence(HADOKEN))`} />
|
$: s("free_hadouken -").slow(2)
|
||||||
|
.gain(gp.btnSequence(HADOUKEN)).room(1).cpm(120)
|
||||||
|
|
||||||
|
// hadouken.wav by Syna-Max
|
||||||
|
//https://freesound.org/people/Syna-Max/sounds/67674/
|
||||||
|
samples({free_hadouken: 'https://cdn.freesound.org/previews/67/67674_111920-lq.mp3'})
|
||||||
|
`} />
|
||||||
|
|
||||||
## Multiple Gamepads
|
## Multiple Gamepads
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue