Skip to content

Commit

Permalink
Sounds Complete, Welcome screen added
Browse files Browse the repository at this point in the history
  • Loading branch information
gawainhewitt committed Jan 20, 2021
1 parent b2066d1 commit f23ff39
Show file tree
Hide file tree
Showing 36 changed files with 180 additions and 24 deletions.
33 changes: 33 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,40 @@ body {
}
}

#loadscreen {
position: absolute;
width: 100%;
height: 100%;
background-color: rgb(94, 176, 179);
z-index: 3;
opacity: 0.8;
}

#welcomescreen {
position: absolute;
width: 100%;
height: 100%;
background-color: rgb(95, 94, 179);
z-index: 3;
opacity: 0.9;
visibility: hidden;
}

h1 {
font-family: Arial, Helvetica, sans-serif;
padding: 20em, 0;
text-align: center;
font-size: 5em;
color: white;
}

p {
font-family: Arial, Helvetica, sans-serif;
padding: 20em, 0;
text-align: center;
font-size: 2em;
color: white;
}

img {
width: 100%;
Expand Down
33 changes: 33 additions & 0 deletions dist/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,40 @@ body {
}
}

#loadscreen {
position: absolute;
width: 100%;
height: 100%;
background-color: rgb(94, 176, 179);
z-index: 3;
opacity: 0.8;
}

#welcomescreen {
position: absolute;
width: 100%;
height: 100%;
background-color: rgb(95, 94, 179);
z-index: 3;
opacity: 0.9;
visibility: hidden;
}

h1 {
font-family: Arial, Helvetica, sans-serif;
padding: 20em, 0;
text-align: center;
font-size: 5em;
color: white;
}

p {
font-family: Arial, Helvetica, sans-serif;
padding: 20em, 0;
text-align: center;
font-size: 2em;
color: white;
}

img {
width: 100%;
Expand Down
13 changes: 13 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@

<body>

<div id="loadscreen">
<h1>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...</h1>
</div>
<div id="welcomescreen">
<br>
<br>
<br>
<br>
<p>Welcome to the Orchlab French Horn.<br> You can play this using the QWERTYUIO keys <br>on your keyboard or by touching or clicking the screen</p>
<br>
<p> Click or touch <br>screen to start</p>
</div>

<div id="container">

<div id="selections">
Expand Down
56 changes: 44 additions & 12 deletions dist/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,24 @@ function startup() {

}

function handleKeyDown(e) {
function hideLoadScreen() {
document.getElementById('loadscreen').style.visibility="hidden";
var welcome = document.getElementById('welcomescreen');
welcome.style.visibility="visible";
welcome.addEventListener("click", startHorn);
welcome.addEventListener("touchstart", startHorn);
}

function startHorn() {
document.getElementById('welcomescreen').style.visibility="hidden";
if(info === true) { // is the info screen on?
Tone.start(); // we need this to allow audio to start. probably best to put it on a different button soon though
info = false;
}
}

function handleKeyDown(e) {

var key = e.code;
console.log("keydown "+key); //debugging

Expand Down Expand Up @@ -423,39 +435,59 @@ function handleMenu(menu, index) { // function to handle the menu selections and

//following is to do with sound and image management

const sampler = new Tone.Sampler({
urls: {
B2: "horn-tone-b2.mp3",
C3: "horn-tone-c3.mp3",
E3: "horn-tone-e3.mp3",
G3: "horn-tone-g3.mp3",
A3: "horn-tone-a3.mp3",
C4: "horn-tone-c4.mp3"
},
baseUrl: "/sounds/",
onload: () => {
hideLoadScreen();
}
})

const reverb = new Tone.Reverb({
decay: 3,
predelay: 0,
wet: 0.5
}).toDestination();

sampler.connect(reverb);


sampler.set({
release: 8
});

synth.set( // setup the synth - this is audio stuff really
{
"volume": 0,
"detune": 0,
"portamento": 0,
"envelope": {
"attack": 2,
"attack": 40,
"attackCurve": "linear",
"decay": 0.1,
"decayCurve": "exponential",
"release": 2,
"releaseCurve": "exponential",
"sustain": 0.3
},
"oscillator": {
"partialCount": 0,
"partials": [],
"phase": 0,
"type": "triangle"
}
}
);

function playSynth(i) {
synth.triggerAttack(notes[i], Tone.now());
//document.getElementById(`i${i}`).src=`images/image${i}_2.jpg`; //using template literals to embed expressions within a string
sampler.triggerAttack(notes[i], Tone.now());
document.getElementById(`i${i}`).style.backgroundColor="magenta";
}

var col = ["rgb(255, 255, 0)", "rgb(200, 200, 0)", "rgb(255, 255, 0)", "rgb(200, 200, 0)", "rgb(255, 255, 0)", "rgb(200, 200, 0)", "rgb(255, 255, 0)", "rgb(200, 200, 0)", "rgb(255, 255, 0)"]; //colour of button

function stopSynth(i) {
synth.triggerRelease(notes[i], Tone.now());
//document.getElementById(`i${i}`).src=`images/image${i}.jpg`;
sampler.triggerRelease(notes[i], Tone.now());
document.getElementById(`i${i}`).style.backgroundColor=col[i];
}
Binary file removed dist/sounds/eight.mp3
Binary file not shown.
Binary file removed dist/sounds/five.mp3
Binary file not shown.
Binary file removed dist/sounds/four.mp3
Binary file not shown.
Binary file added dist/sounds/horn-tone-a3.mp3
Binary file not shown.
Binary file added dist/sounds/horn-tone-b2.mp3
Binary file not shown.
Binary file added dist/sounds/horn-tone-c3.mp3
Binary file not shown.
Binary file added dist/sounds/horn-tone-c4.mp3
Binary file not shown.
Binary file added dist/sounds/horn-tone-e3.mp3
Binary file not shown.
Binary file added dist/sounds/horn-tone-g3.mp3
Binary file not shown.
Binary file removed dist/sounds/nine.mp3
Binary file not shown.
Binary file removed dist/sounds/one.mp3
Binary file not shown.
Binary file removed dist/sounds/seven.mp3
Binary file not shown.
Binary file removed dist/sounds/six.mp3
Binary file not shown.
Binary file removed dist/sounds/three.mp3
Binary file not shown.
Binary file removed dist/sounds/two.mp3
Binary file not shown.
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@

<body>

<div id="loadscreen">
<h1>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...<br>loading...</h1>
</div>
<div id="welcomescreen">
<br>
<br>
<br>
<br>
<p>Welcome to the Orchlab French Horn.<br> You can play this using the QWERTYUIO keys <br>on your keyboard or by touching or clicking the screen</p>
<br>
<p> Click or touch <br>screen to start</p>
</div>

<div id="container">

<div id="selections">
Expand Down
56 changes: 44 additions & 12 deletions sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,24 @@ function startup() {

}

function handleKeyDown(e) {
function hideLoadScreen() {
document.getElementById('loadscreen').style.visibility="hidden";
var welcome = document.getElementById('welcomescreen');
welcome.style.visibility="visible";
welcome.addEventListener("click", startHorn);
welcome.addEventListener("touchstart", startHorn);
}

function startHorn() {
document.getElementById('welcomescreen').style.visibility="hidden";
if(info === true) { // is the info screen on?
Tone.start(); // we need this to allow audio to start. probably best to put it on a different button soon though
info = false;
}
}

function handleKeyDown(e) {

var key = e.code;
console.log("keydown "+key); //debugging

Expand Down Expand Up @@ -423,39 +435,59 @@ function handleMenu(menu, index) { // function to handle the menu selections and

//following is to do with sound and image management

const sampler = new Tone.Sampler({
urls: {
B2: "horn-tone-b2.mp3",
C3: "horn-tone-c3.mp3",
E3: "horn-tone-e3.mp3",
G3: "horn-tone-g3.mp3",
A3: "horn-tone-a3.mp3",
C4: "horn-tone-c4.mp3"
},
baseUrl: "/sounds/",
onload: () => {
hideLoadScreen();
}
})

const reverb = new Tone.Reverb({
decay: 3,
predelay: 0,
wet: 0.5
}).toDestination();

sampler.connect(reverb);


sampler.set({
release: 8
});

synth.set( // setup the synth - this is audio stuff really
{
"volume": 0,
"detune": 0,
"portamento": 0,
"envelope": {
"attack": 2,
"attack": 40,
"attackCurve": "linear",
"decay": 0.1,
"decayCurve": "exponential",
"release": 2,
"releaseCurve": "exponential",
"sustain": 0.3
},
"oscillator": {
"partialCount": 0,
"partials": [],
"phase": 0,
"type": "triangle"
}
}
);

function playSynth(i) {
synth.triggerAttack(notes[i], Tone.now());
//document.getElementById(`i${i}`).src=`images/image${i}_2.jpg`; //using template literals to embed expressions within a string
sampler.triggerAttack(notes[i], Tone.now());
document.getElementById(`i${i}`).style.backgroundColor="magenta";
}

var col = ["rgb(255, 255, 0)", "rgb(200, 200, 0)", "rgb(255, 255, 0)", "rgb(200, 200, 0)", "rgb(255, 255, 0)", "rgb(200, 200, 0)", "rgb(255, 255, 0)", "rgb(200, 200, 0)", "rgb(255, 255, 0)"]; //colour of button

function stopSynth(i) {
synth.triggerRelease(notes[i], Tone.now());
//document.getElementById(`i${i}`).src=`images/image${i}.jpg`;
sampler.triggerRelease(notes[i], Tone.now());
document.getElementById(`i${i}`).style.backgroundColor=col[i];
}
Binary file removed sounds/eight.mp3
Binary file not shown.
Binary file removed sounds/five.mp3
Binary file not shown.
Binary file removed sounds/four.mp3
Binary file not shown.
Binary file added sounds/horn-tone-a3.mp3
Binary file not shown.
Binary file added sounds/horn-tone-b2.mp3
Binary file not shown.
Binary file added sounds/horn-tone-c3.mp3
Binary file not shown.
Binary file added sounds/horn-tone-c4.mp3
Binary file not shown.
Binary file added sounds/horn-tone-e3.mp3
Binary file not shown.
Binary file added sounds/horn-tone-g3.mp3
Binary file not shown.
Binary file removed sounds/nine.mp3
Binary file not shown.
Binary file removed sounds/one.mp3
Binary file not shown.
Binary file removed sounds/seven.mp3
Binary file not shown.
Binary file removed sounds/six.mp3
Binary file not shown.
Binary file removed sounds/three.mp3
Binary file not shown.
Binary file removed sounds/two.mp3
Binary file not shown.

0 comments on commit f23ff39

Please sign in to comment.