Audio plugin / Loopindex limits?

Discussion and feedback on Construct 2

Post » Wed Jun 08, 2016 3:08 am

As the title says...

Does anyone know what are the limits of loopindex and audio plugin analyser song read?

because im trying to get a complete waveform of a song... but for some reason even though the loopindex works even for 2mil counts and above... audio plugin seems to not work properly... or cant read a song properly based on loopindex after 22500 ..... as more i test the C2 new versions it seems there is a limit always that ends in 25 same was for the new audio post that had a 0.025 wait ... now i seen lately nothing happens under 0.025 anymore is that the new tick count?

the code to create a waveform is taking a "songlenght" multiplied by 1000 to get each millisecond and for X from 1 to songlenght creates a sprite

however even if i can create more then 22500 objects .. the loopindex seems to stop at 22500 ... which is weird... is there something im missing?

here is a capx file using the canvas plugin, i was thinking it wold work better by working around the sprite limits but its not ... @Ashley have any idea why it stops? its exactly 2.25 seconds again the magic number "25"

sorry for my confusing writing its really late ... didn't sleep for 2 days trying to find something about it ... either i was looking for the wrong words or dunno couldn't find nothing about waveform in c2

Edited: as you can see instead of 1000 i used 1002.25 because i cant get the exact song length in milliseconds for the loopindex to match incrementally by 1

however the multiplication has nothing to do with the song reading waveform ... it should not stop at 22500 or 2.25 seconds of the song.. im thinking the audio buffer is limited to 2 seconds?

the 22500 its the song with 36000 HZ in name... since the total lenght is around 3 minutes but it stops at around 1% of the song basically.
B
70
S
20
G
67
Posts: 1,314
Reputation: 42,301

Post » Wed Jun 08, 2016 6:39 am

22500 is a common sample rate for sounds so maybe that has something to do with it. It could be just how far ahead the plugin looks. You could try searching for the number in the audio plugin's source code to see if it's ever used.
On another note in webaudio the analyzer effect seems to mainly just be used to get the waveform in sections. I'm not sure if it can get the entire song at once. Some googling about the webaudio analyzer hasn't yielding anything yet except for it being used to show the sound as it plays.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Wed Jun 08, 2016 7:52 am

R0J0hound wrote:22500 is a common sample rate for sounds so maybe that has something to do with it. It could be just how far ahead the plugin looks. You could try searching for the number in the audio plugin's source code to see if it's ever used.
On another note in webaudio the analyzer effect seems to mainly just be used to get the waveform in sections. I'm not sure if it can get the entire song at once. Some googling about the webaudio analyzer hasn't yielding anything yet except for it being used to show the sound as it plays.


hi r0j0 yea i have been looking into that .... .... however sample rates in audio plugin are not the real samples they have to be calculated on gettingfrequencybeat which c2 audio can do but ... not further then the first 22500 of them il look into that...

i tried using functions and even arrays and saving the bitdataat each milisecond but the effect is the same just 22500 are read and written even if i have an array of 2250000


i did look in the audio runtime js and the only close enough number to 22500 is 22050 which is on line 2399

and the code is for playing a empty buffer

Code: Select all
// play empty buffer to unmute audio
         var buffer = context["createBuffer"](1, 220, 22050);
         var source = context["createBufferSource"]();
         source["buffer"] = buffer;
         source["connect"](context["destination"]);
         startSource(source);
      };


not even sure if this has any relevance...

Edited: and it does not

if i do draw while playing works good for the entire song... but not sections... something is up with the cache of the buffer clearing the samples and only reading from source it might be also that ... seen a few browser "Has enough memory tag around then cache cleared.." so im guessing the enough memory is around 2.25 seconds or i guess under 1 mb then after that the app wold buffer directly from the source... the weird part is .. even if i move the music in the sounds folder it still does it... so it cannot be the preloading of the music... its way out of my area...


Edit2: have to mention if i draw a repeat from 1 to 22500 starting the loopindex("x") at 0 lets say and then repeat the same number loopindex at next interval of 200 px to right its drawing the same thing... the only problem is why it does not draw further after 22500 even though the loopindex takes the time to read the entire data of the song...which is 2.250.000 X rows


how i know it reads all the data? .. if i leave only the 1 to 22500 repeat once then its only taking around 0.5-1 second if i leave it for the entire song... takes around 5 -10 seconds so something is reading the problem is does the writting is jumping with 10k further? i tried using the 100k layout to see if shows further out but no changes...
if i use the w3 audio array formula and saving of the bitssamples and repeat the audio.bincount 512 for the loopindex 1 to 22500 which is called preloading the samples of the song.... its not doing nothing else but repeating the same 22500 bits in same place... so its clearly something limiting it to that number or to 1-2% of a Music file(.ogg).

as i noticed if i use the 36000hz song then the data is smaller and reads faster but same stops at the same 1-2% if i decrease the fft size from 2^15 which is 36000hz to 1024 or 2^10 then it reads the half of that so... i wold increase the fft size just we cant above 2^15 i dont see a usage above that either since the more bits the harder computers and browser wold be compatible....


@r0j0hound you said something is interrupting what ived seen in the runtime was that on some browsers its preloading till and quote "Memory is Enough" then after that it clears the cache and starts live streaming.


Edit3: but as many websites that did tutorials on the web audio api a fft size of 1024 should read the entire song... it does not require to be that large... unless.................. i have to check something il edit later a bit...

Edit4: ok so its nothing else but the first point i was wabling around... its related to the fft size calculus and time buffer thats why is the 22050 in there its basically 21.35 hz band and on that hand the time buffer only plays an average 0.23s which in the example i made its a fftsize 10 times bigger so its adding up to 2.25 / 2.135 makes sense... but... now remains the question..

how do we preload more samples then the 1 its doing?


found a beat detection tutorial about samples... however i cant really understand how i wold move the next 1024 instances to the right... im guessing the loopindex it should automatically do it .........in C2 right?

Simple sound energy algorithm #1: its relating to the sampling issue.

Beat detection Gamedev
Last edited by gamecorpstudio on Wed Jun 08, 2016 5:41 pm, edited 8 times in total.
B
70
S
20
G
67
Posts: 1,314
Reputation: 42,301

Post » Wed Jun 08, 2016 8:34 am

My next guess is that's how far ahead the song is loaded if it's being streamed. I'll try to look into it more tomorrow when I get access to construct again.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Wed Jun 08, 2016 8:19 pm

Ok I had a look and to me it looks like the audio analyser in webaudio isn't meant to read the entire song, only what's currently playing as a real time analysis. Maybe instead you could utilize the following to take a sound file and decode it into the raw pcm data and analyse that somehow:
https://developer.mozilla.org/en-US/doc ... eAudioData

Here's a the result:
https://dl.dropboxusercontent.com/u/542 ... eform.capx
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Thu Jun 09, 2016 5:20 am

R0J0hound wrote:Ok I had a look and to me it looks like the audio analyser in webaudio isn't meant to read the entire song, only what's currently playing as a real time analysis. Maybe instead you could utilize the following to take a sound file and decode it into the raw pcm data and analyse that somehow:
https://developer.mozilla.org/en-US/doc ... eAudioData

Here's a the result:
https://dl.dropboxusercontent.com/u/542 ... eform.capx



..... i wish i was near you to kiss you ... your my hero... this is perfect...... this solves a big problem of what i needed :D now fun part comes haha :D il keep you updated


also what is the c2 brakets system for js ? cause i tried a few times using a normal javascript code but i always get some missing tips poping up cause of the closing being wrong does it have to be always between ("")? cause if thats how it works... how we replace the quote sign inside the js? with a ( ' ) ?
B
70
S
20
G
67
Posts: 1,314
Reputation: 42,301

Post » Thu Jun 09, 2016 6:49 am

Usually I just replace all the " in the js with ' which works well. To actually use " in js it looks much uglier and makes it harder to find typos.

For example the take this js:
var name = "bob";

To use in c2 this usually is what I do:
"var name ='bob';"

But if you want to still use " it looks like this:
"var name=""bob"";"
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Thu Jun 09, 2016 9:05 am

@R0J0hound

oh i see so if we keep the normal "bob" we have to basically add an extra " "bob" " system as for the words in a text variable. thats cool i guess thats why i was getting those issues i never added the extra quote signs

that means i can use any js in w3 school :D that will make the code for waveform much more flexible and accesible :D

thanks again Mr R0j0.
B
70
S
20
G
67
Posts: 1,314
Reputation: 42,301


Return to Construct 2 General

Who is online

Users browsing this forum: htmlgames and 8 guests