Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - Dj monitor #216

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions demo-project/DWS - Beep Boop/index.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"controllers": [
{
"port": "Launchpad MK2",
"port": null,
"loopLength": 16,
"chunkPositions": {
"Perc": [
Expand Down Expand Up @@ -29,7 +29,7 @@
0
]
},
"node": "controller/launchpad-mk2"
"node": "controller/qwerty"
},
{
"port": "Launchpad MK2 2",
Expand Down Expand Up @@ -622,7 +622,7 @@
"node": "modulatorChunk"
}
],
"selectedChunkId": "Perc",
"selectedChunkId": "bass",
"volume": 1,
"globalScale": {
"offset": 0,
Expand Down
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,23 @@ var rootContext = window.rootContext = {
nodes: nodes.objectLookup,
nodeInfo: nodes,
zoom: Property(1.1),
version: version
version: version,
alternateOutputs: [],
alternateInputs: []
}

function addAlternates(deviceInfos) {
deviceInfos.forEach(function (device) {
var miniInfo = { label: device.label, deviceId: device.deviceId }
if (device.kind === 'audioinput') rootContext.alternateInputs.push(miniInfo)
if (device.kind === 'audiooutput') rootContext.alternateOutputs.push(miniInfo)
})
}

navigator.mediaDevices.enumerateDevices().then(addAlternates).catch(function (e) {
console.log('unable to get any alternate devices', e)
});

watch(rootContext.zoom, function (value) {
electron.webFrame.setZoomFactor(value || 1)
})
Expand Down
21 changes: 19 additions & 2 deletions nodes/setup/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function Setup (parentContext) {
globalScale: Property({
offset: 0,
notes: [0, 2, 4, 5, 7, 9, 11]
})
}),
selectedOutputId: Property('default')
})

node.overrideVolume = Property(1)
Expand All @@ -61,7 +62,12 @@ function Setup (parentContext) {
context.output.connect(outputLowPass)
outputLowPass.connect(outputHighPass)
node.output = YankSilence(audioContext, outputHighPass)
node.output.connect(parentContext.output)
//node.output.connect(parentContext.output)//
var dest = audioContext.createMediaStreamDestination()
node.output.connect(dest)
node.audioElement = new Audio()
node.audioElement.srcObject = dest.stream
node.audioElement.play()

context.active = node.output.active

Expand All @@ -70,6 +76,17 @@ function Setup (parentContext) {
})

var releases = [
watch(node.selectedOutputId, function (value) {
node.output.disconnect()
node.audioElement = new Audio()
node.audioElement.setSinkId(value).then(() => {
var dest = audioContext.createMediaStreamDestination()
node.output.connect(dest)
node.audioElement.srcObject = dest.stream
node.audioElement.play()
})
}),

watch(computed([node.volume, node.overrideVolume], (a, b) => a * b), function (value) {
node.output.gain.value = value
}),
Expand Down
19 changes: 17 additions & 2 deletions nodes/setup/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var send = require('mutant/send')
var Collection = require('lib/widgets/collection')
var Spawner = require('lib/widgets/spawner')

var Select = require('lib/params/select')
var QueryParam = require('lib/query-param')
var ScaleChooser = require('lib/params/scale-chooser')
var Range = require('lib/params/range')
Expand Down Expand Up @@ -49,15 +50,29 @@ function renderSetup (setup) {

h('div.options', [
renderScaleChooser(setup.globalScale),
renderMasterVolume(setup.volume)
renderMasterVolume(setup.volume),
renderOutputSelector(setup),
])

])
}

function renderOutputSelector(setup) {
var outputOptions = setup.context.alternateOutputs.map(function (info) {
return [info.label, info.deviceId]
})
var params = [
Select(QueryParam(setup, 'selectedOutputId'), {
options: outputOptions,
flex: true,
missingPrefix: ' (unknown)'
})
]
return h('ParamList', params)
}

function renderMasterVolume (volume) {
return h('section.volume', [

h('h1', 'Master Volume'),
h('div.param', [
Range(volume, {
Expand Down