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

added Virtual-Piano #320

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
78 changes: 78 additions & 0 deletions Vanilla-JS-Projects/Basic/Virtual-Piano/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<h1 align='center'><b>💥 VIRTUAL-PIANO 💥</b></h1>

<!-- -------------------------------------------------------------------------------------------------------------- -->

<h3 align='center'>Tech Stack Used 🎮</h3>
<!-- enlist all the technologies used to create this project from them (Remove comment using 'ctrl+z' or 'command+z') -->

<div align='center'>

![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?style=for-the-badge&logo=html5&logoColor=white)
![CSS3](https://img.shields.io/badge/css3-%231572B6.svg?style=for-the-badge&logo=css3&logoColor=white)
<!-- ![Bootstrap](https://img.shields.io/badge/bootstrap-%238511FA.svg?style=for-the-badge&logo=bootstrap&logoColor=white) -->
![JavaScript](https://img.shields.io/badge/javascript-%23323330.svg?style=for-the-badge&logo=javascript&logoColor=%23F7DF1E)
<!-- ![jQuery](https://img.shields.io/badge/jquery-%230769AD.svg?style=for-the-badge&logo=jquery&logoColor=white) -->
<!-- ![React](https://img.shields.io/badge/react-%2320232a.svg?style=for-the-badge&logo=react&logoColor=%2361DAFB) -->
<!-- ![Redux](https://img.shields.io/badge/redux-%23593d88.svg?style=for-the-badge&logo=redux&logoColor=white) -->
<!-- ![TailwindCSS](https://img.shields.io/badge/tailwindcss-%2338B2AC.svg?style=for-the-badge&logo=tailwind-css&logoColor=white) -->
<!-- ![Web3.js](https://img.shields.io/badge/web3.js-F16822?style=for-the-badge&logo=web3.js&logoColor=white) -->
<!-- ![Express.js](https://img.shields.io/badge/express.js-%23404d59.svg?style=for-the-badge&logo=express&logoColor=%2361DAFB) -->
<!-- ![Angular.js](https://img.shields.io/badge/angular.js-%23E23237.svg?style=for-the-badge&logo=angularjs&logoColor=white) -->
<!-- ![Next JS](https://img.shields.io/badge/Next-black?style=for-the-badge&logo=next.js&logoColor=white) -->
<!-- ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?style=for-the-badge&logo=node.js&logoColor=white) -->
<!-- ![Vue.js](https://img.shields.io/badge/vuejs-%2335495e.svg?style=for-the-badge&logo=vuedotjs&logoColor=%234FC08D) -->
<!-- ![MongoDB](https://img.shields.io/badge/MongoDB-%234ea94b.svg?style=for-the-badge&logo=mongodb&logoColor=white) -->
</div>


![Line](https://github.com/Avdhesh-Varshney/WebMasterLog/assets/114330097/4b78510f-a941-45f8-a9d5-80ed0705e847)

<!-- -------------------------------------------------------------------------------------------------------------- -->

## :zap: Description 📃

<div>
<!-- <p>Add Description of the project</p> -->
<p>Virtual Piano enables users to play a digital piano through both mouse clicks and key presses, offering a versatile and interactive musical experience With Custamizable Volume.</p>
</div>


<!-- -------------------------------------------------------------------------------------------------------------- -->

## :zap: How to run it? 🕹️

<!-- Add steps how to run this project -->

- Clone this repository.
- Navigate to this project directory
- Run the `index.html` file.

<!-- -------------------------------------------------------------------------------------------------------------- -->

## :zap: Screenshots 📸
<!-- add the screenshot of the project (Mandatory) -->
![img](./screenshot.webp)


## :zap: Working Video 📹
<!-- directly add the link of video (If, possible) -->
Avdhesh-Varshney marked this conversation as resolved.
Show resolved Hide resolved



![Line](https://github.com/Avdhesh-Varshney/WebMasterLog/assets/114330097/4b78510f-a941-45f8-a9d5-80ed0705e847)

<!-- -------------------------------------------------------------------------------------------------------------- -->

<h4 align='center'>Developed By <b><i>MANKALA VAISHNAVI</i></b> 👦</h4>
<p align='center'>
<a href='https://www.linkedin.com/in/vaishnavi-mankala-33a256252/'>
<img src='https://img.shields.io/badge/linkedin-%230077B5.svg?style=for-the-badge&logo=linkedin&logoColor=white' />
</a>
<a href='https://github.com/VaishnaviMankala19'>
<img src='https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white' />
</a>
</p>

<h4 align='center'>Happy Coding 🧑‍💻</h4>

<h3 align="center">Show some &nbsp;❤️&nbsp; by &nbsp;🌟&nbsp; this repository!</h3>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions Vanilla-JS-Projects/Basic/Virtual-Piano/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>VIRTUAL PIANO</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="wrapper">
<header>
<h2>VIRTUAL PIANO</h2>
<div class="column volume-slider">
<span>Volume</span><input type="range" min="0" max="1" value="0.5" step="any">
</div>
<div class="column keys-checkbox">
<span>Show Keys</span><input type="checkbox" checked>
</div>
</header>
<ul class="piano-keys">
<li class="key white" data-key="a"><span>a</span></li>
<li class="key black" data-key="w"><span>w</span></li>
<li class="key white" data-key="s"><span>s</span></li>
<li class="key black" data-key="e"><span>e</span></li>
<li class="key white" data-key="d"><span>d</span></li>
<li class="key white" data-key="f"><span>f</span></li>
<li class="key black" data-key="t"><span>t</span></li>
<li class="key white" data-key="g"><span>g</span></li>
<li class="key black" data-key="y"><span>y</span></li>
<li class="key white" data-key="h"><span>h</span></li>
<li class="key black" data-key="u"><span>u</span></li>
<li class="key white" data-key="j"><span>j</span></li>
<li class="key white" data-key="k"><span>k</span></li>
<li class="key black" data-key="o"><span>o</span></li>
<li class="key white" data-key="l"><span>l</span></li>
<li class="key black" data-key="p"><span>p</span></li>
<li class="key white" data-key=";"><span>;</span></li>
</ul>
</div>
<script src="script.js"></script>
</body>
</html>
Binary file not shown.
41 changes: 41 additions & 0 deletions Vanilla-JS-Projects/Basic/Virtual-Piano/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const pianoKeys = document.querySelectorAll(".piano-keys .key"),
volumeSlider = document.querySelector(".volume-slider input"),
keysCheckbox = document.querySelector(".keys-checkbox input");

let allKeys = [],
audio = new Audio("tunes/a.wav");

const playTune = (key) => {
audio.src = `tunes/${key}.wav`;
audio.play();

const clickedKey = document.querySelector(`[data-key="${key}"]`);
clickedKey.classList.add("active");

setTimeout(() => {
clickedKey.classList.remove("active");
}, 150);
}

pianoKeys.forEach(key => {

allKeys.push(key.dataset.key);
key.addEventListener("click", () => playTune(key.dataset.key))

});

const showHideKeys = () => {
pianoKeys.forEach(key => key.classList.toggle("hide"))
}

const handleVolume = (e) => {
audio.volume = e.target.value;
}

const pressedKey = (e) => {
if(allKeys.includes(e.key)) playTune(e.key);
}

keysCheckbox.addEventListener("click", showHideKeys);
volumeSlider.addEventListener("input", handleVolume);
document.addEventListener("keydown", pressedKey);
178 changes: 178 additions & 0 deletions Vanilla-JS-Projects/Basic/Virtual-Piano/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap');

*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}

body{
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background-image: url('./image/background_image.jpg');
background-repeat: no-repeat;
background-position: center;
background-size: cover;
padding: 0 10px;
}

.wrapper{
border-radius: 20px;
background: #141414;
padding: 35px 40px;
}

.wrapper header{
color: #b2b2b2;
display: flex;
align-items: center;
justify-content: space-between;
}

header h2{
font-size: 1.6rem;
}

header .column{
display: flex;
align-items: center;
}

header .column span{
font-weight: 500;
margin-right: 15px;
font-size: 1.19rem;
}

.volume-slider input{
outline: none;
accent-color: #fff;
}

.keys-checkbox input{
width: 60px;
height: 30px;
border-radius: 30px;
cursor: pointer;
appearance: none;
background: #4b4b4b;
position: relative;
}

.keys-checkbox input::before{
content: "";
position: absolute;
background: #8c8c8c;
height: 20px;
width: 20px;
border-radius: inherit;
top: 50%;
left: 5px;
transform: translateY(-50%);
transition: all 0.3s ease;
}

.keys-checkbox input:checked::before{
left: 35px;
background: #fff;
}

.piano-keys{
display: flex;
margin-top: 40px;
}

.piano-keys .key{
cursor: pointer;
list-style: none;
color: #a2a2a2;
text-transform: uppercase;
position: relative;
user-select: none;
}

.piano-keys .black{
width: 44px;
height: 140px;
z-index: 2;
margin: 0 -22px 0 -22px;
border-radius: 0 0 5px 5px;
background: linear-gradient(#333, #000);
}

.piano-keys .black.active{
box-shadow: inset -5px 5px 10px rgba(255,255,255,0.1);
background: linear-gradient(to bottom, #000 , #434343 );
}

.piano-keys .white{
width: 70px;
height: 230px;
border-radius: 8px;
border: 1px solid #000;
background: linear-gradient(#fff 96%, #eee 4%);
}

.piano-keys .white.active{
box-shadow: inset -5px 5px 20px rgba(0,0,0,0.2);
background: linear-gradient(to bottom, #fff 0%, #eee 100%);
}

.piano-keys span{
position: absolute;
bottom: 20px;
width: 100%;
text-align: center;
font-size: 1.13rem;
}

.piano-keys .key.hide span{
display: none;
}

@media screen and (max-width: 815px) {
.wrapper {
padding: 25px;
}
header {
flex-direction: column;
}
header :where(h2, .column) {
margin-bottom: 13px;
}
.volume-slider input {
max-width: 100px;
}
.piano-keys {
margin-top: 20px;
}
.piano-keys .key:where(:nth-child(9), :nth-child(10)) {
display: none;
}
.piano-keys .black {
height: 100px;
width: 40px;
margin: 0 -20px 0 -20px;
}
.piano-keys .white {
height: 180px;
width: 60px;
}
}


@media screen and (max-width: 615px) {
.piano-keys .key:nth-child(13),
.piano-keys .key:nth-child(14),
.piano-keys .key:nth-child(15),
.piano-keys .key:nth-child(16),
.piano-keys .key :nth-child(17) {
display: none;
}
.piano-keys .white {
width: 50px;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions Vanilla-JS-Projects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
| 33 | [Social Media Analytics](./Intermediate/Social-Media-Analytics/) | ![Intermediate](https://img.shields.io/badge/Intermediate-FFD700?style=for-the-badge) |
| 34 | [Movie Finder](./Intermediate/Movie-Finder/) | ![Intermediate](https://img.shields.io/badge/Intermediate-FFD700?style=for-the-badge) |
| 35 | [Resume Builder](./Advanced/Resume-Builder/) |![Advanced](https://img.shields.io/badge/Advanced-FF0000?style=for-the-badge) |
| 36 | [Virtual-Piano](./Basic/Virtual-Piano/) | ![Basic](https://img.shields.io/badge/Basic-00FF00?style=for-the-badge) |
</div>


Expand Down
5 changes: 5 additions & 0 deletions database/vanilla.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,10 @@
"tag": "Basic",
"title": "CSS Art Gallery",
"description" :"CSS Art Gallery showcases the art developed by CSS"
},
{
"tag":"Basic",
"title":"Virtual-Piano",
"description":"Virtual Piano enables users to play a digital piano with adjustable volumes, providing a customizable and interactive musical experience."
}
]