Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
stephband committed Sep 22, 2023
1 parent 36dfa39 commit 6aabd53
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions nodes/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ function startSources(sources, destination, detuneNode, map, time, frequency = 4

sources.length = 0;

console.log('NOTE ----------');

// Neuter velocity 0s - they dont seem to get filtered below
return gain === 0 ? sources : map
.filter((region) => (
Expand All @@ -239,6 +241,9 @@ function startSources(sources, destination, detuneNode, map, time, frequency = 4

source.region = region;
source.bufferNode = setupBufferNode(context, source, detuneNode, region, buffer, time, frequency);

console.log('START', gain, region.src);

startSource(context, source, source.bufferNode, region.attack, time);

sources.length = i + 1;
Expand Down
19 changes: 17 additions & 2 deletions nodes/test/instrument-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import run from '../../../fn/modules/test.js';
import toGain from '../../../fn/modules/to-gain.js';
import context from '../../modules/context.js';
import Instrument from '../instrument.js';

Expand Down Expand Up @@ -268,8 +269,8 @@ run('Instrument() sample and tone', [false], function(test, done) {
});
*/

//const path = 'http://sound.stephen.band/';
const path = 'http://localhost/sound.stephen.band/';
const path = 'http://sound.stephen.band/';
//const path = 'http://localhost/sound.stephen.band/';

run('Instrument() Chromatic and dynamic test', [false], function(test, done) {
const duration = 0.1;
Expand Down Expand Up @@ -311,6 +312,19 @@ run('Instrument() Chromatic and dynamic test', [false], function(test, done) {

instrument.connect(context.destination);

function playDynamic(note) {
const t = context.currentTime;
let n = 0;
while (++n < 13) {
var gain = toGain(n * 2.5 - 30);
instrument
.start(t + 0.6 * n, note, gain)
.stop( t + 0.6 * n + 0.6) ;
}
}

playDynamic(60);
/*
function playChromatic(min, max, gain) {
const t = context.currentTime;
let n = min - 1;
Expand All @@ -328,4 +342,5 @@ run('Instrument() Chromatic and dynamic test', [false], function(test, done) {
setTimeout(() => playChromatic(25, 108, 0.5), 40000);
setTimeout(() => playChromatic(25, 108, 1), 50000);
setTimeout(() => done, 60000);
*/
});

0 comments on commit 6aabd53

Please sign in to comment.