Giter Site home page Giter Site logo

mohayonao / timbre.js Goto Github PK

View Code? Open in Web Editor NEW
965.0 59.0 77.0 5.05 MB

JavaScript library for objective sound programming

Home Page: http://mohayonao.github.io/timbre.js/

License: MIT License

JavaScript 97.68% HTML 0.11% CoffeeScript 1.37% CSS 0.69% ActionScript 0.14%

timbre.js's Introduction

This repository is no longer maintained.

timbre.js

JavaScript library for objective sound programming

Timbre.js provides a functional processing and synthesizing audio in your web apps with modern JavaScript's way like jQuery or node.js. It has many T-Object (Timbre-Object) that connected together to define the graph-based routing for overall audio rendering. It is a goal of this project to approach the next generation audio processing for web.

Project Page

English | 日本語

Examples

BeatBox | Chords Work | Gymnopedie | Khoomii | Reich

Supports

Timbre.js runs on modern browsers for Windows/Mac/Linux/iOS/Android or node.js.

Chrome 14.0- Safari 6.0- Firefox 4.0- Opera node.js 0.8-

Installation

browser

Include the timbre.js file. It will install itself as timbre, T under the global namespace.

<script src="timbre.js"></script>
<script>
  T("sin", {freq:880, mul:0.5}).play();
</script>

Flash fallback (for Opera and IE10)

Download an additional file (Right-click and use "Save As")

timbre.swf must be set in the same folder as timbre.js.

node.js

Install via npm: npm install timbre, you can require it as a standard node module.

var T = require("timbre");

T("sin", {freq:880, mul:0.5}).play();

License

MIT

ChangeLog

14.11.25 (356.27KB)

  • Merge: #33 update of the note duration formula to handle more 3 dots
  • Merge: #36 use latest Web Audio API interfaces

14.10.12 (356.28KB)

  • Fixed: Decoding wav file
  • Fixed: Envelope release

14.08.07 (356.19KB)

  • Fixed: Export for CommonJS env #19

14.06.23 (356.14KB)

  • Fixed: #23 fix to work on an iOS device
  • Fixed: fix to work on node.js

14.05.28 (355.91KB)

14.05.15 (355.95KB)

  • Fixed: #15
  • Excluded support of Audio Data API. use Web Audio API instead.

13.08.03 (361.93KB)

13.05.03 (361.93KB)

  • Bugfix: wav decoder. See #3

13.05.01 (361.75KB)

  • Added: T("task")
  • Added: TimbreObject.to()
  • Added: TimbreObject.splice()
  • Added: TimbreObject.postMessage()
  • Updated: T("mml") support multi tracks, command token
  • Updated: TimbreObject support buddies interface
  • Bugfix: T("mouse.x"), T("mouse.y")

13.04.19 (346.63KB)

  • Bugfix: end process of T("params")

13.04.17 (344.94KB)

  • Updated: readable stream api (node.js)

13.04.06 (344.94KB)

  • Fixed: T("pluck) buffer size

13.04.01 (344.95KB)

  • Bugfix: T("buffer").slice()
  • Bugfix: fn.pointer() for Opera
  • Fixed: Flash fallback

13.03.10 (345.41KB)

  • Fixed: Checking Float64Array support. See #2
  • Changed: lame support (default -> optional)
  • updated dependencies in package.json

13.03.01 (355.72KB)

  • Added: T("script")
  • Added: T("waveshaper")
  • Added: T("lag")
  • Added: T("mono")
  • Added: T("delay").cross
  • Added: T("audio.jsonp") to extras
  • Moved: T("keyboard") to extras
  • Moved: T("mouse") to extras
  • Moved: T("cosc) to extras
  • Renamed: T("mml"): mml event listener -> data event listener
  • Fixed: Flash fallback support for Opera, IE9 (changing the installation)
  • make it easier to make a stereo object

13.02.07 (334.61KB)

  • Added T.setup({f64:true}) to use Float64Array instead of Float32Array
  • Added Android/Firefox support
  • Added Flash fallback support for Opera, IE9
  • performance improvements

13.02.06 (337.50KB)

  • workadound for iOS6.1 bug (failure to start processing in a callback of XMLHttpRequest)

13.02.02 (335.97KB)

  • Fixed: decoder for webkit

13.02.01 (335.96KB)

  • Added: T("reverb")
  • Added: T("chorus")
  • Added: T("eq")
  • Added: T("mediastream")
  • Added: T("-"), T("/"), T("min"), T("max")
  • Added: T("WebAudioAPI:recv"), T("WebAudioAPI:send") at extras
  • Added: T("MoogFF") at extras
  • Renamed: T("phaseshift") to T("phaser")
  • Renamed: event names scope, fft to data (T("scope"), T("spectrum"))
  • Fixed: T("osc").phase, T("osc").fb
  • Fixed: T("biquad").plot()
  • Fixed: T("mml").isEnded

13.01.20a (294.82KB)

  • Renamed: T("comp").postGain to T("comp").gain

13.01.20 (294.83KB)

  • Added: T("adshr"), T("ahdsfr")
  • Added: T("comp")
  • Added: T("phaseshift")

13.01.18a (268.71KB)

timbre.js's People

Contributors

acli avatar ianks avatar johann8384 avatar matteodem avatar mohayonao avatar revilofr avatar skratchdot avatar tario avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

timbre.js's Issues

Question: Help with audio example

I can work the rest of timbre alright, but I can't use even the simplest audio example. Any idea whats going wrong?

<script>
function playT(){
var src = window.getDraggedFile() || "amen.wav";
T("audio").loadthis(src, function() {
  this.plot({target:canvas}).play();
}).on("ended", function() {
  this.pause();
});}

function oscD(){
    var freq  = T("param", {value:100}).to(200, "BPM140 L2", -4);
T("pulse", {freq:freq, mul:0.3}).play();
}
</script>   
        <!-- start gui -->
    <button style="background-color:#05a36c;"class="button" onclick="playT();"></button>
    <button style="background-color:#06bb7c;"class="button" onclick="oscD();"></button>

Broken on iOS devices

timbre.js looks broken on iOS devices.

It doesn't play any sound.

It looks broken since 199775c .

I used code below and checked with git bisect start master 4df0821.
c858ad1 plays sin wave, but 199775c doesn't play in iOS simulator.

<html>
  <body>
    <h1>Click me</h1>
    <script src="timbre.dev.js"></script>
    <script>document.querySelector('h1').onclick=function() { console.log('click'); T("sin").play(); }</script>

timeout doesn't work

timeout looks broken since 199775c .
c858ad1 displays ended, but 199775c doesn't display ended.

<html>
  <body>
    <h1>Click me</h1>
    <script src="timbre.dev.js"></script>
    <script>
      document.querySelector("h1").onclick=function() {
        document.write("<h1>Just wait...</h1>");
        T("timeout", {timeout:500}).on("ended", function() { document.write("<h1>ended</h1>"); }).start();
      };
    </script>

error with npm install

when i use npm install timbre
it appear following error message

CC(target) Release/obj.target/output/deps/mpg123/src/output/alsa.o
../deps/mpg123/src/output/alsa.c:19:28: fatal error: alsa/asoundlib.h: No such file or directory
 #include <alsa/asoundlib.h>
                            ^
compilation terminated.

(i have tried to install other lib, and it run successfully.)
is there anything i miss?

The Mozilla Audio Data API is deprecated. Please use the Web Audio API instead.

The following code causes the title message to be raised in Firefox and loads the flashobject in IE11. This happens with the dev and master branches. No other api call are made prior to this code, only the inclusion of the script.

var pluckString = T("pluck", { freq: this.data('NOTE').FREQUENCY , mul: 0.3 }).bang().play();
T("timeout", { timeout: 750 }).on("ended",
function () {
this.stop();
}
).set({ buddies: pluckString }).start();

Timbre Environment Priority

Hi,

I've been using Timbre for a couple months now in an effort to develop an entirely javascript beetmachine / sequencer modeled after the Native Instruments: Maschine line. The app is here — it's mostly built out to support sequencing, multi-pattern and multi-group samples (effects like reverb, chorus, eq used to work through the UI, but I recently broke :[ ) and eventually I'd like to build a sampling feature to be able to cut the uploaded (drag and drop onto a pad) samples into pieces and save separately.

I've been loving timbre so far. It's phenomenal how much effort and consideration appears to have gone into it.

I had one recent issue, though. Which is extremely simple. I had been using timbre in a require.js environment, loading modules through the browser with require, but recently switched to browserify, which bundles all code into one nice minified file while using a node-like require() syntax to "load" module dependencies into a module's scope. (CommonJS pattern).

When using browserify, it defines module, exports and require so that they're used within the bundled application javascript. This tricks Timbre into believing it's in the Node environment and as such, T.envtype will equal "node".

I'm just monkey-patching it in my local file by reversing the ternary conditions to check for window before checking for module.exports.

Checking for window should be a surefire way to determine if we're in a browser environment, right?

ex:

var _envtype = (typeof window !== "undefined") ? "browser" :
        (typeof module !== "undefined" && module.exports) ? "node" : "unknown";

Doing so, however, causes a second issue here

Because browserify is expecting timbre to export itself through module.exports, but in the browser env it is only attaching to the window. I think a safer bet would be to attach to module exports if its defined at all. That way you cover all bases. Basically if module && module.exports, attach to it—regardless of attaching to the window global.

Does that make sense?

[MML] ended event is raised too early

Hi,

Thanks for your work. I'm doing a mml gui of my own and I discovered your library. Great job !

I just noticed that the event 'ended' was raise even if the song is not finished.
So the song continue to play but the event is raised...

Maybe that's not a bug, but I had to ask.

Here is a part of my code to enlight you:

function _play(mmlPartition) {
playBtn.html('Pause');
var player = T("mml", {mml: mmlPartition}, gen);

    //Subscribtions to every events
    gen.on('ended', function () {
        playBtn.html('Play');
        _displayStatus('ended');
        //$('#play_button').html('Play');
        gen.stop();
        gen.reset(T);

        T.stop();
    });

    gen.on('pause', function () {
        _displayStatus('pause');
        playBtn.html('Resume');
    });
    ......
    player.start();
    gen.play(mmlPartition);
}

should renew development tools

It is difficult to update this project. A cool project has some useful tasks for development. But this project doesn't have them. So, I should renew development tools.

Replaying audio

I'm sure I'm missing something super obvious, but what do I need to do to keep replaying a sound? This only plays once.

var T = require("timbre");
var audio_src = T("audio", {}).loadthis("cicada_2.wav");
setInterval(function(){
    console.log("trigger");
    audio_src.play();
}, 2000);

Really what I need is some kind of sampler where I can load and trigger a bunch of clips as needed. Maybe I'm missing that, too?

Thanks!

Stream

Is there any way for get the stream (pipe function) for input and for output?

Thanks.

noisy interaction in three.js based app

hi, i'm developing a 3d app that involves live sound synthesis, and we would like to use timbre.js for the awesome range of programming affordances it offers. But we've found that simple sound synthesis with timbre.js is interrupted by noise when we do any manipulation of our 3d model.

We've tried a range of other (less capable) libraries wrapping the Web Audio API, and have not had this same problem with them, but we'd much prefer to use timbre.js if we can solve this noise problem!

Our animation rendering is run by recursive calls to requestAnimationFrame(); running the app in Chrome 37.0.2062.0 dev. The 3d code is using three.js, with WebGL rendering.

my simple synthesis test, triggered by a mouse click is:

    var sine1 = T("sin", {freq:vcs(x), mul:0.2});
    var sine2 = T("sin", {freq:vcs(y), mul:0.2});
    var sine3 = T("sin", {freq:vcs(z), mul:0.2});
    T("perc", {r:900}, sine1, sine2, sine3).on("ended", function() {
     this.pause();
    }).bang().play();

support on firefox?

Is there a plugin or extension to permit firefox to use timbre.js - right now the examples play silently with no informative error messages in the web console.

How to add pitch AND amp env to an OSC?

# define the pitch env
pitch_env = T("env", {table:[ 320, [160, 20], [80, 40], [80, 100] ]});

# define the osc
VCO = T("sin", {freq: pitch_env, mul:1})

# define an amp env AND add the osc to it. (different than adding a pitchenv?)
amp_env = T("env", {table:[0,[1, 1], [0.9, 90], [0, 100] ]}, VCO)

# stop synth on end amp env
amp_env.on("ended", function(){ 
    VCO.pause()
})

# start the amp env (why not start the synth?)
amp_env.bang().play()

in this case it ignores the pitch envelope and only uses the amp envelope. how can i trigger the pitch and the amp envelope? thx

Soundfont capabilities?

I'm having trouble figuring out what's possible with soundfonts. Can I shape the duration of the note, its envelope, etc.?

Brown Noise

Any idea as to how I would implement brown noise? I see you've got pink and white - I'd love to add brown and then pass it through various filters.

Change volume of note continuously

I have a synthDef, on which is called noteOn and noteOff. I am also hackishly changing the volume of the gen, by calling .set({mul: value}).

I notice that this causes a disruption, which is very obvious when changed at a fast rate. E.g., if I update the mul every 16ms, then it is more clicks and white noise than a continuous function.

Is there a more correct way of doing this?

Thanks!

Edit, here's a good way to test, where list[0] is a synthGen:

   i = 0; setInterval(function(){ 
  i++; list[0].set({mul: 1000000 * 0.5 * (Math.sin(i / Math.PI / 2) )  })
 }, 16)

how do I turn off the sample?

I tried this T("sin", {freq:880, mul:0.0}).play(); but it kept on playing so I had to exit the browser. How do I stop the sound and how can I control how long the sound plays?

Titanium Studio integration

Has anyone attempted to use this with Titanium Studio. I have tried but keep getting a Float32 declaration error using the simple example. Any suggestions would be appreciated.

Unable to check demo on frontend

When trying to press "Play" button in http://mohayonao.github.io/timbre/ or type examples in developer console, receiving an error:

Uncaught TypeError: this.ctx.createJavaScriptNode is not a function

Stack trace:

on  @   timbre.min.js:6
c.on    @   timbre.min.js:3
b.on    @   timbre.min.js:3
a   @   timbre.min.js:3
b.fn.h.dac.on   @   timbre.min.js:3
b.fn.a.TimbreBasePrototype.h.play   @   timbre.min.js:3
window.play @   index.js:16
(anonymous function)    @   VM535:1

Ipad Audio

I am having trouble getting any audio using timbre on my ipad despite it working fine on android & desktop.

Are there any specific settings for the ipad?

npm module requires 'lame' module, but it's not listed as a depndency

When you try to require('timbre') it throws the following error.

Warning: Cannot find module 'lame' from '/Users/jorgesilva/Sites/2014/clickOnJorge/node_modules/timbre' Use --force to continue.

This seems to be because this package is not listed as a dependency in the package.json.

Should be as simple as:

npm install lame --save

ended event not working using array of frequencies.

Hi!

The event "ended" is not working when using frequencies array.

var freqs = T(function(count) {
  return [440,800,900,1000][count % 4];
});    

var osc = T("square", {freq:freqs});

When I append the on.("ended") to an interval method or osc itself, the callback seems to be never reached. Any thoughts about this issue? I appreciate any reply.

Documentation of available parametters T()

Hi, I have to say that i like the library and it's really useful.

Can I ask if there is any documentation.

I would appriciate just a simple list of all possible options. In example I see here a demo:

T("perc", {r:500}, sine1, sine2).on("ended", function() {

But I don't know what means 'perc' as same I don't know what else can be called instead of 'sin', 'saw', 'perc', 'pulse'.

I'm not skilled in synths and electronic sound processing in general and I understand that you have just implemented something that already exists. Maybe that is my trouble.

Best regards
Tom

I discover

I discorver this project last night, and I have a question

  1. How do the T object terminates its flow?
  2. How to make noise disappear?

Here is my source code:

var tempo = 120;
function metroBeatsSeconds(seconds) {
    tempo = seconds;
    timbre.bpm = seconds;
}

/**
 * Created by manuel on 13-03-16.
 */
function freqSon(ecartTon)
{
    var BaseLa4 = 440;
var factTon = Math.pow(2,1/6);
return BaseLa4 * Math.pow(factTon, ecartTon);



}
function note(param, length)
{
    var fre = freqSon(noteTrans(param, length));
    console.log("Note" + param, " \nDurée (en temps de mesure): " + (length * 1000 / partFractDenominateur()) + "ms (" + (length / timbre.bpm / 60 * 1000) + "ms\n");
    T("sin", {freq: fre, mul: 100, timeout: "" + (length * 1000 / timbre.bpm) + "ms"}).play();

}

/***
 * ex; do4 , 1
 * ex: so4 , 1
 */
function noteTrans(note, length) {
    switch(note.substring(0, 2))
 {
    case "do":
        param = 0;
        break;
    case "re":
        param = 1;
        break;
    case "mi":
        param = 2;
        break;
    case "fa":
        param = 2.5;
        break;
    case "so":
        param = 3.5;
        break;
    case "la":
        param = 4.5;
        break;
    case "si":
        param = 5.5;
        break;
    }
    octave = note.substring(2,3);

var ecart = param+6*octave - 4.5 + 6 * 4; //ParRapprtLa440 en tons + -> aigu - -> grave

return ecart;
}

function silence(length)
{
}



//And the "score" file: 

function part1() {
    metroBeatsSeconds(120);
    note("do4", 1);
    note("re4", 1);
    note("mi4", 1);
    note("fa4", 1);
    note("sol4", 1);
    note("la4", 1);
    note("si4", 1);
    note("do5", 1);
}
function partFractDenominateur() {
    return 4;
}
function partFractNumerateur() {
    return 2;
}
function part1_stop() {
    T.stop();
}

I really want to get involved in this project. I have a question 💯 Do you have Javascript code generator?

https://gitlab.com/mdahmen/Laterreestron.de.git

NodeJS + raspberry PI

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();

How to get Timbre.js version?

I'm writing a wrapper to connect Timbre.js synth to my own library.
Is there a way to obtain Timbre.js version from the script?

Thanks!

audio latency on android chrome

I tried creating a html5 musical keyboard using timbre.js and noticed significant latency between touch and audio only on android chrome. There is no perceptible latency on iOS (iphone, ipad) and windows touchscreen devices.

I've filed a bug against chrome. ( https://code.google.com/p/chromium/issues/detail?id=312502 )

The latency seems to be in audio and not in touch response.

Since I'm using timbre.js, I thought of reporting the issue here too.

I tried to time the code execution using chrome console, using the following few lines of code.

Notice that s.play() consumes 10ms on android wheres on macosx it is less than 2ms.

c = function(){console.log(window.performance.now())};
s=T('sin');
c(); s.play(); c()

chrome 30.0.1599.105 on android 4.4
174774.38400000392
174784.88199999993

chrome 31.0.1650.57 on macosx 10.9
28419.46000000098
28421.132999999827

Need complete stand alone examples

The mohayonao timbre.js contains very promising examples, but they do not show the complete code that can be copy/pasted in to a text file and tried out by itself. Need have such code and more user friendly documentation.

OscGen wave setting

I was having trouble setting the osc on an OscGen object doing something like this: T('OscGen', {osc: T('osc', {wave: 'saw'})} but the wave still sounded like a sin. I then noticed that there is an undocumented wave setting that can be set to a string. So in order to achieve what I was looking for I would need to do: T('OscGen', {wave: 'saw'})

Shouldn't the OscGen wave reflect the wave of the osc?

'T("undefined") is not defined' console error message

While trying to set the freq of a simple synth within a NoUiSlider function, timbre is printing a 'T("undefined") is not defined' error printed to the console.

When setting the freq explicitly as the below commented out line, there is no issue.

             var value = 0;
                    $(function(){
                        $('.slider').noUiSlider({
                            start: 40,
                            range: {
                                'min': 0,
                                'max': 500
                            }
                        });
                    });
                    $('.slider').on({
                        slide: function(){
                            value = $('#slider').val(); 
                                synth1.set({freq:value});
                                        // synth1.set({freq:500});
                        }
                    });

This may or may not be an issue with timbre.js. Please accept my apologies if not.
Thank you for a wonderful library thus far.

http://refreshless.com/nouislider/

T('audio') and WAV

Hello !
Is there a special software|encoding you're using to encode the demo .wav ?
I tried all the encoding combinations in Audacity, but Timbre stays silent when reading any .wav I make, though it works when I use yours.

Dynamically adjusting ADSR and other parameters

Is there a way to dynamically adjust ADSR or other synth parameters to add expression to notes as they play? I've trawled the documentation and Google and can only find someone who had the same problem as me; being unable to find the answer.

As a simple example, I'll have a synth setup like so with noteOn used to trigger a note:

var env  = T("adsr", {a:50,d:300,s:0,r:200});
var synth = T("OscGen", {fwave:"sin", mul:0.5, env:self.env}).play();

Now, I'd expect the following to work:

synth.set({a:300});

or

synth.set({attackTime:300)}

But it has no effect.

Am I missing something, or is it impossible to adjust the envelope without replacing the entire OscGen object?

Frequency modification in realtime dephases oscillators.

Hello,
First of all, thanks for all the hard work. I really like timbre.js.
The issue:

  1. Create 2 oscillators (wave:sin, freq:440, mul:0.1, phase:0).
  2. Play them.
  3. Modify the phase of an oscillator to Math.PI.
    Result: The waves cancel out.
  4. Modify the frequency of oscillator 1 to 600.
  5. Modify the frequency of oscillator 2 to 600.
    Result: The waves DO NOT cancel out.

Am I missing something?, some physics class maybe?, I think they should cancel out, but they don't.

Thanks,

Cheers.

mp3 decode and webkit

I tested to mp3 decode on this page on Chrome 32 linux and Safari 7 on iOS but it doesn’t play the sound. Is it a known issue? Is there a workaround? I am trying to avoid .wav files. Thanks for your amazing work.

clarify listener registration

Figuring out how to properly register and unregister listeners that use the .listen method is unclear to me. If I create a spectrum object for instance:

var saw = T("pink", {mul:0.15}).play();

var fft = T("spectrum", {size:512, interval:100}).on("data", function() {
  fft.plot({target:canvas});
}).listen(saw);

Is this removable through calling fft.removeAllListeners(), or saw.removeAllListeners(), or is this completely separate? If so, could somebody add documentation for the listen and unlisten methods (or point me to it if I have missed it).

Some objects are not defined

Hi,

I installed timbre.js through bower and I was trying to reproduce some examples from the website.

I run through some warnings like :

T("ndict.key") is not defined
T("keyboard") is not defined

Using the file available for download on the website of the project doesn't fix the issue. Am I missing something ?

Missing timbre.js file

You mention in the install to use the timbre.js file. This file doesn't exist. This also affects package managers like http://bower.io from being able to infer the package name.

Question: how to save a .WAV file?

Hi,

maybe it is implemented and/or in the documentation - but is there a way to save a (finite) T Object as a wave (or any other format) file to my hard disk?

Thanks,
Dirk

PS: awesome project!

noteOff() does not work

Tried it with T("PluckGen"), T("OscGen"), T("SynthDef") on several browsers Windows and Mac.
Here is a sample file:

<title>Timbre</title> <script src="timbre.js"></script> <script></script>

Timbre

PluckGen
OscGen
SynthDef

Loading wav's from a file not working on Chrome(59.0.3071.86) and Opera(45.0.2552.888).

Posting this to help out anyone else, who stumbles upon this problem. I don't really know how to properly implement this, but here's a diff of a solution that helped me.

Breakage seems to have been caused by a changing in the web audio API.

--- a/timbre.dev.js
+++ b/timbre.dev.js
@@ -3527,34 +3527,39 @@
 
                 var buffer;
                 try {
-                    buffer = ctx.createBuffer(data.buffer, false);
+                    buffer = ctx.decodeAudioData(data.buffer).then(success, failure);
                 } catch (e) {
                     return onloadedmetadata(false);
                 }
 
-                samplerate = ctx.sampleRate;
-                channels   = buffer.numberOfChannels;
-                if (channels === 2) {
-                    bufferL = buffer.getChannelData(0);
-                    bufferR = buffer.getChannelData(1);
-                } else {
-                    bufferL = bufferR = buffer.getChannelData(0);
-                }
-                duration = bufferL.length / samplerate;
+                function success(buffer){
+                    samplerate = ctx.sampleRate;
+                    channels   = buffer.numberOfChannels;
+                    if (channels === 2) {
+                        bufferL = buffer.getChannelData(0);
+                        bufferR = buffer.getChannelData(1);
+                    } else {
+                        bufferL = bufferR = buffer.getChannelData(0);
+                    }
+                    duration = bufferL.length / samplerate;
 
-                var mixdown = new Float32Array(bufferL);
-                for (var i = 0, imax = mixdown.length; i < imax; ++i) {
-                    mixdown[i] = (mixdown[i] + bufferR[i]) * 0.5;
-                }
+                    var mixdown = new Float32Array(bufferL);
+                    for (var i = 0, imax = mixdown.length; i < imax; ++i) {
+                        mixdown[i] = (mixdown[i] + bufferR[i]) * 0.5;
+                    }
 
-                onloadedmetadata({
-                    samplerate: samplerate,
-                    channels  : channels,
-                    buffer    : [mixdown, bufferL, bufferR],
-                    duration  : duration
-                });
+                    onloadedmetadata({
+                        samplerate: samplerate,
+                        channels  : channels,
+                        buffer    : [mixdown, bufferL, bufferR],
+                        duration  : duration
+                    });
 
-                onloadeddata();
+                    onloadeddata();
+                }
+                function failure(){
+                    onloadedmetadata(false);
+                }
             };
 
             return function(src, onloadedmetadata, onloadeddata) {

Generating samples

Awesome project!

Is it possible to generate a sample and have access to the raw audio data?

For example, if I have this non-looping sample:

var sin = T('sin', {freq:440, mul:0.5});
var perc = T('perc', {r: 1000}, sin).bang();

How would I get the resulting audio buffer data?

Adjusting output

Hello,
I'm working on a drum machine using wav files. I would like to know if it's possible to change the output level of a T('audio') object without redefining the audio file.
For example i have this :
var audio1 = T("audio").load("audio/kick.wav");
and i would like to do something like :

audio1.mul = 0.3

instead of writing this :

audio1 = T("audio", {mul : 0.3}).load("audio/kick.wav");

This is because the audio file can change and it would save me some code!
Thanks a lot!

[MML] Wrong octave on certain notes

Hi
Here is the reference song (French song : "Sur le pont d'Avignon" BTW)

c4c4c4rd4d4d4re4r8f8g8r8c8r8c8r8d8r8<g4

c4c4c4rd4d4d4re4r8f8g8r8c8r8d8r8r8c2

if we play this with timbre.js we can notice than both "<b8" are played on the upper octave wherease it should be played on the lower one.

Am I doing something wrong?

I'am digging into it and I'll try to fix this (maybe a pull request) but that part of the code is really hard to get into ;).
A little help from you would be really appreciated

Regards,
Olivier.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.