Coder Social home page Coder Social logo

Comments (7)

jussi-kalliokoski avatar jussi-kalliokoski commented on May 24, 2024

I'd be glad to help, but I need to see some code. Not knowing what you've modified in the Pluck makes it hard to tell what's the problem, I'm not a psychic (yet) after all. :D

from audiolib.js.

Karbonforms avatar Karbonforms commented on May 24, 2024

I'm using the original Pluck. Sorry for confusion. I thought it was something to do with my modifications, so I reverted back to the original. It's something going on elsewhere in my app that's causing the issue. I never attempted to post code as I've no idea where the issue is! So, just to be clear: Pluck is unmodified.

My internet has actually exploded so I'm in the library, but my under-development site can be found at http://fretweb.co.uk

click either the "black dog" or "bendtest" button to load a track, then press one of the play buttons under the fretboard. Until recently this would play notes. Currently just getting a pop at audio start and finish. All javascript should be uncompressed, with the action starting in fretboard.js which sends events through audio_audiolib.js which calls Pluck.

I've a feeling it's something to do with my javascript naivety (so, sorry for dodgy noob JS!)

As I say, I'm in the bleedin library, not at my machine. Hopefully you may not mind pointing your debugger at my site, if not I'll get back to you when my interknocker is fixed.

Cheers!

from audiolib.js.

Karbonforms avatar Karbonforms commented on May 24, 2024

Right, got me some Mobile Broadband...

So, as I said, I'm using the unmodified Pluck. My app is a rudimentary sequenced guitar synth Here is the calling code. I use 6 Plucks: 1 for each string on the guitar. This was working fine. PlayNote gets called whenever needed. Now something I do not understand is stomping on the buffer used inside Pluck. I just looked and the buffer is full of -1.2832028954190643e-19 and very similar. But it's hard to debug as the audio thread/worker does not stop.

And as I mentioned in my first post, if I put a breakpoint right at the end of the 'note' function, I can hear the first note, but then it just goes to the odd pop again.

I am baffled.

var channels, sample;

var AudioLibApp = function () {
    this.channels = new Array(6);
    channels = this.channels;
};


var audioProcess = function (buffer, channelCount) {
    sample = 0;
    for (var i = 0; i < buffer.length; i += channelCount) {
        for (var j = 0; j < 6; ++j) {
            channels[j].generate();
            sample += channels[j].getMix();
        }
        sample /= 6.0;
        for (var n = 0; n < channelCount; n++) {
            buffer[i + n] = sample;
        }
    }
};

AudioLibApp.prototype.stop = function () {
    this.dev.kill();
    this.dev = null;
};

AudioLibApp.prototype.start = function () {
    this.dev = audioLib.AudioDevice(audioProcess, 2);
    for (var i = 0; i < 6; ++i) {
        this.channels[i] = audioLib.Pluck(this.dev.sampleRate, 0.3, 1.0, "brown");
    }
};

AudioLibApp.prototype.playNote = function( frequency, string, velocity ) {
    this.channels[string].note(frequency[0]);
    this.channels[string].amp = velocity;
};

from audiolib.js.

jussi-kalliokoski avatar jussi-kalliokoski commented on May 24, 2024

Alright then, the problem is that you're setting Pluck's amp value to undefined which causes it to output NaN.

A quick fix would be to change (in playNote())

this.channels[string].amp = velocity;

to:

this.channels[string].amp = typeof velocity === 'undefined' ? 1.0 : velocity;

But another way to fix it is to always pass a valid velocity to the function. :)

from audiolib.js.

Karbonforms avatar Karbonforms commented on May 24, 2024

Doh! How on earth did I miss that?! Well I suspected my Javascript naivety and I was right. I'm not used to being able to call functions without all parameters filled in.

Cheers and sorry for bothering you with my stupidity!

from audiolib.js.

jussi-kalliokoski avatar jussi-kalliokoski commented on May 24, 2024

Heh, no problem, reaching out is always good! And that wasn't stupidity, I make that same mistake (in different forms) all the time, and that's why it was so easy for me to spot it in your code. ^^

Take care!

from audiolib.js.

Karbonforms avatar Karbonforms commented on May 24, 2024

All good. Project back on track...

I can get back to my modified Pluck now.

I was wanting to ask you, how you would go about approximating a guitar bend? I say approximating because I'm not writing an actual guitar synth performance tool. It's a teaching tool so it only needs to get the general idea across. The source data (Guitar Pro files) provides "bend points". What I'm doing for now is providing my modified Pluck with an array of frequencies representing said bend points. It creates a buffer for each bend point/frequency. The generate function updates all these buffers but the output value is only taken from the "current" buffer/bendpoint/frequency. This current buffer-to-use is updated in real time. So the frequency jumps rather than bends, which is OK for now.

Just curious how you'd maybe go about it?

from audiolib.js.

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.