var signal = [];
var sam = 1000;
var fre = 14;
var buf = 1024;
function Parabel(value , index) {
return value * (index *index - buf * index );
}
function Hanning( value , index ){
var cos = Math.cos((2 * Math.PI * index) / (buf));
return 0.5 * value *(1 - cos);
}
function Id (value){
return value;
}
function Gaussian(value , index){
var exp = 1 / Math.sqrt( Math.PI) * Math.exp(0);
return value * exp;
}
function Oszi(){
signal = []
for (i = 0 ; i<buf; i++){
signal.push(3*Math.cos(Math.PI * 2 * i / sam * fre*2.7) +Math.sin(Math.PI * 2 * i / sam * fre));
}
var signal2 = _.map(signal , Gaussian ) ;
plot(signal2);
}
function _FFT(signal,bufferSize, samplingRate) {
var fft = new FFT(bufferSize, samplingRate);
fft.forward(signal);
var spectrum = fft.spectrum;
plotFFT(spectrum,samplingRate);
}
function plotFFT(spectrum,samplingRate) {
var data = [];
var frequencyIncrement = parseFloat(samplingRate)/2/spectrum.length;
for (var j = 0; j < spectrum.length; j++){
data.push([frequencyIncrement*j,spectrum[j]]);
}
new Dygraph(document.getElementById("graph"),data);
console.log(data);
}
function plot(plotData) {
var row = [];
for (var j = 0; j < plotData.length; j++){
row.push([j,plotData[j]]);
}
console.log(row);
new Dygraph(document.getElementById("graph"),row);
}
Oszi()
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.