'Change an audio file frequency into ultra-sonic sound frequency
I'm trying to change my audio file frequency in Javascript and after a lot of struggle I came to one solution, files are given below but I face one limitation here that it can only convert frequency upto "22kHz".
But I want to convert it to "45kHz"???
"Web Audio API" & "Pizzicato.js" is used in this project. You can use any audio file.
JS file:
import "./styles.css";
import PizzicatoRecorder from "pizzicato-recorder";
import Pizzicato from "pizzicato";
import audio from "../viper.mp3";
PizzicatoRecorder(Pizzicato);
document.addEventListener("click", () => {
console.log("start");
Pizzicato.Recorder.start({ mute: false });
var sound = new Pizzicato.Sound(audio, () => {
sound.addEffect(delay);
sound.play();
});
var delay = new Pizzicato.Effects.HighPassFilter({
frequency: 22000,
peak: 10,
});
sound.on("end", function () {
console.log("end");
Pizzicato.Recorder.stop("wav", handleAudio);
});
});
function handleAudio(file, fileType) {
console.log("Stop");
let url = URL.createObjectURL(file);
let hf = document.createElement("a");
hf.href = url;
hf.download = "AtLastSuccess." + fileType;
hf.innerHTML = hf.download;
hf.click();
}
document.getElementById("app").innerHTML = `
<h1>Frequency Modulation & Download!</h1>
<div>
Download from
<a href="https://www.google.com" target="_blank" rel="noopener noreferrer">here</a>.
</div>
`;
html file:
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
</head>
<body>
<div id="app"></div>
<script src="src/index.js">
</script>
</body>
</html>
package.json file:
{
"name": "vanilla",
"version": "1.0.0",
"description": "JavaScript example starter project",
"main": "index.html",
"scripts": {
"start": "parcel index.html --open",
"build": "parcel build index.html"
},
"dependencies": {
"parcel-bundler": "^1.6.1",
"pizzicato": "0.6.4",
"pizzicato-recorder": "1.0.3"
},
"devDependencies": {
"@babel/core": "7.2.0"
},
"resolutions": {
"@babel/preset-env": "7.13.8"
},
"keywords": [
"javascript",
"starter"
]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
