GithubHelp home page GithubHelp logo

Comments (3)

voodoohop avatar voodoohop commented on May 4, 2024 1

Cool. Good to know the expected behaviour. I'll try to make some tests

from virtual-audio-graph.

voodoohop avatar voodoohop commented on May 4, 2024

Sorry hijacking this thread for another followup question. Are nodes only updated when their key changes?

I'm creating a new audio graph where the buffers of the bufferSource's are changed but I only hear the new sound if i change the key.

from virtual-audio-graph.

benji6 avatar benji6 commented on May 4, 2024

Hi @voodoohop, custom nodes can be composed of other custom nodes. There is ony 1 test case for that though https://github.com/benji6/virtual-audio-graph/blob/master/test/customNodes/expectedBehaviour.ts#L26 so it's possible you hit an edge case.

I just tested this example which seemed fine:

    const osc = createNode(
      ({ gain: gainValue, startTime, stopTime, ...rest }) => {
        const duration = stopTime - startTime;
        return {
          0: gain("output", {
            gain: [
              ["setValueAtTime", 0, startTime],
              [
                "linearRampToValueAtTime",
                gainValue,
                startTime + duration * 0.15,
              ],
              ["setValueAtTime", gainValue, stopTime - duration * 0.25],
              ["linearRampToValueAtTime", 0, stopTime],
            ],
          }),
          1: oscillator(0, { startTime, stopTime, ...rest }),
        };
      },
    );
    const pingPongDelay = createNode(({ decay, delayTime }) => ({
      0: stereoPanner("output", { pan: -1 }),
      1: stereoPanner("output", { pan: 1 }),
      2: delay([1, 5], { delayTime, maxDelayTime: delayTime }),
      3: gain(2, { gain: decay }),
      4: delay([0, 3], { delayTime, maxDelayTime: delayTime }),
      5: gain(4, { gain: decay }, "input"), // connections will be made here
    }));
    const synth = createNode(({ startTime, stopTime }) => ({
      0: pingPongDelay("output", { decay: 0.8, delayTime: 0.5 }),
      1: osc(0, {
        frequency: 110,
        gain: 0.2,
        startTime,
        stopTime,
        type: "square",
      }),
    }));

    const { currentTime } = virtualAudioGraph;
    virtualAudioGraph.update({
      0: synth("output", { startTime: currentTime, stopTime: currentTime + 1 }),
    });

And in answer to your second question, nodes should be updated whenever any properties change (not just the key). There may be some limitations to this (e.g. if the underlying audio API does not allow this). Or of course there may be a bug - do share an example if you are having trouble.

from virtual-audio-graph.

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.