mohayonao / timbre.js

JavaScript library for objective sound programming
http://mohayonao.github.io/timbre.js/
MIT License
963 stars 74 forks source link

NodeJS + raspberry PI #39

Open revolunet opened 9 years ago

revolunet commented 9 years ago

Hi there,

Running this simple code on raspberry PI gives choppy sound output and works fine on OSX. Any idea what i'm doing wrong ?

Playing ogg files on the rpi works correctly though.

thanks !

var T = require("timbre");

var PulseGenerator = function() {
    this.freq = 440;
    this.interval = 1000;
};

PulseGenerator.prototype.play = function() {
    this.tone = T("sin", {
        freq: this.freq
    });
    this.pulse = T('+pulse', {
        freq: this.interval + 'ms'
    });
    var sound = T('*', this.tone, this.pulse).play();
};

PulseGenerator.prototype.setFrequency = function(freq) {
    this.tone.set('freq', freq);
};

PulseGenerator.prototype.setInterval = function(ms) {
    this.pulse.set('freq', ms + 'ms');
};

var p = new PulseGenerator();
p.play();