wizgrav / clubber

Application of music theory in audio reactive visualizations
http://wizgrav.github.io/clubber
MIT License
358 stars 26 forks source link

Templates #6

Closed alvarobyrne closed 6 years ago

alvarobyrne commented 7 years ago

Hi. Dare sharing this: http://jsdo.it/alvarobyrne/clubber_templates_1 Not sure why template 3 power of strongest note is spitting values higher than 1. Currently looking into it but anyways want to share the demo. Would like this issue to be tagged as a question. Thank you.

wizgrav commented 7 years ago

No question, this is a bug, more than one actually. Thank you for bringing this to my attention. It is triggered by the configuration of the adapt option. Fixing it is easy but I'm investigating it a bit more. In the meanwhile, I think my description for the adapt option isn't clear (documentation PRs are most welcome).

The smooth option needs to be the same length as the template, the number of measurements produced. The adapt option takes always 4 numbers. The first one is the offset, relative to the range low-high, of the lower bound. The offset is from the average power of the notes. The second number sets the smoothing factor for the lower bounds movement. The other two numbers do the same for the upper bound. The upper bound generally needs to be more than 0.5. You can experiment in the tool and see how the specturm window behaves when the values are changed.

These are irelevant to the fact that this is a bug. It was just triggered by the 0.1 values provided to the upper bound which forced it to stay too low. This uncovered the bug because the power of the strongest note was not taking the upper bound into account, it assumed it would usually match it.

wizgrav commented 7 years ago

@alvarobyrne I did a fix, it seems to work normally now http://jsdo.it/ygravezas/QAZC please confirm so we can close this. Also the last two template descriptions were wrongly swapped, this is also fixed

alvarobyrne commented 7 years ago

@wizgrav Thank you man. It seems to work well but I wont be able to confirm until some time next week. I want to take a look at how each template is computed and write a bit about it, hopefully add some wiki page(s) or extend the main readme.md file, but as I said before, wont be able to do so soon. I insist: thank you.

alvarobyrne commented 7 years ago

Hi. So I have done these two at jsdo.it: audio audio synthesis I don't understand why some templates get locked when band bounds are not affected. This is easier to see with the second demo: when changing the volume of synthesized audio.

wizgrav commented 7 years ago

The audio volume will affect the values returned from the web audio analyzer. Gain etc should be applied after fetching the fft data. You can achieve this with clubber by instantiating it like:

var clubber = new Clubber({ mute: true }); // It will not connect the internal analyzer to audio out

clubber.listen(audioNode); // You can also pass webaudio nodes instead of media elements

// Apply gain etc to audioNode and finally output to webAudioContext.destination
wizgrav commented 7 years ago

The second example is great for checking the note detection, your examples in general make me think of the value of a sort of test suite, would you want to tackle that?

The strongest and weakest note indexes keep their last values when no notes have been active in the window defined by the bounds. They don't zero out when the track is silent, should this behavior be changed? I felt is was more proper at the time but I'm open. Is this what you mean by locked?

I also have the impression that the actual bounds don't update to the controls values until the first time the controls are changed, the defaults only have a range of 24-34 midi which is pretty narrow and not even a full octave so the note indexes will not cover the whole range

alvarobyrne commented 7 years ago

Yes, that is what I mean by locked. I believe they shouldn't get locked. Although it makes me think that zeroing them would be equivalent to saying that the "0th note is the strongest/weakest", so may be setting it/them to null might be appropriate, I don't know.

Tackling a "sort of test suite"? Would you set it and i'll program it? To tell you the truth I have always thought of testing as boring, but in this case it makes me doubt. In this case "I am open".

I'm not sure if I fully understand the last paragraph. I could make and effort but could you please rephrase it or expand upon it, please.

Thanks for you attention.

alvarobyrne commented 7 years ago

Not relevant to issue: there is typo on line 176 of http://jsdo.it/ygravezas/4yHC: obviously it should spell 'triangle' instead of 'traingle'.

wizgrav commented 7 years ago

Well I'm in the same thought train here, writing tests is boring. What I really meant was that you could bundle your existing examples to be used as an online testing utility. That would be very valuable.

Regarding the note index lock, I think I'll provide a flag on bands that would switch between the two behaviors(locked or zeroing the values when silent).

Regarding the last paragraph scrap it, the values are indeed set according to the controls

alvarobyrne commented 7 years ago

I'll consider/think about "bundling existing examples to be used a an online testing utility". I'm not sure but I'll think about doing so.

alvarobyrne commented 6 years ago

Closing this issue due to recent code base changes. Congratulations on the updates!