Package Exports
- ciseaux/lib/tape
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ciseaux) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ciseaux
JavaScript utility to chop an audio buffer, inspired from youpy/scissor
✂️ Installation
bower:
bower install ciseauxnpm:
npm install ciseauxdownloads:
✂️ API
Ciseaux.silence(duration: number): TapeCiseaux.concat(...tapes: Tape): TapeCiseaux.mix(...tapes: Tape, [method='silence']): Tape
Ciseaux.Tape
constructor(audioBuffer: AudioBuffer)
Instance attributes
sampleRate: numberreadonlylength: numberreadonlyduration: numberreadonlynumberOfChannelsreadonlynumberOfTracksreadonly
Instance methods
gain(gain: number = 1): Tapepan(pan: number = 0): Tapereverse(): Tapepitch(rate: number = 1): Tapestretch(rate: number = 1): Tape- not implemented (Pull Request please)
concat(...tapes: Tape): Tapeslice(startTime: number = 0, duration: number = inf): Tapeloop(n: number = 2): Tapefill(duration: number): Tapereplace(startTime: number = 0, duration: number = 0, tape: Tape = null): Tapesplit(n: number = 2): Tape[]mix(...tapes: Tape, [method = 'silence']): Taperender(audioContext: AudioContext): Promise<AudioBuffer>dispose(): void
Ciseaux.Sequence
constructor(pattern: string, durationPerStep: number)
Instance methods
apply(instruments: object): Tape
✂️ Usage
tape = new Ciseaux.Tape(audioBuffer);
tape = Ciseaux.concat([ tape.slice(10, 1), tape.slice(2, 3) ]).loop(4);
tape.render(audioContext).then(function(audioBuffer) {
var bufSrc = audioContext.createBuffer();
bufSrc.buffer = audioBuffer;
bufSrc.start(audioContext.currentTime);
bufSrc.connect();
});✂️ Examples
slice + concat
tape = tape2.slice(0, 1.5).concat(tape3.slice(0, 0.5), tape1.slice(-2));slice + concat + loop
tape = tape3.slice(0, 0.5).concat(Ciseaux.silence(0.5)).loop(4);replace + reverse
tape = tape1.replace(2, 3, function(tape) {
return tape.reverse();
});gain
tape = Ciseaux.concat(tape1.split(128).map(function(tape, i) {
return tape.gain(i / 128);
}));pan
tape = Ciseaux.concat(tape1.split(25).map(function(tape, i) {
return tape.pan(i % 2 ? -0.85 : +0.85);
}));pitch
tape = Ciseaux.concat(tape1.split(128).map(function(tape, i) {
return tape.pitch(i / 128 + 0.5);
}));mix
tape = tape1.mix(tape2.gain(0.5), "fill");stutter
tape = Ciseaux.concat(tape2.split(64).map(function(tape) {
return tape.loop(4).pitch(2);
}));phase
tape = Ciseaux.mix([ 1, 0.95 ].map(function(rate) {
return tape2.pitch(rate).fill(10);
}));lace
tape = Ciseaux.concat(tape1.split(32).map(function(tape, index) {
return index % 2 ? tape2.pitch(2).fill(tape.duration) : tape;
}));concrete
tape = Ciseaux.mix([ -3, 0, 4, 7 ].map(function(midi) {
return tape1.pitch(Math.pow(2, midi * 1/12)).fill(10);
})).gain(0.5);sequence
tape = new Ciseaux.Sequence("a bdacbba babfeg", 0.2)
.apply({
a: tape1.split(16)[0],
b: tape1.split(16)[1],
c: tape1.split(16)[2],
d: tape1.split(16)[3].gain(0.15),
e: tape2.split(16)[4].pitch(0.25),
f: tape2.split(16)[5].pitch(4).gain(0.1),
g: tape3.pitch(32),
}).loop(4);