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

AudioMotion and Pizzicato #10

Closed
franck34 opened this issue Jan 19, 2021 · 2 comments
Closed

AudioMotion and Pizzicato #10

franck34 opened this issue Jan 19, 2021 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@franck34
Copy link

Hi

audioMotion demos are impressive !

I'm trying to use both https://github.com/alemangui/pizzicato and audioMotion.

I've tested many things (i'm completely new with Web Audio). No luck. My last try was

const el = document.getElementById('container');
const audioMotion = new AudioMotionAnalyzer(el, {});
audioMotion.connectInput(Pizzicato.context.destination);

const soundPath = '/path/to/sound.ogg';
const mySound = new Pizzicato.Sound(soundPath, () => {
    mySound.play();
});

Error

Uncaught DOMException: Failed to execute 'connect' on 'AudioNode': output index (0) exceeds number of outputs (0)

I have no idea how to "connect" Pizzicato with AudioMotion :(

Any help is welcome, thank you !

@franck34 franck34 changed the title connect with Pizzicato ? audioMotion with Pizzicato ? Jan 19, 2021
@franck34 franck34 changed the title audioMotion with Pizzicato ? AudioMotion and Pizzicato Jan 19, 2021
@hvianna
Copy link
Owner

hvianna commented Jan 19, 2021

Hello!

Audio nodes must be created in the same audio context so they can be connected to each other. You can pass Pizzicato's context to the audioMotion-analyzer constructor, like so:

const el = document.getElementById('container');
const audioMotion = new AudioMotionAnalyzer( el, {
    audioCtx: Pizzicato.context
});

Then use the getInputNode() method to connect Pizzicato objects to audioMotion, like so:

const soundPath = '/path/to/sound.ogg';
const mySound = new Pizzicato.Sound( soundPath, () => {
    audioMotion.connectInput( mySound.getInputNode() );
    mySound.play();
});

Live example: https://codesandbox.io/s/9y6qb (you may need to click the canvas on first run to unlock the audio context)

@hvianna hvianna added the documentation Improvements or additions to documentation label Jan 19, 2021
@franck34
Copy link
Author

❤️ ❤️ ❤️ ❤️ ❤️

" My God, it's full of stars! "

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants