Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a4-alan-healy #41

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 7 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,11 @@
Assignment 4 - Creative Coding: Interactive Multimedia Experiences
===
## Virtual Synth Keyboard

Due: October 4th, by 11:59 AM.
https://a4-alan-healy.glitch.me/

For this assignment we will focus on client-side development using popular audio/graphics/visualization technologies. The goal of this assignment is to refine our JavaScript knowledge while exploring the multimedia capabilities of the browser.
This application is a simple synthesizer with piano keyboard controls. It provides a simple interface with 5 aspects of user input: pitch, gain, panning, wave type, and low pass filtering. It uses the default Web Audio API, and uses UI elements from the NexusUI API.

[WebAudio / Canvas / Three Tutorial](https://github.com/cs4241-21a/cs4241-21a.github.io/blob/main/webaudio_canvas_three.md)
[SVG + D3 tutorial](https://github.com/cs4241-21a/cs4241-21a.github.io/blob/main/using_svg_and_d3.md)
One of the main challenges I faced while creating the application was handling the audio clicking noise that can occur if an oscillator is turned off when not at a zero crossing.
To address this, I used an exponential fade to 0.001 on the main gain node before stopping any oscillator. This successfully reduced the audio clicking.
However, some of this clicking can still occur if the user clicks and quickly drags across the piano keyboard.

Baseline Requirements
---

Your application is required to implement the following functionalities:

- A server created using Express. This server can be as simple as needed.
- A client-side interactive experience using at least one of the following web technologies frameworks.
- [Three.js](https://threejs.org/): A library for 3D graphics / VR experiences
- [D3.js](https://d3js.org): A library that is primarily used for interactive data visualizations
- [Canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D raster drawing API included in all modern browsers
- [SVG](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D vector drawing framework that enables shapes to be defined via XML.
- [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API): An API for audio synthesis, analysis, processing, and file playback.
- A user interface for interaction with your project, which must expose at least four parameters for user control. [tweakpane](https://cocopon.github.io/tweakpane/) is highly recommended for this, but you can also use regular HTML `<input>` tags (the `range` type is useful to create sliders). You might also explore interaction by tracking mouse movement via the `window.onmousemove` event handler in tandem with the `event.clientX` and `event.clientY` properties. Consider using the [Pointer Events API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events) to ensure that that both mouse and touch events will both be supported in your app.
- Your application should display basic documentation for the user interface when the application first loads.

The interactive experience should possess a reasonable level of complexity. Some examples:
### Three.js
- A generative algorithm creates simple agents that move through a virtual world. Your interface controls the behavior / appearance of these agents.
- A simple 3D game... you really want this to be a simple as possible or it will be outside the scope of this assignment.
- An 3D audio visualization of a song of your choosing. User interaction should control aspects of the visualization.
### Canvas
- Implement a generative algorithm such as [Conway's Game of Life](https://bitstorm.org/gameoflife/) (or 1D cellular automata) and provide interactive controls. Note that the Game of Life has been created by 100s of people using <canvas>; we'll be checking to ensure that your implementation is not a copy of these.
- Design a 2D audio visualizer of a song of your choosing. User interaction should control visual aspects of the experience.
### Web Audio API
- Create a screen-based musical instrument using the Web Audio API. You can use projects such as [Interface.js](http://charlie-roberts.com/interface/) or [Nexus UI](https://nexus-js.github.io/ui/api/#Piano) to provide common musical interface elements, or use dat.GUI in combination with mouse/touch events (use the Pointer Events API). Your GUI should enable users to control aspects of sound synthesis. If you want to use higher-level instruments instead of the raw WebAudio API sounds, consider trying the instruments provided by [Tone.js]() or [Gibber](https://github.com/charlieroberts/gibber.audio.lib).
### D3.js
- Create visualizations using the datasets found at [Awesome JSON Datasets](https://github.com/jdorfman/Awesome-JSON-Datasets). Experiment with providing different visualizations of the same data set, and providing users interactive control over visualization parameters and/or data filtering. Alternatively, create a single visualization with using one of the more complicated techniques shown at [d3js.org](d3js.org) and provide meaningful points of interaction for users.

Deliverables
---

Do the following to complete this assignment:

1. Implement your project with the above requirements.
3. Test your project to make sure that when someone goes to your main page on Glitch/Heroku/etc., it displays correctly.
4. Ensure that your project has the proper naming scheme `a4-firstname-lastname` so we can find it.
5. Fork this repository and modify the README to the specifications below. *NOTE: If you don't use Glitch for hosting (where we can see the files) then you must include all project files that you author in your repo for this assignment*.
6. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a4-firstname-lastname`.

Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions)
---

## Your Web Application Title

your hosting link e.g. http://a4-charlieroberts.glitch.me

Include a very brief summary of your project here. Images are encouraged when needed, along with concise, high-level text. Be sure to include:

- the goal of the application
- challenges you faced in realizing the application
- the instructions you present in the website should be clear enough to use the application, but if you feel any need to provide additional instructions please do so here.
NOTE: Professor Roberts gave me an extension on this assignment.
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "virtual-synthesizer-keyboard",
"version": "1.0.0",
"description": "A simple synthesizer with keyboard controls.",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1"
},
"engines": {
"node": "14.18.0"
},
"repository": {
"url": "https://glitch.com/edit/#!/a4-alan-healy"
},
"keywords": [
"node",
"glitch",
"express",
"synthesizer"
]
}
140 changes: 140 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<!doctype html>
<html lang='en'>
<head>

<title>A4 Music Synthesizer</title>

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lato&display=swap" rel="stylesheet">

<style>
body {
background-color: #ccdce6;
font-family: 'Lato', sans-serif;
text-align: center;
}

p {
margin:auto;
width: 700px;
text-align: justify;
}

h2 {
text-align: left;
width: 700px;
margin:auto;
}

button {
display:block;
margin:auto;
width: 50px;
}

#piano {
display: none;
margin: auto;
}

#optionsDiv {
display: none;
margin: auto;
width: 700px;
}

#spectrogram {
display: none;
margin: auto;
}

.optionBlock {
float: left;
margin:auto;
text-align:center;
}

#toggleFilter {
margin-left: 40px;
}

#filterFrequency {
margin-left: 30px;
}
</style>

<script src='/js/scripts.js' type='module'></script>
<script src='https://cdn.jsdelivr.net/npm/nexusui@latest/dist/NexusUI.js'></script>

</head>
<body>
<h1>
Virtual Synthesizer Keyboard
</h1>

<button id="start">Start</button>

<div id="piano"></div>

<div id="optionsDiv">

<div class="optionBlock">

<h3>Gain Dial</h3>

<div id="gainDial" class="option"></div>

</div>

<div class="optionBlock">

<h3>Panning Slider</h3>

<div id="panSlider" class="option"></div>
</div>

<div class="optionBlock">

<h3>Wave Type</h3>

<div id="waveTypeSelector" class="option"></div>
</div>

<div class="optionBlock">
<h3>
Low Pass Filter
</h3>
<div id="toggleFilter" class="option"></div>

<div id="filterFrequency" class="option"></div>

</div>

</div><br>

<div id="spectrogram"></div>

<h2>
Instructions:
</h2><br>
<p>
This application provides controls for a basic synthesizer. Press the "Start" button to display the controls and begin using the synthesizer.
</p><br>
<p>
Click and hold a key on the keyboard displayed to play a note ranging from C1 (32.703 Hz) to C6 (1046.5 Hz). Release the click to stop playing the note. You can also click and drag to change what note is being played, but doing this too quickly may cause sound clipping issues.
</p><br>
<p>
Click and drag the "Gain Dial" to adjust the gain of the audio from 0% to 100%. By default, the gain is set to 25%.
</p><br>
<p>
Click and drag the "Panning Slider" left or right to adjust the stereo panning of the audio. At all the way left, all audio will come out of your left speaker or headphone. At all the way right, all audio will come out of your right speaker or headphone.
</p><br>
<p>
Select a wave type from the "Wave Type" box. You can choose between sine, square, sawtooth, and triangle waves.
</p><br>
<p>
The toggle under the "Low Pass Filter" heading turns the low pass filter on and off. When the low pass filter is enabled, frequencies above the number in the box below the toggle will be filtered out from the audio. You can click and drag this box up or down to increase or decrease the filtering frequency.
</p>
</body>
</html>
Loading