We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, i'm new here and new in programming in general, so excuse if my question will be stupid... anyway I'm playing with a p5.js sound script, trying to modify it and study a bit Everything's works except for the link I created on the page that in mobile version (ios-safari) doesn't work. Works perfectly on desktop. Can you please help me and let me know where i'm wrong? the website is www.paolotocci.webflow.io and this is the script:
<
script> var carrier; // this is the oscillator we will hear var modulator; // this oscillator will modulate the amplitude of the carrier var fft; // we'll visualize the waveform
function setup() { createCanvas(windowWidth,windowHeight); noFill(); background('rgb(0,0,255)'); // alpha
carrier = new p5.Oscillator(); // connects to master output by default carrier.freq(20); carrier.amp(0); // carrier's amp is 0 by default, giving our modulator total control
carrier.start();
modulator = new p5.Oscillator('triangle'); modulator.disconnect(); // disconnect the modulator from master output modulator.freq(5); modulator.amp(1); modulator.start();
// Modulate the carrier's amplitude with the modulator // Optionally, we can scale the signal. carrier.amp(modulator.scale(-1,1,1,-1));
// create an fft to analyze the audio fft = new p5.FFT(); }
function windowResized() { resizeCanvas(windowWidth, windowHeight); }
function draw() { background('rgb(0,0,255)'); // alpha
// map mouseY to moodulator freq between 0 and 20hz var modFreq = map(mouseY, 0, height, 20, 0); modulator.freq(modFreq);
var modAmp = map(mouseX, 0, width, 0, 1); modulator.amp(modAmp, 0.01); // fade time of 0.1 for smooth fading
// analyze the waveform waveform = fft.waveform();
// draw the shape of the waveform drawWaveform();
drawText(modFreq, modAmp); }
function drawWaveform() { stroke(240); strokeWeight(4); beginShape(); for (var i = 0; i<waveform.length; i++){ var x = map(i, 0, waveform.length, 0, width); var y = map(waveform[i], -1, 1, -height/2, height/2); vertex(x, y + height/2); } endShape(); }
function drawText(modFreq, modAmp) { strokeWeight(0); text('FREQUENCY ' + modFreq.toFixed(3) + ' Hz', 20, 20); text('AMPLITUDE ' + modAmp.toFixed(3), 20, 40);
}
thank you very much P
Answers
Sorry guys I already solved, it was beacuse of the version of p5.js with 05.07 everythings works