Skip to content

izm51/p5.audio-picker

Repository files navigation

p5.audio-picker

A library for creating audio source selection buttons for p5.sound.js.

DEMO: https://izm51.github.io/p5.audio-picker/

(The buttons at the bottom of the image was created with this library.)

Installation

Link p5.audio-picker.js or p5.audio-picker.min.js from your HTML file. You will also need to link p5.js and p5.sound.js first. Check index.html for an example.

Usage examples

getSources()

const audioSources = await AudioPicker.getSources();
  • Show a dialog to prompt to use a microphone
  • Get audio sources you can use
  • (Return a list of audio souces)

setSource()

setSource(2)
  • Set input source and start audioIn.
  • Param: {Int} An index in the array returned by getSources().

createButtons()

const bttons = AudioPicker.createButtons(() => {
  fft = new p5.FFT();
  fft.setInput(audioIn);
})
  • Create buttons that displays each label of audio sources.
  • When pressed the button, setSource at the index of that button and removeButtons.
  • Param: {Function} onPressed()
  • Return Buttons
buttons.addStyleToButtons((btn, index, length) => {
  btn.size(width, 28);
  btn.position(0, index * 30);
});

Getters

AudioPicker.audioIn
  • Return p5.AudioIn
AudioPicker.isMicAllowed
  • Return Boolean
  • Whether the use of microphones is allowed.
AudioPicker.isPicked
  • Return Boolean
  • Whether the AudioSource to use is already selected.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published