Skip to content

Commit

Permalink
fix .out in SynthStream SynthEventList and AudioBus
Browse files Browse the repository at this point in the history
  • Loading branch information
crucialfelix committed Apr 25, 2016
1 parent 0009107 commit 8e051c0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
7 changes: 4 additions & 3 deletions src/dryads/AudioBus.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import {Dryad} from 'dryadic';

/**
* Allocates an audio bus, making it available in the children's context as .bus (integer)
* Allocates an audio bus, making it available in the children's context as .out (integer)
* and .numChannels (integer)
*/
export default class AudioBus extends Dryad {

Expand All @@ -22,14 +23,14 @@ export default class AudioBus extends Dryad {

prepareForAdd() {
return {
bus: (context) => context.scserver.state.allocAudioBus(this.properties.numChannels),
out: (context) => context.scserver.state.allocAudioBus(this.properties.numChannels),
numChannels: this.properties.numChannels
};
}

remove() {
return {
run: (context) => context.scserver.state.freeAudioBus(context.bus, this.properties.numChannels)
run: (context) => context.scserver.state.freeAudioBus(context.out, this.properties.numChannels)
};
}
}
10 changes: 8 additions & 2 deletions src/dryads/SCServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@ export default class SCServer extends Dryad {
};
}

prepareForAdd() {
initialContext() {
return {
scserver: (context) => boot(_.defaults(this.properties.options, {log: context.log})),
out: 0,
group: 0
};
}

prepareForAdd() {
return {
scserver: (context) => boot(_.defaults(this.properties.options, {log: context.log}))
};
}

remove() {
return {
run: (context) => {
Expand Down
3 changes: 1 addition & 2 deletions src/dryads/SynthEventList.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ export default class SynthEventList extends Dryad {
const defaultParams = this.properties.defaultParams || {};
return events.map((event) => {
const defName = event.defName || defaultParams.defName;
const args = _.assign({}, defaultParams.args, event.args);
args.out = context.out || 0;
const args = _.assign({out: context.out || 0}, defaultParams.args, event.args);
const msg = synthNew(defName, -1, AddActions.TAIL, context.group, args);
// epoch: takes a Date or date.getTime()
// find first defined
Expand Down
4 changes: 1 addition & 3 deletions src/dryads/SynthStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ export default class SynthStream extends Dryad {
// Should validate that event.value is object
let ev = event.value();
let defaultParams = this.properties.defaultParams || {};
// should update 'out' with the bus if there is an out
// arg on the def
const args = _.assign({}, defaultParams.args, ev.args);
const args = _.assign({out: context.out || 0}, defaultParams.args, ev.args);
const defName = ev.defName || this.properties.defaultParams.defName;
const synth = synthNew(defName, -1, AddActions.TAIL, context.group, args);
player.callCommand(context.id, {
Expand Down

0 comments on commit 8e051c0

Please sign in to comment.