New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hydra-synth

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hydra-synth - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

7

index.js

@@ -60,7 +60,9 @@ const Output = require('./src/output.js')

if(detectAudio) this._initAudio()
if(makeGlobal) {
//if(makeGlobal) {
window.mouse = mouse
window.time = this.time
window['render'] = this.render.bind(this)
// window.bpm = this.bpm
window.bpm = this._setBpm.bind(this)
}
// }
if(autoLoop) loop(this.tick.bind(this)).start()

@@ -264,2 +266,3 @@ }

// })
window.time = this.time
this.audio.tick()

@@ -266,0 +269,0 @@ for (let i = 0; i < this.s.length; i++) {

{
"name": "hydra-synth",
"version": "1.0.11",
"version": "1.0.12",
"description": "base synth for hydra-editor",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -20,2 +20,15 @@ const Meyda = require('meyda')

// beat detection from: https://github.com/therewasaguy/p5-music-viz/blob/gh-pages/demos/01d_beat_detect_amplitude/sketch.js
this.beat = {
holdFrames: 20,
threshold: 40,
_cutoff: 0, // adaptive based on sound state
decay: 0.98,
_framesSinceBeat: 0 // keeps track of frames
}
this.onBeat = () => {
console.log("beat")
}
this.canvas = document.createElement('canvas')

@@ -33,3 +46,3 @@ this.canvas.width = 100

this.ctx = this.canvas.getContext('2d')
this.ctx.fillStyle="#FFF"
this.ctx.fillStyle="#DFFFFF"
this.ctx.strokeStyle="#0ff"

@@ -47,3 +60,3 @@ this.ctx.lineWidth=0.5

this.context = new AudioContext()
this.context = new AudioContext()
// this.context = new AudioContext()
let audio_stream = this.context.createMediaStreamSource(stream)

@@ -66,2 +79,18 @@

detectBeat (level) {
//console.log(level, this.beat._cutoff)
if (level > this.beat._cutoff && level > this.beat.threshold) {
this.onBeat()
this.beat._cutoff = level *1.2
this.beat._framesSinceBeat = 0
} else {
if (this.beat._framesSinceBeat <= this.beat.holdFrames){
this.beat._framesSinceBeat ++;
} else {
this.beat._cutoff *= this.beat.decay
this.beat._cutoff = Math.max( this.beat._cutoff, this.beat.threshold);
}
}
}
tick() {

@@ -72,3 +101,3 @@ if(this.meyda){

this.vol = features.loudness.total
this.detectBeat(this.vol)
// reduce loudness array to number of bins

@@ -83,7 +112,15 @@ const reducer = (accumulator, currentValue) => accumulator + currentValue;

return (bin * (1.0 - this.smooth) + this.prevBins[index] * this.smooth)
// return (bin * (1.0 - this.smooth) + this.prevBins[index] * this.smooth)
return (bin * (1.0 - this.settings[index].smooth) + this.prevBins[index] * this.settings[index].smooth)
})
this.fft = this.bins.map((bin) => (
Math.max(0, (bin - this.cutoff) / (this.max - this.cutoff))
// var y = this.canvas.height - scale*this.settings[index].cutoff
// this.ctx.beginPath()
// this.ctx.moveTo(index*spacing, y)
// this.ctx.lineTo((index+1)*spacing, y)
// this.ctx.stroke()
//
// var yMax = this.canvas.height - scale*(this.settings[index].scale + this.settings[index].cutoff)
this.fft = this.bins.map((bin, index) => (
// Math.max(0, (bin - this.cutoff) / (this.max - this.cutoff))
Math.max(0, (bin - this.settings[index].cutoff)/this.settings[index].scale)
))

@@ -97,2 +134,6 @@ if(this.isDrawing) this.draw()

this.cutoff = cutoff
this.settings = this.settings.map((el) => {
el.cutoff = cutoff
return el
})
}

@@ -102,3 +143,8 @@

this.smooth = smooth
this.settings = this.settings.map((el) => {
el.smooth = smooth
return el
})
}
setBins (numBins) {

@@ -108,5 +154,6 @@ this.bins = Array(numBins).fill(0)

this.fft = Array(numBins).fill(0)
this.range = Array(numBins).fill(0).map(() => ({
this.settings = Array(numBins).fill(0).map(() => ({
cutoff: this.cutoff,
scale: this.scale
scale: this.scale,
smooth: this.smooth
}))

@@ -117,7 +164,16 @@ // to do: what to do in non-global mode?

})
console.log(this.range)
console.log(this.settings)
}
setScale(scale){
this.scale = scale
this.settings = this.settings.map((el) => {
el.scale = scale
return el
})
}
setMax(max) {
this.max = max
console.log('set max is deprecated')
}

@@ -146,4 +202,4 @@ hide() {

// console.log(this.range[index])
var y = this.canvas.height - scale*this.range[index].cutoff
// console.log(this.settings[index])
var y = this.canvas.height - scale*this.settings[index].cutoff
this.ctx.beginPath()

@@ -154,3 +210,3 @@ this.ctx.moveTo(index*spacing, y)

var yMax = this.canvas.height - scale*(this.range[index].scale + this.range[index].cutoff)
var yMax = this.canvas.height - scale*(this.settings[index].scale + this.settings[index].cutoff)
this.ctx.beginPath()

@@ -157,0 +213,0 @@ this.ctx.moveTo(index*spacing, yMax)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc