MoonModules / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi! MoonModules adds features on top of upstream.
https://mm.kno.wled.ge
GNU General Public License v3.0
187 stars 54 forks source link

Troy's zeroCrossingCount #125

Closed netmindz closed 2 months ago

netmindz commented 3 months ago

I am trying to port @troyhacks 's experiment to swap the playlist at a "good moment" in the music, rather than just at a fixed time interval. The first stage is to capture the extra data we need, the second MR is to use this zeroCrossing data https://github.com/MoonModules/WLED/pull/124

Video what his original experiment can be seen here https://discord.com/channels/700041398778331156/1074743147797688340/1214691686060531824

softhack007 commented 3 months ago

Hi guys, I'll look into this over the weekend. Maybe spend a few words on what you want to achieve?

netmindz commented 3 months ago

Hey @softhack007, thanks for the comments so far. I've added some context to the MR description as you weren't part of the chat on discord

troyhacks commented 3 months ago

Mostly it's capturing 3 main calculations inside of AudioReactive:

The number of zero crossings The "bass amount" (adding up some bins) The "energy" of the sample (samples squared)

These a munged together to get a "score" and then a short and long running average is created from these scores.

When the scores align, the pattern is changed.

troyhacks commented 3 months ago

@netmindz @softhack007 - this is the original inspiration for what I'm trying to do:

https://not-matt.github.io/AudioSync/ (live demo where you can drop an audio file)

The calculations I used are based on this:

https://github.com/not-matt/AudioSync/blob/41c287c3541509d5a9c6d8f17bbfdec2e1727238/src/AudioSync.js#L244

Admittedly my code was slopped together in an afternoon as a PoC, so I really appreciate you both taking this on. Thank you!

netmindz commented 3 months ago

Look at the auto-playlist branch to see the data actually being used for something

netmindz commented 3 months ago

I think I've taken this as far as I can, might need to hand back over to you @troyhacks or maybe @softhack007 ?

softhack007 commented 2 months ago

Is this PR a pre-requisite for https://github.com/MoonModules/WLED/pull/124 ? Or maybe the other way, this PR is superseded by #124?

I'm asking because both PR's have code to calculate zero crossings in audioreactive.

softhack007 commented 2 months ago

Mostly it's capturing 3 main calculations inside of AudioReactive: The number of zero crossings The "bass amount" (adding up some bins) The "energy" of the sample (samples squared)

Seems that we are only calculating zero crossings - so you don't need the other two values? Or I missed something?

netmindz commented 2 months ago

Is this PR a pre-requisite for https://github.com/MoonModules/WLED/pull/124 ? Or maybe the other way, this PR is superseded by #124?

I'm asking because both PR's have code to calculate zero crossings in audioreactive.

Started 124, then thought it better we have a PR that contains the changes to our main module without the playlist module, so created 125

124 in effect depends on 125.

So any changes should be made here and pulled into 125

netmindz commented 2 months ago

Mostly it's capturing 3 main calculations inside of AudioReactive: The number of zero crossings The "bass amount" (adding up some bins) The "energy" of the sample (samples squared)

Seems that we are only calculating zero crossings - so you don't need the other two values? Or I missed something?

Managed to move the other two values to be calculated from data in the sync packet, so we only calculate the extra two if we are actually interested and no new sync version needed either

softhack007 commented 2 months ago

Not sure about the placement of the calculation after filtering - I found it better before, but whatever works.

I think it's better after the filtering. We have some crazy audio sources like analog or PDM mics that won't cross zero without the filters - too noisy or strong DC offset.