diff --git a/LICENSE.TLDR.md b/LICENSE.TLDR.md new file mode 100644 index 0000000..0e88742 --- /dev/null +++ b/LICENSE.TLDR.md @@ -0,0 +1,45 @@ +# The MIT License (MIT) + +A short, permissive software license. Basically, you can do whatever you want as long as you include the original copyright and license notice in any copy of the software/source. + +## Can + +- Commercial Use +- Modify +- Distribute +- Sublicense +- Private Use + +## Cannot + +- Hold lible + +## Must + +- Include Copyright +- Include License + +--- + +**Disclaimer:** This TL;DR summary is provided for convenience and informational +purposes only. It is not a substitute for the +[full text of the Apache License 2.0](LICENSE). The full license should be +consulted for a comprehensive understanding of your rights and obligations. +In the event of any discrepancies or legal questions, the full license text +takes precedence. + +TL;DR for this licence was taken from +[TLDRLegal](https://www.tldrlegal.com/license/apache-license-2-0-apache-2-0) + + +--- + +**Disclaimer:** This TL;DR summary is provided for convenience and informational +purposes only. It is not a substitute for the +[full text of the License](LICENSE). The full license should be +consulted for a comprehensive understanding of your rights and obligations. +In the event of any discrepancies or legal questions, the full license text +takes precedence. + +TL;DR for this licence was taken from +[TLDRLegal](https://www.tldrlegal.com/license/mit-license) diff --git a/README.md b/README.md index 58c6d7f..8e431fb 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The 5mdt Noise Generator is a web-based application that generates different types of noises locally, including brown, white, and pink noise. It allows users to play these noises and control their volume. -There is no tracking, ads or even cookies here. It's absolutely free to use and modify +There is no tracking, ads or even cookies here. It's absolutely free to use and modify. ## Demo @@ -33,10 +33,12 @@ To use the 5mdt Noise Generator, simply open the `index.html` file in a web brow This project is licensed under the [MIT License](LICENSE). -## Authors +## Authors (alphabetically) -- [@nett00n](https://github.com/nett00n) +- [@akamenskiy](https://github.com/akamenskiy) - [@kawaiier](https://github.com/kawaiier) +- [@nett00n](https://github.com/nett00n) + --- -2023, Tbilisi, Sakartvelo +2023 diff --git a/RandomNoiseProcessor.js b/RandomNoiseProcessor.js new file mode 100644 index 0000000..44949cc --- /dev/null +++ b/RandomNoiseProcessor.js @@ -0,0 +1,78 @@ +const tempo = 30; +const types = { + pink: "pink", + brown: "brown", + white: "white", +} + +function generateBrownNoise(buffer) { + let lastOut = 0.0; + + for (let i = 0; i < buffer.length; i++) { + const whiteNoise = (Math.random() * 2 - 1) / tempo; + buffer[i] = (lastOut + (0.02 * whiteNoise)) / 1.02; + lastOut = buffer[i]; + buffer[i] *= 3.5; // Amplify the sound + } +} + +// Function to generate Pink noise +function generatePinkNoise(buffer) { + let b0 = 0; + let b1 = 0; + let b2 = 0; + let b3 = 0; + let b4 = 0; + let b5 = 0; + let b6 = 0; + + for (let i = 0; i < buffer.length; i++) { + const whiteNoise = (Math.random() * 2 - 1) / tempo; + b0 = 0.99886 * b0 + whiteNoise * 0.0555179; + b1 = 0.99332 * b1 + whiteNoise * 0.0750759; + b2 = 0.96900 * b2 + whiteNoise * 0.1538520; + b3 = 0.86650 * b3 + whiteNoise * 0.3104856; + b4 = 0.55000 * b4 + whiteNoise * 0.5329522; + b5 = -0.7616 * b5 - whiteNoise * 0.0168980; + buffer[i] = b0 + b1 + b2 + b3 + b4 + b5 + b6 + whiteNoise * 0.5362; + buffer[i] *= 0.11; // Amplify the sound + b6 = whiteNoise * 0.115926; + } +} + +// Function to generate White noise +function generateWhiteNoise(buffer) { + + for (let i = 0; i < buffer.length; i++) { + buffer[i] = (Math.random() * 2 - 1) / tempo; + } +} + + +class RandomNoiseProcessor extends AudioWorkletProcessor { + constructor (options) { + super(); + this.type = options.processorOptions.type; + }; + process(inputs, outputs) { + const output = outputs[0]; + output.forEach((channel) => { + switch (this.type) { + case types.brown: + generateBrownNoise(channel); + break; + case types.pink: + generatePinkNoise(channel); + break; + case types.white: + generateWhiteNoise(channel); + break; + default: + break; + } + }); + return true; + } +} + +registerProcessor("RandomNoiseProcessor", RandomNoiseProcessor); \ No newline at end of file diff --git a/index.html b/index.html index 2ca30dc..b6931c7 100644 --- a/index.html +++ b/index.html @@ -1,278 +1,190 @@ - +
-