meenie / band.js

Band.js - Music composer interface for the Web Audio API.
Other
1.18k stars 93 forks source link

Possible addition to a plugins object... #32

Open assertchris opened 7 years ago

assertchris commented 7 years ago

I was wondering what your thoughts are on plugins (as part of the core library). For instance, I've created a fade in/out plugin (function), and thought it might be a cool idea to bundle it like:

const instruments = [
    instrument1
]

const from = 0
const to = 50
const steps = 8

BandJS.plugins.fade(instruments, from, to, steps, function() {
    instrument1.repeatStart()
    instrument1.note("quarter", "C3")
    instrument1.note("quarter", "D3")
    instrument1.repeat(3)
})

I could create a pull request, for this, if you think it's a good idea...

meenie commented 7 years ago

The ability to fade like this is amazing! Dynamics are very important in music :). I'm don't feel like the way Band.js is built allows for plugins. I'm actually in the middle of rewriting the whole thing using RxJS. I can build in the concept of plugins at that point as well.

If you want, you could build the fading ability straight into the core of the app, rather than making it a plugin. What do you think about that?

BTW, by steps, do you mean how many notes go by? Usually in music, you see the crecendo or decrecendo lines the length of notes. So it might be better to say for how long the fade should go, i.e. half, quarter, whole, etc. What do you think?

assertchris commented 7 years ago

What do you think about that?

Sounds cool. Lemme know where I can find the Rx version/send pull requests to :)

i.e. half, quarter, whole, etc. What do you think?

I think it's a good idea to support the musically correct way of describing a fade in/out, but I must confess I know even less of music theory than I do of the internals of this library. The easiest way I could figure to fake the fade was to adjust volume between instrument.note/instrument.rest calls (which is what the example demonstrates).

I was even working on a variation of the fade function, to inspect the source of the callback, and count the number of calls to note and rest, so that I could remove the steps parameter, but that complicated multiple instruments inside the fade block (so I removed that code).