Coder Social home page Coder Social logo

Visualization Example about audiolet HOT 13 OPEN

oampo avatar oampo commented on June 23, 2024
Visualization Example

from audiolet.

Comments (13)

oampo avatar oampo commented on June 23, 2024

Hey Elliott. Yeah, I forgot about this on moving over. Probably the solution for the moment is a new node which subclasses PassThroughNode and fills a fixed length buffer in its tick method. Then you should be able to use it in the same way as before, just grabbing data from the buffer and visualising it.

I can have a look at some point in the next week or so, but if you fancy having a shot at fixing it then feel free to ask any questions here, and chuck in a pull request.
Thanks for the report,
Joe

from audiolet.

ewdicus avatar ewdicus commented on June 23, 2024

That makes sense. However, I'd like to be able to show a visualization for any arbitrary node. Short of adding a fixed length buffer back into every node purely for visualization, is there a sensible way to accomplish this? It may be that this is outside the general scope of the library, in which case I suppose I'll have to do it in a fork.

Thanks for the quick reply and any other info you can offer,
Elliott

from audiolet.

oampo avatar oampo commented on June 23, 2024

Other than adding a fixed length buffer to each node I can't really think of how you could do this. It's a bit of an unfortunate consequence of shifting to single sample ticking (although visualising the variable length buffers wasn't ideal when working with blocks).

You can probably monkey-patch the behaviour into the base AudioletNode fairly simply though. So something like this would probably do what you want:

AudioletNode.prototype.tick = function() {
    // First three lines are the standard AudioletNode tick method
    this.createInputSamples();
    this.createOutputSamples();

    this.generate();

    // This is where we make sure each node stores a visualisation buffer
    if (!this.buffer) {
       // Create this.buffer to store the samples here
   }
   // Push a sample from an output into this.buffer here
};

Hope this helps,
Joe

from audiolet.

ewdicus avatar ewdicus commented on June 23, 2024

Okay, thanks. I'll give that a shot. I'd like to switch to single-sample so
that I can use the FFT stuff when that's all wrapped up, I just can't lose
the visualizations!

If you think it'll be useful for others, I can put up a pull request if I
get it ironed out. If not, then I'll just keep a fork around.

Thanks again,
Elliott

On Fri, May 25, 2012 at 1:21 AM, Joe Turner <
[email protected]

wrote:

Other than adding a fixed length buffer to each node I can't really think
of how you could do this. It's a bit of an unfortunate consequence of
shifting to single sample ticking (although visualising the variable length
buffers wasn't ideal when working with blocks).

You can probably monkey-patch the behaviour into the base AudioletNode
fairly simply though. So something like this would probably do what you
want:

AudioletNode.prototype.tick = function() {
   // First three lines are the standard AudioletNode tick method
   this.createInputSamples();
   this.createOutputSamples();

   this.generate();

   // This is where we make sure each node stores a visualisation buffer
   if (!this.buffer) {
      // Create this.buffer to store the samples here
  }
  // Push a sample from an output into this.buffer here
};

Hope this helps,
Joe


Reply to this email directly or view it on GitHub:
#33 (comment)

from audiolet.

oampo avatar oampo commented on June 23, 2024

I think this is a fairly specific case (being able to simultaneously visualise all nodes), so it's probably best in a fork given that there is some processing and memory overhead associated. I do think there should probably be a separate node used for visualisation so we're not losing functionality, so I'll keep the bug open until that's in place.
Cheers,
Joe

from audiolet.

heavyk avatar heavyk commented on June 23, 2024

hey, I'm trying to add a visualizer to an audiolet test, and I've reduced the code down to a simple sinewave. I cannot get this to visualize no matter what I try. I have looked at the example but it's not working, tried the suggestions here, and also tried using webaudio's real time analyser like this

analyzer = audiolet.output.device.sink._node.context.createAnalyser()
data = new Uint8Array(analyzer.frequencyBinCount)
analyzer.getByteFrequencyData(data)
// data is [0,0,0 ...]

what would be the best way to visualize audiolet?

from audiolet.

ewdicus avatar ewdicus commented on June 23, 2024

I forked and added a buffer for visualization to each node. You can look at the specifics here: https://github.com/ewdicus/Audiolet. Then I'm plotting it using Canvas and Javascript.

from audiolet.

heavyk avatar heavyk commented on June 23, 2024

great man! I'll use that. thanks!

from audiolet.

ewdicus avatar ewdicus commented on June 23, 2024

I should clarify, I haven't updated the examples there. I've just made the changes to the code. If you need help figuring it out, let me know.

from audiolet.

heavyk avatar heavyk commented on June 23, 2024

I have collected the vizData successfully with your branch, but my visualizer needs a lot of work, lolz
thanks!

from audiolet.

oampo avatar oampo commented on June 23, 2024

Just a quick note that this probably falls under the Audiolet 2 remit now, where you will be able to use the RealTimeAnalyserNode.

from audiolet.

heavyk avatar heavyk commented on June 23, 2024

@oampo, ok, I'll give this a test run tomorrow...

@ewdicus so, I found a slight bug with your code...

(coffeescript syntax - contrived example)

sine_l = new Sine @audiolet, 440
sine_r = new Sine @audiolet, 440

pan_l = new Pan @audiolet, 0
pan_r = new Pan @audiolet, 1
sine_l.connect pan_l
sine_r.connect pan_r

vol_l = new Gain @audiolet, 0.1
vol_r = new Gain @audiolet, 0.1

pan_l.connect vol_l
pan_r.connect vol_r

vol_l.connect @audiolet.output
vol_r.connect @audiolet.output

vol_r.visBuffer.channels[0] will be correct, however vol_l.visBuffer.channels[0] will be filled with basically zeros (very small floats)

I'm not sure what the problem could be, and I may not even be using audiolet correctly, connecting stuff, but either way, I think it's time for me to call it a night... look at it tomorrow... gg guys!

from audiolet.

oampo avatar oampo commented on June 23, 2024

@heavyk The code to make it work in the version-2 branch isn't quite ready yet. I'll ping you when you can try it.
Joe

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.