Skip to content

Commit

Permalink
a basic mosquito, i got a bad feeling about this
Browse files Browse the repository at this point in the history
  • Loading branch information
tholman committed Feb 23, 2020
1 parent a684f6e commit 717bee2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mosquito/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Mosquito JS</title>
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<header class="center">
<button>🦟</button>
</header>
<script src="./mosquito.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions mosquito/mosquito.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

let context = new (window.AudioContext || window.webkitAudioContext)();

let oscillator = context.createOscillator();
oscillator.type = "sawtooth";
oscillator.frequency.setValueAtTime(750, context.currentTime);

const gainNode = context.createGain();
gainNode.connect(context.destination);

oscillator.connect(gainNode);

document.querySelector("button").onclick = () => {
oscillator.start();
};
22 changes: 22 additions & 0 deletions mosquito/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
* {
box-sizing: border-box;
}

html,
body {
margin: 0;
}

.center {
display: flex;
justify-content: center;
align-items: center;
}

header {
width: 100%;
height: 100vh;
background: #fff;
flex-direction: column;
border: 20px solid #eee;
}

0 comments on commit 717bee2

Please sign in to comment.