You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
430 lines
9.1 KiB
JavaScript
430 lines
9.1 KiB
JavaScript
let keyButton, printerButton, recorderButton, playButton;
|
|
let bg;
|
|
let printer, keycard;
|
|
let keyIsPlaying = false;
|
|
let printerIsPlaying = false;
|
|
let phoneIsPlaying = false;
|
|
let speakerIsPlaying = false;
|
|
let neonIsPlaying = false;
|
|
let tvIsPlaying = false;
|
|
let slidingdoorIsPlaying = false;
|
|
let chatterIsPlaying = false;
|
|
let recordedMicSoundIsPlaying = false;
|
|
let bellIsPlaying = false;
|
|
let heartIsPlaying = false;
|
|
let mic, soundMicRecorder, recordedMicSound;
|
|
let isMicRecording;
|
|
let recordedSceneSound,soundSceneRecorder;
|
|
let isSceneRecording;
|
|
let showingTitle = false;
|
|
let Title;
|
|
let recordingImage;
|
|
|
|
|
|
function setup() {
|
|
bg = loadImage('assets/waitingroom.png');
|
|
createCanvas(640, 480);
|
|
var myCanvas = createCanvas(640, 480);
|
|
myCanvas.parent('main');
|
|
|
|
printer = loadSound('assets/printer.mp3');
|
|
printer.pan(1.0);
|
|
|
|
phone = loadSound('assets/phone.mp3');
|
|
phone.pan(0.8);
|
|
|
|
keycard = loadSound('assets/keycard.mp3');
|
|
keycard.pan(-0.9);
|
|
|
|
speaker = loadSound('assets/announcement.mp3');
|
|
speaker.pan(-0.2);
|
|
|
|
neon = loadSound('assets/neonlight.mp3');
|
|
|
|
tv = loadSound('assets/channelsurfing.mp3');
|
|
tv.pan(0.7);
|
|
|
|
slidingdoor = loadSound('assets/slidingdoor.mp3');
|
|
slidingdoor.pan(0.8);
|
|
|
|
chatter = loadSound('assets/chatter.mp3');
|
|
|
|
mic = new p5.AudioIn();
|
|
mic.start();
|
|
|
|
soundMicRecorder = new p5.SoundRecorder();
|
|
soundMicRecorder.setInput(mic);
|
|
|
|
recordedMicSound = new p5.SoundFile();
|
|
recordedMicSound.pan(-0.9);
|
|
|
|
soundSceneRecorder = new p5.SoundRecorder();
|
|
soundSceneRecorder.setInput();
|
|
|
|
recordedSceneSound = new p5.SoundFile();
|
|
|
|
|
|
bell = loadSound('assets/bell.mp3');
|
|
bell.pan(0.9);
|
|
|
|
heart = loadSound('assets/heartbeat.mp3');
|
|
|
|
showingTitle = true;
|
|
Title = loadImage('assets/titlescreen.png');
|
|
|
|
recordImage = loadImage('assets/record.png');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
keyButton = createButton('');
|
|
keyButton.parent("main");
|
|
keyButton.volume = (0.1);
|
|
keyButton.position(87, 190);
|
|
keyButton.mousePressed(playKeySound);
|
|
keyButton.size(22, 30);
|
|
keyButton.style('background-color', color(25, 23, 200, 0));
|
|
keyButton.style('border-style', 'hidden');
|
|
keyButton.style('outline', 'none');
|
|
|
|
printerButton = createButton('');
|
|
printerButton.parent("main");
|
|
printerButton.position(571, 100);
|
|
printerButton.mousePressed(playPrinterSound);
|
|
printerButton.size(56, 30);
|
|
printerButton.style('background-color', color(25, 23, 200, 0));
|
|
printerButton.style('border-style', 'hidden');
|
|
printerButton.style('outline', 'none');
|
|
|
|
sceneRecordButton = createButton('');
|
|
sceneRecordButton.parent("main");
|
|
sceneRecordButton.position(572, 8);
|
|
sceneRecordButton.mousePressed(recordScene);
|
|
sceneRecordButton.size(58, 30);
|
|
sceneRecordButton.style('background-color', color(25, 23, 200, 0));
|
|
sceneRecordButton.style('border-style', 'hidden');
|
|
sceneRecordButton.style('outline', 'none');
|
|
|
|
|
|
phoneButton = createButton('');
|
|
phoneButton.parent("main");
|
|
phoneButton.position(491, 180);
|
|
phoneButton.mousePressed(playPhoneSound);
|
|
phoneButton.size(36, 30);
|
|
phoneButton.style('background-color', color(25, 23, 200, 0));
|
|
phoneButton.style('border-style', 'hidden');
|
|
phoneButton.style('outline', 'none');
|
|
|
|
speakerButton = createButton('');
|
|
speakerButton.parent("main");
|
|
speakerButton.position(143, 84);
|
|
speakerButton.mousePressed(playSpeakerSound);
|
|
speakerButton.size(38, 70);
|
|
speakerButton.style('background-color', color(25, 23, 200, 0));
|
|
speakerButton.style('border-style', 'hidden');
|
|
speakerButton.style('outline', 'none');
|
|
|
|
neonButton = createButton('');
|
|
neonButton.parent("main");
|
|
neonButton.position(183, 5);
|
|
neonButton.mousePressed(playNeonSound);
|
|
neonButton.size(223, 10);
|
|
neonButton.style('background-color', color(25, 23, 200, 0));
|
|
neonButton.style('border-style', 'hidden');
|
|
neonButton.style('outline', 'none');
|
|
|
|
tvButton = createButton('');
|
|
tvButton.parent("main");
|
|
tvButton.position(425, 20);
|
|
tvButton.mousePressed(playTVSound);
|
|
tvButton.size(90, 50);
|
|
tvButton.style('background-color', color(25, 23, 200, 0));
|
|
tvButton.style('border-style', 'hidden');
|
|
tvButton.style('outline', 'none');
|
|
|
|
slidingdoorButton = createButton('');
|
|
slidingdoorButton.parent("main");
|
|
slidingdoorButton.position(420, 460);
|
|
slidingdoorButton.mousePressed(playSlidingSound);
|
|
slidingdoorButton.size(220, 20);
|
|
slidingdoorButton.style('background-color', color(25, 23, 200, 0));
|
|
slidingdoorButton.style('border-style', 'hidden');
|
|
slidingdoorButton.style('outline', 'none');
|
|
|
|
chatterButton = createButton('');
|
|
chatterButton.parent("main");
|
|
chatterButton.position(165, 196);
|
|
chatterButton.mousePressed(playChatterSound);
|
|
chatterButton.size(260, 130);
|
|
chatterButton.style('background-color', color(25, 23, 200, 0));
|
|
chatterButton.style('border-style', 'hidden');
|
|
chatterButton.style('outline', 'none');
|
|
|
|
recorderButton = createButton('');
|
|
recorderButton.parent("main");
|
|
recorderButton.position(20, 405);
|
|
recorderButton.mousePressed(recordInput);
|
|
recorderButton.mouseReleased(recordInput);
|
|
recorderButton.size(35,30);
|
|
recorderButton.style('background-color', color(25, 23, 200, 0));
|
|
recorderButton.style('border-style','hidden');
|
|
recorderButton.style('outline','none');
|
|
|
|
playButton = createButton('');
|
|
playButton.parent("main");
|
|
playButton.position(55, 405);
|
|
playButton.mousePressed(playRecorded);
|
|
playButton.size(35,30);
|
|
playButton.style('background-color', color(25, 23, 200, 0));
|
|
playButton.style('border-style','hidden');
|
|
playButton.style('outline','none');
|
|
|
|
bellButton = createButton('');
|
|
bellButton.parent("main");
|
|
bellButton.position(610, 310);
|
|
bellButton.mousePressed(playBellSound);
|
|
bellButton.size(30, 40);
|
|
bellButton.style('background-color', color(25, 23, 200, 0));
|
|
bellButton.style('border-style', 'hidden');
|
|
bellButton.style('outline', 'none');
|
|
|
|
|
|
heartButton = createButton('');
|
|
heartButton.parent("main");
|
|
heartButton.position(542, 325);
|
|
heartButton.mousePressed(playHeartSound);
|
|
heartButton.size(50, 60);
|
|
heartButton.style('background-color', color(25, 23, 200, 0));
|
|
heartButton.style('border-style', 'hidden');
|
|
heartButton.style('outline','none');
|
|
|
|
}
|
|
function draw() {
|
|
background(bg);
|
|
if(isSceneRecording)
|
|
{
|
|
image(recordImage, 575, 12, 21.5, 21.5)
|
|
}
|
|
|
|
if (showingTitle)
|
|
image(Title,0,0,640,480)
|
|
}
|
|
|
|
|
|
|
|
function keyPressed() {
|
|
if(keyCode == ENTER)
|
|
{
|
|
showingTitle = false;
|
|
}
|
|
}
|
|
|
|
|
|
function recordInput() {
|
|
userStartAudio();
|
|
if (isMicRecording) {
|
|
isMicRecording = false;
|
|
soundMicRecorder.stop();
|
|
|
|
} else {
|
|
soundMicRecorder.record(recordedMicSound);
|
|
isMicRecording = true;
|
|
|
|
}
|
|
}
|
|
|
|
function recordScene() {
|
|
if (isSceneRecording) {
|
|
soundSceneRecorder.stop();
|
|
} else {
|
|
soundSceneRecorder.record(recordedSceneSound, 360, sceneRecordFinished);
|
|
isSceneRecording = true;
|
|
}
|
|
}
|
|
|
|
function sceneRecordFinished()
|
|
{
|
|
isSceneRecording = false;
|
|
save(recordedSceneSound, "W808");
|
|
}
|
|
|
|
|
|
function playRecorded() {
|
|
|
|
//recordedSound.setVolume(0.1);
|
|
if (recordedMicSoundIsPlaying) {
|
|
recordedMicSound.pause();
|
|
|
|
recordedMicSoundIsPlaying = false;
|
|
} else {
|
|
recordedMicSound.loop();
|
|
|
|
recordedMicSoundIsPlaying = true;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
function playKeySound() {
|
|
keycard.setVolume(0.1);
|
|
if (keyIsPlaying) {
|
|
keycard.pause();
|
|
|
|
keyIsPlaying = false;
|
|
} else {
|
|
keycard.loop();
|
|
|
|
keyIsPlaying = true;
|
|
}
|
|
|
|
}
|
|
|
|
function playPrinterSound() {
|
|
printer.setVolume(0.1);
|
|
if (printerIsPlaying) {
|
|
printer.pause();
|
|
printerIsPlaying = false;
|
|
|
|
|
|
} else {
|
|
printer.loop();
|
|
printerIsPlaying = true;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
function playPhoneSound() {
|
|
phone.setVolume(0.2);
|
|
if (phoneIsPlaying) {
|
|
phone.pause();
|
|
phoneIsPlaying = false;
|
|
|
|
|
|
} else {
|
|
phone.loop();
|
|
phoneIsPlaying = true;
|
|
}
|
|
|
|
}
|
|
|
|
function playSpeakerSound() {
|
|
speaker.setVolume(0.15);
|
|
if (speakerIsPlaying) {
|
|
speaker.pause();
|
|
speakerIsPlaying = false;
|
|
|
|
|
|
} else {
|
|
speaker.loop();
|
|
speakerIsPlaying = true;
|
|
}
|
|
|
|
}
|
|
|
|
function playNeonSound() {
|
|
neon.setVolume(0.1);
|
|
if (neonIsPlaying) {
|
|
neon.pause();
|
|
|
|
neonIsPlaying = false;
|
|
} else {
|
|
neon.loop();
|
|
|
|
neonIsPlaying = true;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
function playTVSound() {
|
|
tv.setVolume(0.02);
|
|
if (tvIsPlaying) {
|
|
tv.pause();
|
|
tvIsPlaying = false;
|
|
|
|
|
|
} else {
|
|
tv.loop();
|
|
tvIsPlaying = true;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
function playSlidingSound() {
|
|
slidingdoor.setVolume(0.25);
|
|
if (slidingdoorIsPlaying) {
|
|
slidingdoor.pause();
|
|
tvIsPlaying = false;
|
|
|
|
|
|
} else {
|
|
slidingdoor.loop();
|
|
slidingdoorIsPlaying = true;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
function playChatterSound() {
|
|
chatter.setVolume(1.0);
|
|
if (chatterIsPlaying) {
|
|
chatter.pause();
|
|
chatterIsPlaying = false;
|
|
|
|
|
|
} else {
|
|
chatter.loop();
|
|
chatterIsPlaying = true;
|
|
}
|
|
}
|
|
|
|
function playToySound() {
|
|
toy.setVolume(0.25);
|
|
if (toyIsPlaying) {
|
|
toy.pause();
|
|
toyIsPlaying = false;
|
|
|
|
|
|
} else {
|
|
toy.loop();
|
|
toyIsPlaying = true;
|
|
}
|
|
|
|
}
|
|
|
|
function playHeartSound() {
|
|
heart.setVolume(0.5);
|
|
if (heartIsPlaying) {
|
|
heart.pause();
|
|
heartIsPlaying = false;
|
|
|
|
|
|
|
|
} else {
|
|
heart.loop();
|
|
heartIsPlaying = true;
|
|
}
|
|
}
|
|
|
|
function playBellSound() {
|
|
bell.setVolume(0.3);
|
|
if (bellIsPlaying) {
|
|
bell.pause();
|
|
bellIsPlaying = false;
|
|
|
|
|
|
} else {
|
|
bell.loop();
|
|
bellIsPlaying = true;
|
|
}
|
|
} |