parade update.
This commit is contained in:
parent
ab9057fc03
commit
f6f02ebee0
2 changed files with 69 additions and 55 deletions
|
|
@ -175,7 +175,7 @@ fastify.post("/entry", async function (request, reply) {
|
||||||
const client = new Client(server);
|
const client = new Client(server);
|
||||||
|
|
||||||
//create unique folder ==> timestamp + uuid
|
//create unique folder ==> timestamp + uuid
|
||||||
const folder = await client.createFolder("Storage/public/sound-parade/" + moment().tz('Asia/Seoul').format('YYYYMMDD-HHmmss - ') + uuidv1());
|
const folder = await client.createFolder("Storage/public/sound-parade/" + moment().tz('Asia/Seoul').format('YYYYMMDD-HHmmss-') + uuidv1());
|
||||||
if (converted) {
|
if (converted) {
|
||||||
const file = await folder.createFile("audio.mp3", await fs.readFile(tmpdir + '/converted.mp3'));
|
const file = await folder.createFile("audio.mp3", await fs.readFile(tmpdir + '/converted.mp3'));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,10 @@
|
||||||
fr = 20;
|
fr = 20;
|
||||||
}
|
}
|
||||||
frameRate(fr);
|
frameRate(fr);
|
||||||
//
|
|
||||||
silence = (await AudioImport("./audio/_silence.wav")).toDestination();
|
//p5 'draw()' doesn't work if user is not looking at the tab.
|
||||||
clap = (await AudioImport("./audio/clap01.mp3")).toDestination();
|
noLoop();
|
||||||
|
// --> use custom looper.
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
@ -66,9 +67,12 @@
|
||||||
var intro;
|
var intro;
|
||||||
var ready;
|
var ready;
|
||||||
//
|
//
|
||||||
socket.on("connect", function() {
|
socket.on("connect", async function() {
|
||||||
console.log("connected!");
|
console.log("connected!");
|
||||||
|
|
||||||
//
|
//
|
||||||
|
silence = (await AudioImport("./audio/_silence.wav")).toDestination();
|
||||||
|
clap = (await AudioImport("./audio/clap01.mp3")).toDestination();
|
||||||
|
|
||||||
//TESTING... fixed to room 1.
|
//TESTING... fixed to room 1.
|
||||||
// myroom = 1;
|
// myroom = 1;
|
||||||
|
|
@ -127,8 +131,8 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var fading_factor = 0.3; //30%
|
//var fading_factor = 0.3; //30%
|
||||||
//var fading_factor = 0.5; //50%
|
var fading_factor = 0.5; //50%
|
||||||
socket.on("post", async function(post) {
|
socket.on("post", async function(post) {
|
||||||
|
|
||||||
console.log(post);
|
console.log(post);
|
||||||
|
|
@ -159,7 +163,7 @@
|
||||||
var img = createImg(object.src, object.alt, "", async function(im) {
|
var img = createImg(object.src, object.alt, "", async function(im) {
|
||||||
//로딩이 끝나면, start!
|
//로딩이 끝나면, start!
|
||||||
var pv = new Tone.PanVol(0, -99).toDestination();
|
var pv = new Tone.PanVol(0, -99).toDestination();
|
||||||
var snd = (await AudioImport(object.audio));
|
var snd = await AudioImport(object.audio); // NOTE: url with spaces didn't work here.
|
||||||
snd.connect(pv).start();
|
snd.connect(pv).start();
|
||||||
snd.loop = true;
|
snd.loop = true;
|
||||||
|
|
||||||
|
|
@ -222,60 +226,70 @@
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function draw() {
|
//p5 'draw()' doesn't work if user is not looking at the tab.
|
||||||
for (var i = arr.length - 1; i >= 0; i -= 1) {
|
// --> custom looper is ok.
|
||||||
var bundle = arr[i];
|
var looper;
|
||||||
var img = bundle.img;
|
(looper = function(timeout) {
|
||||||
var showtime = parseFloat(img.attribute("data-showtime"));
|
setTimeout(async function() {
|
||||||
var type = img.attribute("data-type");
|
|
||||||
var x = img.position().x;
|
|
||||||
var y = img.position().y;
|
|
||||||
y = y + random(-1, 1);
|
|
||||||
x = x - windowWidth / (fr * showtime);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
if (type == "icon") {
|
for (var i = arr.length - 1; i >= 0; i -= 1) {
|
||||||
img.style("z-index", "-1");
|
var bundle = arr[i];
|
||||||
}
|
var img = bundle.img;
|
||||||
3;
|
var showtime = parseFloat(img.attribute("data-showtime"));
|
||||||
|
var type = img.attribute("data-type");
|
||||||
|
var x = img.position().x;
|
||||||
|
var y = img.position().y;
|
||||||
|
y = y + random(-1, 1);
|
||||||
|
x = x - windowWidth / (fr * showtime);
|
||||||
|
|
||||||
img.position(x, y);
|
//
|
||||||
var pan = (x / windowWidth) * 2 - 1;
|
if (type == "icon") {
|
||||||
|
img.style("z-index", "-1");
|
||||||
|
}
|
||||||
|
3;
|
||||||
|
|
||||||
//panning
|
img.position(x, y);
|
||||||
var snd = bundle.sound;
|
var pan = (x / windowWidth) * 2 - 1;
|
||||||
var pv = bundle.panvol;
|
|
||||||
if (x >= -bundle.width && x < windowWidth) {
|
//panning
|
||||||
pan = ((x + bundle.width) / (windowWidth + bundle.width)) * 2 - 1;
|
var snd = bundle.sound;
|
||||||
pv.pan.value = pan;
|
var pv = bundle.panvol;
|
||||||
pv.volume.value = 0;//(dB)
|
if (x >= -bundle.width && x < windowWidth) {
|
||||||
} else {
|
pan = ((x + bundle.width) / (windowWidth + bundle.width)) * 2 - 1;
|
||||||
var range;
|
pv.pan.value = pan;
|
||||||
var knob;
|
pv.volume.value = 0;//(dB)
|
||||||
if (x >= windowWidth) {
|
} else {
|
||||||
range = windowWidth * fading_factor
|
var range;
|
||||||
knob = x - windowWidth;
|
var knob;
|
||||||
pv.pan.value = 1;
|
if (x >= windowWidth) {
|
||||||
pv.volume.value = (1 - (knob / range)) * 99;
|
range = windowWidth * fading_factor
|
||||||
} else if (x < -bundle.width) {
|
knob = x - windowWidth;
|
||||||
range = windowWidth * fading_factor
|
pv.pan.value = 1;
|
||||||
knob = (x + bundle.width) * -1;
|
pv.volume.value = knob / range * -20;
|
||||||
pv.pan.value = -1;
|
} else if (x < -bundle.width) {
|
||||||
pv.volume.value = (1 - (knob / range)) * 99;
|
range = windowWidth * fading_factor
|
||||||
|
knob = (x + bundle.width) * -1;
|
||||||
|
pv.pan.value = -1;
|
||||||
|
pv.volume.value = knob / range * -20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove with sound fade-out
|
||||||
|
var exit_x = -bundle.width - windowWidth * fading_factor;
|
||||||
|
if (x < exit_x) {
|
||||||
|
img.remove();
|
||||||
|
snd.stop();
|
||||||
|
delete snd;
|
||||||
|
delete pv;
|
||||||
|
arr.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
|
|
||||||
//remove with sound fade-out
|
looper(1000/fr);
|
||||||
var exit_x = -bundle.width - windowWidth * fading_factor;
|
}, timeout);
|
||||||
if (x < exit_x) {
|
})(1000/fr);
|
||||||
img.remove();
|
|
||||||
snd.stop();
|
|
||||||
delete snd;
|
|
||||||
delete pv;
|
|
||||||
arr.splice(i, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// function randomvoiceplay() {
|
// function randomvoiceplay() {
|
||||||
// (looper = function(timeout) {
|
// (looper = function(timeout) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue