I'm JavaScript beginner. I am not English native and I'm sorry for my poor English.
Now I want to do sound visualization with Node.js + Typescript, but I don't know how to load sound in setup(). Please teach me how to load sound in Node.js + Typescript.
I tried importing 'p5/lib/addons/p5.sound'. But I don't know how to use this module in sketch of below code.
main.ts
import * as p5 from 'p5';
const sketch = (p: p5) => {
p.setup = () => {
p.resizeCanvas(100, 100);
// want to load sound here
};
p.draw = () => {
p.background(100);
}
};
const sketchP = new p5(sketch);
global.d.ts
import module = require('p5');
export = module;
export as namespace p5;
declare global {
interface Window {
p5: typeof module
}
}
loadSound(). However, methodloadSound()is the module'p5/lib/addons/p5.sound'butpin the above code is the module'p5'. So I could not load sounds only to writeloadSound()insetupsimply.