Channel

Scribbletune creates channels that can contain multiple clips.

Note: tone.js must be loaded in the browser via SCRIPT tag before Scribbletune (or your compiled app - with Scribbletune) is loaded.

Before you can create a channel, you must create a session.

const scribble = require('scribbletune/browser');
const session = new scribble.Session();

You can either pass an array of channels to that or you can add them individually.

const kickChannel = session.createChannel({
sample: 'https://scribbletune.com/sounds/kick.wav',
clips: [
{ pattern: 'x' },
{ pattern: 'xxx[xx]' },
{ pattern: 'x' },
{ pattern: 'xxx[-x]' }
]
});
 
const bassChannel = session.createChannel({
sample: 'https://scribbletune.com/sounds/kick.wav',
clips: [
{ pattern: '[-x]' },
{ pattern: '[--xx]' },
{ pattern: '[-xxx]' },
{ pattern: 'xxx' }
]
});

Apart from sample you could also provide an array as samples, or provide a synth property to use a Tone.js synth:

const synthChannel = session.createChannel({
synth: 'PolySynth',
clips: [
{ pattern: '[-x]', notes: 'C4 D#4' },
{ pattern: '[--xx]', notes: 'C4 Cm-4' },
{ pattern: '[-xxx]', notes: ['E4', 'D#4'] },
{ pattern: 'xxx', notes: scribble.scale('C minor') }
]
});

Methods

Play or stop a particular clip:

bassChannel.startClip(2);
bassChannel.stopClip(2);

Add a new clip at a specific index:

const params = { pattern: 'xx[xx]' };
bassChannel.addClip(params, 4);

Get the index of the currently active clip:

bassChannel.activeClipIdx;