We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey guys! So I'm working on an audio music visualizer that will be viewed on an iPad. Problem I'm running into is that the sketch runs fine in Safari within p5, but not when its hosted. And yes, the entire file structure (html, libraries, sketch) are uploaded to my host. I'm getting the error below. Also attached is my very basic sketch code. The website is mmengle.com and my sketch is grid1. Help!
var shiftX, shiftY;
var x, y, spacing;
var song;
//var r, o, y, g, b;
// var c1 = [(fill(243, 158, 34)), (fill(57, 178, 136)), (fill(239, 73, 36)), (fill(234, 130, 36)), (fill(66, 104, 177))];
function preload() {
mySound = loadSound('assets/Finding Nemo - Nemo Egg (Main Theme).mp3');
}
function setup() {
createCanvas(1024, 760);
spacing = 150;
// c1[k] = 0, 4;
//music
mySound.play();
}
function draw() {
background(18, 21, 24);
//shifting + grid
shiftX = (1024 / 2) - 320;
shiftY = (760 / 2) - 250;
translate(shiftX, shiftY);
//all the squares; color generation
for (var i = 0; i < 5; i++) {
for (var j = 0; j < 4; j++) {
x = i * spacing;
y = j * spacing;
// fill(c1[i]);
noStroke();
fill(243, 158, 34);
rect(x, y, 40, 40, 10);
}
}
}
Answers
Sounds plays fine for me on Windoze Chrome; but not in IE. Could be a bug in the sound library; though one thing I would suggest doing first is changing the audio filename to something with no capitals, spaces or symbols. Obviously change the path in your sketch accordingly.
Search 'web safe filenames' for an explanation...
All sketches have worked for me both in 64-bit SlimJet 10.0.7.0 (Chromium 50.0.2661.75) & 64-bit CyberFox 47 (Firefox 47) under Win7. Failed in IE11 though. :-&
Seems like AudioContext compatibility isn't that widespread for mobile: :|
https://developer.Mozilla.org/en-US/docs/Web/API/AudioContext#Browser_compatibility
You may try out your luck at: https://GitHub.com/processing/p5.js-sound/issues
Thanks for the suggestions, guys!