import _ from 'lodash';
import '../../../globals.js';
import tambo from '../tambo.js';
import SoundClip from './SoundClip.js';
import SoundGenerator from './SoundGenerator.js';
class CompositeSoundClip extends SoundGenerator {
    constructor(soundsAndOptionsTuples, options) {
        super(options);
        this.soundClips = [];
        for (let i = 0; i < soundsAndOptionsTuples.length; i++) {
            const soundAndOptions = soundsAndOptionsTuples[i];
            const soundClip = new SoundClip(soundAndOptions.sound, soundAndOptions.options);
            soundClip.connect(this.soundSourceDestination);
            this.soundClips.push(soundClip);
        }
    }
    play() {
        this.soundClips.forEach(soundClip => soundClip.play());
    }
    stop() {
        this.soundClips.forEach(soundClip => soundClip.stop());
    }
    connect(destination) {
        this.soundClips.forEach(soundClip => soundClip.connect(destination));
    }
    dispose() {
        this.soundClips.forEach(soundClip => soundClip.dispose());
        super.dispose();
    }
    get isPlaying() {
        return _.some(this.soundClips, soundClip => soundClip.isPlaying);
    }
    setOutputLevel(outputLevel, timeConstant) {
        this.soundClips.forEach(soundClip => soundClip.setOutputLevel(outputLevel, timeConstant));
    }
}
tambo.register('CompositeSoundClip', CompositeSoundClip);
export default CompositeSoundClip;
//# sourceMappingURL=CompositeSoundClip.js.map