Coder Social home page Coder Social logo

Comments (5)

oampo avatar oampo commented on July 21, 2024

That sounds odd to me - you're definitely doing this the right way. Can you post up your code somewhere so I can have a look at what's going on?
Thanks,
Joe

from audiolet.

ewdicus avatar ewdicus commented on July 21, 2024

Thanks for the quick response. Here's the code, I've just modified an example:

function playExample() {
    var AudioletApp = function() {
        this.audiolet = new Audiolet();
        this.sine = new Sine(this.audiolet, 440);
        this.sine.connect(this.audiolet.output);

        console.log(this.sine.outputs[0].buffer);
        console.log(this.sine.outputs[0].buffer.getChannelData(0));
    };

    this.audioletApp = new AudioletApp();
};

Thanks again.

from audiolet.

oampo avatar oampo commented on July 21, 2024

Ah, okay - this happens because the buffers are created the first time the output requests samples from the Audiolet graph, which hasn't had a chance to happen by the time we get to the console.log calls. If you are just looking to visualise the first n samples then you can manually tick the graph by doing something like:

...
        this.sine.connect(this.audiolet.output);

        // Manually tick the audio processing graph
        this.audiolet.device.tick(new Float32Array(1024), 2);

        console.log(this.sine.outputs[0].buffer);
        console.log(this.sine.outputs[0].buffer.getChannelData(0));
...

Otherwise if you set up a requestAnimationFrame after you have initialised the audio graph then it should get a chance to tick through the first time and you will get sensible sized buffers.

from audiolet.

ewdicus avatar ewdicus commented on July 21, 2024

Ah, thanks. To clarify, I'll be doing this repeatedly; so, then I don't need to tick it manually, it's just the first time that it's empty? I'll give that a try.

from audiolet.

oampo avatar oampo commented on July 21, 2024

Yup, that's right - tick will be called automatically every time new samples are needed, and the first time this happens the buffers will be populated.

from audiolet.

Related Issues (20)

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.