hydra-synth
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -81,2 +81,31 @@ module.exports = { | ||
}, | ||
solid: { | ||
type: 'src', | ||
inputs: [ | ||
{ | ||
name: 'r', | ||
type: 'float', | ||
default: 0.0 | ||
}, | ||
{ | ||
name: 'g', | ||
type: 'float', | ||
default: 0.0 | ||
}, | ||
{ | ||
name: 'b', | ||
type: 'float', | ||
default: 0.0 | ||
}, | ||
{ | ||
name: 'a', | ||
type: 'float', | ||
default: 1.0 | ||
} | ||
], | ||
notes: '', | ||
glsl: `vec4 solid(vec4 c0, float _r, float _g, float _b, float _a){ | ||
return vec4(_r, _g, _b, _a); | ||
}` | ||
}, | ||
rotate: { | ||
@@ -83,0 +112,0 @@ type: 'coord', |
const Hydra = require('./../index.js') | ||
const Analyzer = require('web-audio-analyser') | ||
const getUserMedia = require('getusermedia') | ||
function init () { | ||
function init () { | ||
canvas = document.createElement('canvas') | ||
@@ -17,2 +18,12 @@ canvas.width = 800 | ||
s0.initCam(1) | ||
getUserMedia({audio: true, video: false}, function (err, stream) { | ||
console.log('audio', stream) | ||
if(err) { | ||
console.log(err) | ||
} else { | ||
window.audio = Analyzer(stream, {audible: false}) | ||
console.log(window.audio) | ||
} | ||
}) | ||
// hydra.osc().out(hydra.o[0]) | ||
@@ -19,0 +30,0 @@ // hydra.osc().rotate(0.4).out(hydra.o[1]) |
@@ -189,3 +189,3 @@ /* globals tex */ | ||
Generator.prototype.out = function (_output) { | ||
console.log('UNIFORMS', this.uniforms, output) | ||
// console.log('UNIFORMS', this.uniforms, output) | ||
@@ -192,0 +192,0 @@ // console.log("FRAG", frag) |
20
index.js
@@ -5,2 +5,4 @@ const Output = require('./output.js') | ||
const GeneratorFactory = require('./GeneratorFactory.js') | ||
const Analyzer = require('web-audio-analyser') | ||
const getUserMedia = require('getusermedia') | ||
const mouse = require('mouse-change')() | ||
@@ -18,2 +20,3 @@ | ||
autoLoop = true, | ||
detectAudio = true, | ||
canvas | ||
@@ -31,3 +34,19 @@ } = {}) { | ||
this.time = 0 | ||
self.detectAudio = false | ||
if(detectAudio) { | ||
getUserMedia({audio: true, video: false}, function (err, stream) { | ||
// console.log('audio', stream) | ||
if(err) { | ||
console.log(err) | ||
} else { | ||
self.audio = Analyzer(stream, {audible: false}) | ||
self.fft = self.audio.frequencies() | ||
self.detectAudio = true | ||
window.fft = (freq, mult) => () => (self.fft[freq]*mult) | ||
// console.log(window.audio) | ||
} | ||
}) | ||
} | ||
// create main output canvas and add to screen | ||
@@ -193,2 +212,3 @@ if (canvas) { | ||
self.tick = function (dt, uniforms) { | ||
if(self.detectAudio === true) self.fft = self.audio.frequencies() | ||
// this.regl.frame(function () { | ||
@@ -195,0 +215,0 @@ self.time += dt * 0.001 |
@@ -18,2 +18,3 @@ var adapter = require('webrtc-adapter'); | ||
if (window.navigator.userAgent.match('Chrome')) { | ||
var chromever = parseInt(window.navigator.userAgent.match(/Chrome\/(.*) /)[1], 10); | ||
@@ -35,3 +36,3 @@ var maxver = 33; | ||
console.log("running in electron" , constraints) | ||
constraints.video.mandatory.chromeMediaSourceId = data.sourceId; | ||
// constraints.video.mandatory.chromeMediaSourceId = data.sourceId; | ||
window.navigator.mediaDevices.getUserMedia(constraints).then(function (stream) { | ||
@@ -38,0 +39,0 @@ callback(null, stream); |
{ | ||
"name": "hydra-synth", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "base synth for hydra-editor", | ||
@@ -32,4 +32,5 @@ "main": "index.js", | ||
"raf-loop": "^1.1.3", | ||
"regl": "^1.3.1" | ||
"regl": "^1.3.1", | ||
"web-audio-analyser": "^2.0.1" | ||
} | ||
} |
49150
1744
6
+ Addedweb-audio-analyser@^2.0.1
+ Addedweb-audio-analyser@2.0.1(transitive)