Skip to content
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

Add Gamepad module #1223

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add Gamepad module #1223

wants to merge 2 commits into from

Conversation

nkymut
Copy link

@nkymut nkymut commented Nov 26, 2024

Adds gamepad support for Strudel, allowing users to use game controllers as expressive input devices for live coding music.

Examples

// Use button values to control amplitude
$: sequence([
  s("bd").gain(pad.X),    // X button controls gain
  s("[hh oh]").gain(pad.tglY),    // Y button toggles gain
]);

// Use analog stick for continuous control
$: note("c4*4".add(pad.y1_2.range(-24,24))) // Left stick Y controls pitch shift
  .pan(pad.x1_2);          // Left stick X controls panning

// Use toggle buttons to switch patterns on/off

// Define button sequences
const HADOKEN = [
  'd',               // Down
  'r',               // Right
  'a',               // A
];

const KONAMI = 'uuddlrlrba' //Konami Code ↑↑↓↓←→←→BA

// Add these lines to enable buttons(but why?)
$:pad.D.segment(16).gain(0)
$:pad.R.segment(16).gain(0)
$:pad.A.segment(16).gain(0)

// Check button sequence (returns 1 when detected, 0 when not within last 1 second)
$: sound("hadoken").gain(pad.checkSequence(HADOKEN))

Testing Done

  • [x]Tested with Logitech Gamepad F310
  • Tested with Xbox controller
  • Tested with PS4/PS5 controller

@nkymut nkymut changed the title Add GamePad Module Add Gamepad module Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant