From ee2914a64eed0659eaad23d3a4723c9508f92016 Mon Sep 17 00:00:00 2001 From: 1911aditi <146438609+1911aditi@users.noreply.github.com> Date: Sun, 23 Jun 2024 23:39:04 +0530 Subject: [PATCH 1/8] Add files via upload --- Calculators/SOUND-LEVEL-CALCULATOR/README.md | 0 Calculators/SOUND-LEVEL-CALCULATOR/index.html | 17 +++++++ Calculators/SOUND-LEVEL-CALCULATOR/script.js | 51 +++++++++++++++++++ Calculators/SOUND-LEVEL-CALCULATOR/style.css | 26 ++++++++++ 4 files changed, 94 insertions(+) create mode 100644 Calculators/SOUND-LEVEL-CALCULATOR/README.md create mode 100644 Calculators/SOUND-LEVEL-CALCULATOR/index.html create mode 100644 Calculators/SOUND-LEVEL-CALCULATOR/script.js create mode 100644 Calculators/SOUND-LEVEL-CALCULATOR/style.css diff --git a/Calculators/SOUND-LEVEL-CALCULATOR/README.md b/Calculators/SOUND-LEVEL-CALCULATOR/README.md new file mode 100644 index 000000000..e69de29bb diff --git a/Calculators/SOUND-LEVEL-CALCULATOR/index.html b/Calculators/SOUND-LEVEL-CALCULATOR/index.html new file mode 100644 index 000000000..450ab89d8 --- /dev/null +++ b/Calculators/SOUND-LEVEL-CALCULATOR/index.html @@ -0,0 +1,17 @@ + + + + + + Sound Level Calculator + + + +
+

Sound Level Calculator

+ +

Sound Level: 0 dB

+
+ + + diff --git a/Calculators/SOUND-LEVEL-CALCULATOR/script.js b/Calculators/SOUND-LEVEL-CALCULATOR/script.js new file mode 100644 index 000000000..9f0205c63 --- /dev/null +++ b/Calculators/SOUND-LEVEL-CALCULATOR/script.js @@ -0,0 +1,51 @@ +document.addEventListener('DOMContentLoaded', function() { + const startButton = document.getElementById('start-button'); + const soundLevelDisplay = document.getElementById('sound-level'); + + let audioContext; + let analyser; + let microphone; + let javascriptNode; + + startButton.addEventListener('click', startMeasuring); + + function startMeasuring() { + if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { + alert('Your browser does not support the required features.'); + return; + } + + navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => { + audioContext = new (window.AudioContext || window.webkitAudioContext)(); + analyser = audioContext.createAnalyser(); + microphone = audioContext.createMediaStreamSource(stream); + javascriptNode = audioContext.createScriptProcessor(2048, 1, 1); + + analyser.smoothingTimeConstant = 0.8; + analyser.fftSize = 1024; + + microphone.connect(analyser); + analyser.connect(javascriptNode); + javascriptNode.connect(audioContext.destination); + + javascriptNode.onaudioprocess = function() { + const array = new Uint8Array(analyser.frequencyBinCount); + analyser.getByteFrequencyData(array); + let values = 0; + + for (let i = 0; i < array.length; i++) { + values += array[i]; + } + + const average = values / array.length; + const dB = Math.round(20 * Math.log10(average)); + + soundLevelDisplay.textContent = dB; + }; + }).catch(err => { + console.error(err); + alert('Error accessing the microphone.'); + }); + } + }); + \ No newline at end of file diff --git a/Calculators/SOUND-LEVEL-CALCULATOR/style.css b/Calculators/SOUND-LEVEL-CALCULATOR/style.css new file mode 100644 index 000000000..3f9efca61 --- /dev/null +++ b/Calculators/SOUND-LEVEL-CALCULATOR/style.css @@ -0,0 +1,26 @@ +body { + font-family: Arial, sans-serif; + background-color: #282c34; + color: white; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; + } + + .container { + text-align: center; + } + + button { + padding: 10px 20px; + font-size: 16px; + margin-top: 20px; + } + + p { + font-size: 24px; + margin-top: 20px; + } + \ No newline at end of file From ea7dd6c829f695e5b00d1a3fd2278540bd7252d8 Mon Sep 17 00:00:00 2001 From: 1911aditi <146438609+1911aditi@users.noreply.github.com> Date: Wed, 26 Jun 2024 10:20:11 +0530 Subject: [PATCH 2/8] Delete Calculators/SOUND-LEVEL-CALCULATOR directory --- Calculators/SOUND-LEVEL-CALCULATOR/README.md | 0 Calculators/SOUND-LEVEL-CALCULATOR/index.html | 17 ------- Calculators/SOUND-LEVEL-CALCULATOR/script.js | 51 ------------------- Calculators/SOUND-LEVEL-CALCULATOR/style.css | 26 ---------- 4 files changed, 94 deletions(-) delete mode 100644 Calculators/SOUND-LEVEL-CALCULATOR/README.md delete mode 100644 Calculators/SOUND-LEVEL-CALCULATOR/index.html delete mode 100644 Calculators/SOUND-LEVEL-CALCULATOR/script.js delete mode 100644 Calculators/SOUND-LEVEL-CALCULATOR/style.css diff --git a/Calculators/SOUND-LEVEL-CALCULATOR/README.md b/Calculators/SOUND-LEVEL-CALCULATOR/README.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/Calculators/SOUND-LEVEL-CALCULATOR/index.html b/Calculators/SOUND-LEVEL-CALCULATOR/index.html deleted file mode 100644 index 450ab89d8..000000000 --- a/Calculators/SOUND-LEVEL-CALCULATOR/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Sound Level Calculator - - - -
-

Sound Level Calculator

- -

Sound Level: 0 dB

-
- - - diff --git a/Calculators/SOUND-LEVEL-CALCULATOR/script.js b/Calculators/SOUND-LEVEL-CALCULATOR/script.js deleted file mode 100644 index 9f0205c63..000000000 --- a/Calculators/SOUND-LEVEL-CALCULATOR/script.js +++ /dev/null @@ -1,51 +0,0 @@ -document.addEventListener('DOMContentLoaded', function() { - const startButton = document.getElementById('start-button'); - const soundLevelDisplay = document.getElementById('sound-level'); - - let audioContext; - let analyser; - let microphone; - let javascriptNode; - - startButton.addEventListener('click', startMeasuring); - - function startMeasuring() { - if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { - alert('Your browser does not support the required features.'); - return; - } - - navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => { - audioContext = new (window.AudioContext || window.webkitAudioContext)(); - analyser = audioContext.createAnalyser(); - microphone = audioContext.createMediaStreamSource(stream); - javascriptNode = audioContext.createScriptProcessor(2048, 1, 1); - - analyser.smoothingTimeConstant = 0.8; - analyser.fftSize = 1024; - - microphone.connect(analyser); - analyser.connect(javascriptNode); - javascriptNode.connect(audioContext.destination); - - javascriptNode.onaudioprocess = function() { - const array = new Uint8Array(analyser.frequencyBinCount); - analyser.getByteFrequencyData(array); - let values = 0; - - for (let i = 0; i < array.length; i++) { - values += array[i]; - } - - const average = values / array.length; - const dB = Math.round(20 * Math.log10(average)); - - soundLevelDisplay.textContent = dB; - }; - }).catch(err => { - console.error(err); - alert('Error accessing the microphone.'); - }); - } - }); - \ No newline at end of file diff --git a/Calculators/SOUND-LEVEL-CALCULATOR/style.css b/Calculators/SOUND-LEVEL-CALCULATOR/style.css deleted file mode 100644 index 3f9efca61..000000000 --- a/Calculators/SOUND-LEVEL-CALCULATOR/style.css +++ /dev/null @@ -1,26 +0,0 @@ -body { - font-family: Arial, sans-serif; - background-color: #282c34; - color: white; - display: flex; - justify-content: center; - align-items: center; - height: 100vh; - margin: 0; - } - - .container { - text-align: center; - } - - button { - padding: 10px 20px; - font-size: 16px; - margin-top: 20px; - } - - p { - font-size: 24px; - margin-top: 20px; - } - \ No newline at end of file From 79933b8f7de45d831c5d188d2aa6308c01348f4d Mon Sep 17 00:00:00 2001 From: 1911aditi <146438609+1911aditi@users.noreply.github.com> Date: Wed, 26 Jun 2024 10:20:28 +0530 Subject: [PATCH 3/8] Add files via upload --- Calculators/Sound-Level-Calculator/README.md | 50 ++++++++ Calculators/Sound-Level-Calculator/index.html | 112 ++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 Calculators/Sound-Level-Calculator/README.md create mode 100644 Calculators/Sound-Level-Calculator/index.html diff --git a/Calculators/Sound-Level-Calculator/README.md b/Calculators/Sound-Level-Calculator/README.md new file mode 100644 index 000000000..552d98e4b --- /dev/null +++ b/Calculators/Sound-Level-Calculator/README.md @@ -0,0 +1,50 @@ +# Sound Level Calculator + +A simple web-based sound level calculator that allows users to input two sound levels in decibels (dB) and calculate the combined sound level. + +## Table of Contents +- [Demo](#demo) +- [Features](#features) +- [Technologies](#technologies) +- [Setup](#setup) +- [Usage](#usage) +- [License](#license) + +## Demo +You can view a live demo of the Sound Level Calculator [here](https://example.com). + +## Features +- Simple and intuitive user interface +- Real-time calculation of combined sound levels +- Responsive design for mobile and desktop use + +## Technologies +- HTML +- CSS +- JavaScript + +## Setup +To set up the project locally, follow these steps: + +1. Clone the repository: + ```bash + git clone https://github.com/yourusername/sound-level-calculator.git + ``` + +2. Navigate to the project directory: + ```bash + cd sound-level-calculator + ``` + +3. Open `index.html` in your web browser: + ```bash + open index.html + ``` + +## Usage +1. Open the Sound Level Calculator in your web browser. +2. Enter two sound levels in decibels (dB) into the input fields. +3. Click the "Calculate" button to see the combined sound level. + +## License +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. diff --git a/Calculators/Sound-Level-Calculator/index.html b/Calculators/Sound-Level-Calculator/index.html new file mode 100644 index 000000000..17000a3c9 --- /dev/null +++ b/Calculators/Sound-Level-Calculator/index.html @@ -0,0 +1,112 @@ + + + + + + Sound Level Calculator + + + +
+

Sound Level Calculator

+
+
+ + +
+
+ + +
+ +
+
+

Combined Sound Level: 0 dB

+
+
+ + + From be1112e694b5a3dae858ca218536be150a7a9798 Mon Sep 17 00:00:00 2001 From: 1911aditi <146438609+1911aditi@users.noreply.github.com> Date: Fri, 28 Jun 2024 10:11:17 +0530 Subject: [PATCH 4/8] Delete Calculators/Sound-Level-Calculator directory --- Calculators/Sound-Level-Calculator/README.md | 50 -------- Calculators/Sound-Level-Calculator/index.html | 112 ------------------ 2 files changed, 162 deletions(-) delete mode 100644 Calculators/Sound-Level-Calculator/README.md delete mode 100644 Calculators/Sound-Level-Calculator/index.html diff --git a/Calculators/Sound-Level-Calculator/README.md b/Calculators/Sound-Level-Calculator/README.md deleted file mode 100644 index 552d98e4b..000000000 --- a/Calculators/Sound-Level-Calculator/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# Sound Level Calculator - -A simple web-based sound level calculator that allows users to input two sound levels in decibels (dB) and calculate the combined sound level. - -## Table of Contents -- [Demo](#demo) -- [Features](#features) -- [Technologies](#technologies) -- [Setup](#setup) -- [Usage](#usage) -- [License](#license) - -## Demo -You can view a live demo of the Sound Level Calculator [here](https://example.com). - -## Features -- Simple and intuitive user interface -- Real-time calculation of combined sound levels -- Responsive design for mobile and desktop use - -## Technologies -- HTML -- CSS -- JavaScript - -## Setup -To set up the project locally, follow these steps: - -1. Clone the repository: - ```bash - git clone https://github.com/yourusername/sound-level-calculator.git - ``` - -2. Navigate to the project directory: - ```bash - cd sound-level-calculator - ``` - -3. Open `index.html` in your web browser: - ```bash - open index.html - ``` - -## Usage -1. Open the Sound Level Calculator in your web browser. -2. Enter two sound levels in decibels (dB) into the input fields. -3. Click the "Calculate" button to see the combined sound level. - -## License -This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. diff --git a/Calculators/Sound-Level-Calculator/index.html b/Calculators/Sound-Level-Calculator/index.html deleted file mode 100644 index 17000a3c9..000000000 --- a/Calculators/Sound-Level-Calculator/index.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - Sound Level Calculator - - - -
-

Sound Level Calculator

-
-
- - -
-
- - -
- -
-
-

Combined Sound Level: 0 dB

-
-
- - - From b4a98a1479613407214613b85c6b5f10fd906379 Mon Sep 17 00:00:00 2001 From: 1911aditi <146438609+1911aditi@users.noreply.github.com> Date: Fri, 28 Jun 2024 10:11:53 +0530 Subject: [PATCH 5/8] Add files via upload --- Calculators/Sound-Level-Calculator/README.md | 48 +++++++++++++++ Calculators/Sound-Level-Calculator/index.html | 29 +++++++++ Calculators/Sound-Level-Calculator/script.js | 22 +++++++ Calculators/Sound-Level-Calculator/style.css | 59 +++++++++++++++++++ 4 files changed, 158 insertions(+) create mode 100644 Calculators/Sound-Level-Calculator/README.md create mode 100644 Calculators/Sound-Level-Calculator/index.html create mode 100644 Calculators/Sound-Level-Calculator/script.js create mode 100644 Calculators/Sound-Level-Calculator/style.css diff --git a/Calculators/Sound-Level-Calculator/README.md b/Calculators/Sound-Level-Calculator/README.md new file mode 100644 index 000000000..b4be19128 --- /dev/null +++ b/Calculators/Sound-Level-Calculator/README.md @@ -0,0 +1,48 @@ +# Sound Level Calculator + +A simple web-based sound level calculator that allows users to input two sound levels in decibels (dB) and calculate the combined sound level. + +## Table of Contents +- [Demo](#demo) +- [Features](#features) +- [Technologies](#technologies) +- [Setup](#setup) +- [Usage](#usage) +- [License](#license) + + +## Features +- Simple and intuitive user interface +- Real-time calculation of combined sound levels +- Responsive design for mobile and desktop use + +## Technologies +- HTML +- CSS +- JavaScript + +## Setup +To set up the project locally, follow these steps: + +1. Clone the repository: + ```bash + git clone https://github.com/yourusername/sound-level-calculator.git + ``` + +2. Navigate to the project directory: + ```bash + cd sound-level-calculator + ``` + +3. Open `index.html` in your web browser: + ```bash + open index.html + ``` + +## Usage +1. Open the Sound Level Calculator in your web browser. +2. Enter two sound levels in decibels (dB) into the input fields. +3. Click the "Calculate" button to see the combined sound level. + +## License +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. diff --git a/Calculators/Sound-Level-Calculator/index.html b/Calculators/Sound-Level-Calculator/index.html new file mode 100644 index 000000000..3fbeba278 --- /dev/null +++ b/Calculators/Sound-Level-Calculator/index.html @@ -0,0 +1,29 @@ + + + + + + Sound Level Calculator + + + +
+

Sound Level Calculator

+
+
+ + +
+
+ + +
+ +
+
+

Combined Sound Level: 0 dB

+
+
+ + + diff --git a/Calculators/Sound-Level-Calculator/script.js b/Calculators/Sound-Level-Calculator/script.js new file mode 100644 index 000000000..dc1a35ff1 --- /dev/null +++ b/Calculators/Sound-Level-Calculator/script.js @@ -0,0 +1,22 @@ +document.getElementById('soundForm').addEventListener('submit', function(event) { + event.preventDefault(); + + const sound1 = parseFloat(document.getElementById('sound1').value); + const sound2 = parseFloat(document.getElementById('sound2').value); + + if (isNaN(sound1) || isNaN(sound2)) { + alert('Please enter valid numbers for both sound levels.'); + return; + } + + const combinedSoundLevel = calculateCombinedSoundLevel(sound1, sound2); + document.getElementById('result').textContent = combinedSoundLevel.toFixed(2); +}); + +function calculateCombinedSoundLevel(sound1, sound2) { + const power1 = Math.pow(10, sound1 / 10); + const power2 = Math.pow(10, sound2 / 10); + const combinedPower = power1 + power2; + const combinedSoundLevel = 10 * Math.log10(combinedPower); + return combinedSoundLevel; +} diff --git a/Calculators/Sound-Level-Calculator/style.css b/Calculators/Sound-Level-Calculator/style.css new file mode 100644 index 000000000..d0cfa78aa --- /dev/null +++ b/Calculators/Sound-Level-Calculator/style.css @@ -0,0 +1,59 @@ +body { + font-family: Arial, sans-serif; + background-color: #f4f4f4; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + margin: 0; +} + +.container { + background: #fff; + padding: 20px; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + text-align: center; +} + +h1 { + margin-bottom: 20px; +} + +.input-group { + margin-bottom: 15px; +} + +.input-group label { + display: block; + margin-bottom: 5px; +} + +.input-group input { + width: 100%; + padding: 10px; + border: 1px solid #ccc; + border-radius: 5px; +} + +button { + padding: 10px 20px; + border: none; + border-radius: 5px; + background-color: #5cb85c; + color: #fff; + cursor: pointer; + font-size: 16px; +} + +button:hover { + background-color: #4cae4c; +} + +.result { + margin-top: 20px; +} + +.result h2 { + font-size: 24px; +} From 741fe3a0a73dff568845af624a7ec65ff0bd7970 Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Mon, 1 Jul 2024 16:36:14 +0530 Subject: [PATCH 6/8] Update index.html --- index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/index.html b/index.html index f6f376fb8..2f85553c0 100644 --- a/index.html +++ b/index.html @@ -3366,6 +3366,20 @@

Calculates the amount one can save on electricity by installing solar panels +
+
+

Sound Level Calculator

+

Calculator to combine two sound levels in decibels (dB).

+ +
+

Speed Calculator

From 9f6e5b26be75f77d8cdcb02ad4d9a9b52c4317d1 Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Mon, 1 Jul 2024 16:40:56 +0530 Subject: [PATCH 7/8] Update README.md --- Calculators/Sound-Level-Calculator/README.md | 43 ++------------------ 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/Calculators/Sound-Level-Calculator/README.md b/Calculators/Sound-Level-Calculator/README.md index b4be19128..9e90a8edc 100644 --- a/Calculators/Sound-Level-Calculator/README.md +++ b/Calculators/Sound-Level-Calculator/README.md @@ -1,48 +1,13 @@ -# Sound Level Calculator +#

Sound Level Calculator

A simple web-based sound level calculator that allows users to input two sound levels in decibels (dB) and calculate the combined sound level. -## Table of Contents -- [Demo](#demo) -- [Features](#features) -- [Technologies](#technologies) -- [Setup](#setup) -- [Usage](#usage) -- [License](#license) +## Tech Stacks :- - -## Features -- Simple and intuitive user interface -- Real-time calculation of combined sound levels -- Responsive design for mobile and desktop use - -## Technologies - HTML - CSS - JavaScript -## Setup -To set up the project locally, follow these steps: - -1. Clone the repository: - ```bash - git clone https://github.com/yourusername/sound-level-calculator.git - ``` - -2. Navigate to the project directory: - ```bash - cd sound-level-calculator - ``` - -3. Open `index.html` in your web browser: - ```bash - open index.html - ``` - -## Usage -1. Open the Sound Level Calculator in your web browser. -2. Enter two sound levels in decibels (dB) into the input fields. -3. Click the "Calculate" button to see the combined sound level. +## Screenshots :- -## License -This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. +![image](https://github.com/Rakesh9100/CalcDiverse/assets/73993775/ea90d4e9-8e3a-40f1-9949-f7134d663506) From 63876a75885976ba708cd20113ea2c54a6863faf Mon Sep 17 00:00:00 2001 From: Rakesh Roshan Date: Mon, 1 Jul 2024 16:41:06 +0530 Subject: [PATCH 8/8] Update index.html --- Calculators/Sound-Level-Calculator/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Calculators/Sound-Level-Calculator/index.html b/Calculators/Sound-Level-Calculator/index.html index 3fbeba278..b34b4b040 100644 --- a/Calculators/Sound-Level-Calculator/index.html +++ b/Calculators/Sound-Level-Calculator/index.html @@ -3,8 +3,8 @@ - Sound Level Calculator + Sound Level Calculator