Comparar commits
1 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| 3c748e8152 |
@@ -43,7 +43,6 @@
|
||||
"brainbrowser": "^2.3.0",
|
||||
"chart.js": "^2.1.4",
|
||||
"chroma-js": "^1.1.1",
|
||||
"dsp.js": "neurojs/dsp.js",
|
||||
"es6-shim": "^0.35.0",
|
||||
"express": "^4.13.4",
|
||||
"fili": "^1.2.1",
|
||||
|
||||
@@ -63,7 +63,7 @@ export class ChartService {
|
||||
display: true
|
||||
},
|
||||
ticks: {
|
||||
max: 3,
|
||||
max: 5,
|
||||
min: -2,
|
||||
stepSize: 0.5
|
||||
}
|
||||
@@ -73,7 +73,7 @@ export class ChartService {
|
||||
display: true
|
||||
},
|
||||
ticks: {
|
||||
max: 3,
|
||||
max: 5,
|
||||
min: -2,
|
||||
stepSize: 0.5
|
||||
}
|
||||
@@ -121,7 +121,7 @@ export class ChartService {
|
||||
display: true
|
||||
},
|
||||
ticks: {
|
||||
max: 2,
|
||||
max: 4,
|
||||
min: -2,
|
||||
stepSize: 0.5,
|
||||
showLabelBackdrop: false
|
||||
|
||||
@@ -13,7 +13,8 @@ module.exports = {
|
||||
windowSize: 32 // data has a moving window of 32 samples = 128 milliseconds (250Hz)
|
||||
},
|
||||
fft: {
|
||||
bins: 512
|
||||
bufferSize: 512,
|
||||
windowFunction: 'none'
|
||||
},
|
||||
scale: {
|
||||
global: 1.5,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const dsp = require('dsp.js');
|
||||
const Fili = require('fili');
|
||||
const Utils = require('../utils');
|
||||
const constants = require('../constants');
|
||||
|
||||
@@ -8,8 +8,8 @@ module.exports = class FFT {
|
||||
|
||||
constructor ({ Signal }) {
|
||||
this.signal = Signal;
|
||||
this.bins = constants.fft.bins;
|
||||
this.bufferSize = constants.signal.bufferSize;
|
||||
this.bufferSize = constants.fft.bufferSize;
|
||||
this.bins = this.bufferSize / 4;
|
||||
this.sampleRate = constants.signal.sampleRate;
|
||||
this.bands = constants.bands;
|
||||
this.spectrums = [[],[],[],[],[],[],[],[]];
|
||||
@@ -19,7 +19,8 @@ module.exports = class FFT {
|
||||
}
|
||||
|
||||
subscribe () {
|
||||
this.signal.emitter.on(constants.events.signal, (signals) => {
|
||||
this.signal.emitter.on(constants.events.signal, (signals) => {
|
||||
//signals = this.trim(signals);
|
||||
this.signalsToFFT(signals);
|
||||
this.scaleLabels();
|
||||
this.filterBands();
|
||||
@@ -28,13 +29,20 @@ module.exports = class FFT {
|
||||
});
|
||||
}
|
||||
|
||||
trim (signals) {
|
||||
return signals.map((channel) => {
|
||||
return channel.splice(this.bins, this.bufferSize);
|
||||
});
|
||||
}
|
||||
|
||||
signalsToFFT (signals) {
|
||||
signals.forEach((signal, index) => {
|
||||
signal = Utils.filter.process(signal);
|
||||
let fft = new dsp.FFT(this.bufferSize, this.sampleRate);
|
||||
fft.forward(signal);
|
||||
this.spectrums[index] = Utils.data.parseObjectAsArray(fft.spectrum);
|
||||
//signal = Utils.filter.process(signal);
|
||||
let fft = new Fili.Fft(constants.fft.bufferSize);
|
||||
let spectrum = fft.forward(signal, constants.fft.windowFunction);
|
||||
this.spectrums[index] = fft.magnitude(spectrum);
|
||||
this.spectrums[index] = Utils.signal.voltsToMicrovolts(this.spectrums[index], true);
|
||||
console.log('this.spectrums[index]', this.spectrums[index].length);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,6 @@
|
||||
|
||||
module.exports = {
|
||||
|
||||
parseObjectAsArray (obj) {
|
||||
var array = [];
|
||||
Object.keys(obj).forEach((key) => {
|
||||
array.push(obj[key]);
|
||||
});
|
||||
return array;
|
||||
},
|
||||
|
||||
/**
|
||||
* generateTimeline
|
||||
* @param size
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário