I am attempting to create an audio visualization program on codepen.io (http://codepen.io/www139/pen/oLrJAZ?editors=0010). I have built my own web server which I used to upload the audio for the project. You can listen to the audio without CORS problems (http://williamgreen.hopto.org/audioVisualization/song.mp3). However, the audio visualization program requires access to read the sound frequencies. When I try to read the audio frequencies, I am given this error:
MediaElementAudioSource outputs zeroes due to CORS access restrictions for http://williamgreen.hopto.org/audioVisualization/song.mp3
The frequencies return as 0s.
When I add this line:
audio.crossOrigin = 'anonymous';
I no longer receive the error but the audio doesn't load.
I have also tried setting CORS access with this header in .htaccess according to https://stackoverflow.com/a/11691776/3011082 . This question also seems interesting but lacks the information I need (MediaElementAudioSource outputs zeros due to CORS access restrictions local mp3 file). I also referenced this (http://enable-cors.org/server_apache.html).
Any suggestions? Are there any apache/PHP headers that need to be set? How can I get this working?
I had asked this question a while back (How can I set CORS access for an audio file on my Linux webserver with apache2?) but I wasn't as accurate as I would like and the answers didn't help me which is why I asked this question. My brain has been working this puzzle for literally months aside from high school ;)
Edit: I asked this question which reveals more information. The issue is very likely with the CORS headers CORS headers for accessing a file on another domain