alemangui / pizzicato

Library to simplify the way you create and manipulate sounds with the Web Audio API.
https://alemangui.github.io/pizzicato/
MIT License
1.66k stars 130 forks source link

how to make sound from a file , #161

Open divineuniverse opened 2 years ago

divineuniverse commented 2 years ago

Hi ,

i am new to prizzicato.js , and now i am learning about it , but i found that i cannot load up any sound from a file , ( i am using laptop with chrome browser ) ,

var tSnd = new Pizzicato.Sound( './audio/sound.wav' ); tSnd.play();

may i know do i need to do sth in the setting or config or others , really many thanks for this help and reply ,

thanks ALL , : )

=== === ===

BTW , i hv also tried to pass an AudioObject into it , such as , var XX = new Audio();' XX.src = './audio/sound.wav'; XX.load();`

var tSnd = new Pizzicato.Sound( XX ); tSnd.play(); or var tSnd = new Pizzicato.Sound( XX.src ); tSnd.play();

but these also NOT work ,

pascalwengerter commented 2 years ago

@divineuniverse I've stumbled upon the same issue today. The key is serving your files over HTTP (e.g. by running a super simple Go server like https://gist.github.com/paulmach/7271283), because the relative links from your HTML/JS resolve to using file:// URLs that then cause CORS issues