GeorgeZaharia's Forum Posts

  • Why not just use the Audio plugin?

    the project im working on(to kill my time and make something cool using C2 and Q3D) requires mp3/ogg/wave audio formats to be played... but users after i finish the project wont sit to convert to .ogg or any other format.. they will want to import a mp3 file directly since its the most common format on internet ...

    i have a combination of filechooser and browser js snippet to play any audio format and read a song pcm data

    which gives me a full preloaded waveform of any audio format...

    but i cant add the audio analyser effect to it since the audio plugin is not playing that song but a new audio object that i made in the browser...

    so now i need to get a js execution and basically reinvent everything to work around the audio plugin inability of playing mp3's and read the full waveform before playing the audio file in this case the music files that users wold choose to import.

    all this wold be avoided if audio plugin could play mp3's alone with the other formats

    the audio plugin works perfect for the rest of the project... but mp3s and pcm data is the main game (ex of gameplay :

    Subscribe to Construct videos now

    )

    with the help of R0j0Hound i have the bellow capx...

    which i adapted to work with the Q3d and i have a pretty close simulation as audiosurf... just now im missing the analyser effect which wold give me the beats reading while playing and ability to use those as speed boosting and notes/blocks spawning.

    its a pretty easy project ... but gives me headaches since im a bit more clumsy then normal people with js.

    capx: import any audio format and create a linear waveform - doesn't require custom plugins.

    now since i explained what im doing...

    the main audio js execution i need.. is for me to stop the audio playing... if i import a new song in the above capx .... for that i know i need a tag or name for each audio object i create... or i could destroy the audio object of the previews song and then create a new one when a new file is imported. ... or i can change the source... but for that i need to stop creating a new audio ... and that i have no clue how to do..

    but as i said above... my js skills are similar to a preschool kid assembling puzzles.

    as for the audio analyser its not a problem... i can calculate the length of each waveform line and convert it to a fictional speed when player is in proximity creating the illusion of speed boosting on beat.

    i just going to use unity + blox and it seems like construct1000 !

    thats more like stencyl logic then scratch.... even though both use the same colored blox... stencyl has similar logic as the unity+ blox thing interesting

    Really looking forward to this.

    Adding in the ability to do Javascript code snippets would be killer.

    you already can do that using the browser plugin and execute javascript

  • im currently playing audio files with browser

    by using the bellow execution

    "var aud = new Audio();

    aud.src = '"&FileChooser.FileURLAt(0)&"';

    aud.play();

    "

    everytime i import a new song it plays over the old one and sound duplicates

    i tried using this "sound.pause();

    sound.currentTime = 0;

    " before i play a new audio but if i do that the global volume stops and the audio files aren't heard anymore

    is there a way when i load a new song to stop the old song? i know i have to add a tag or name to the object but my skills are really poor on js.

  • normal buttons are a different type of objects they cant be toggled invisible unless you use CSS to make it so... or move it outside the layout. but there is no point of using buttons when you have sprites unless you need that custom CSS feature of them.

  • 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

    thanks again Mr R0j0.

  • 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 <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> now fun part comes haha <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> 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 ( ' ) ?

  • 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

    // 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);
    		};[/code:2i4hq3rs]
    
    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 [url=http://support.ircam.fr/docs/AudioSculpt/3.0/co/FFT%20Size.html]fft size[/url] calculus and [url=http://support.ircam.fr/docs/AudioSculpt/3.0/co/Time%20Buffer.html]time buffer[/url] 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.
    
    [url=http://archive.gamedev.net/archive/reference/programming/features/beatdetection/index.html]Beat detection Gamedev[/url]
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • This is interesting. Can you share the code on how to detect beats?

    the code is based on the C2 default Audio Analyser example ... however in order to properly use it i had to understand how audio Api works and how beat detection is matematically calculated.

    2 very good tutorials and reads i found where W3 audio Api and the info from gamedev for understanding the math behind it.

    and of course the badlogic onset detection helps or maybe "helps" is to strong... but proves the above 2 documentation about the audio processing.

    at the moment there is not much for me to share with you as code base since its not different then what audio analyser uses... but when im done with it i will release a tutorial about it since the links above are pretty hard to adapt to C2 plugin which is missing a few important calls... but that is another story and i dont want to sound as a broken record.

    but on a short explanation im using the Audio.AnalyserGetFrequencyBinAt("audio",0,audio.CurrentTime) which gives you the exact beats for every 0.01-0.001(686968691 as C2 shows), of the song then its a matter of detecting the lows (bass beats ) and highs (Snares/overal volume hits). by substracting an average -60 dB for Lows and -20 for highs. but i need to retest it a few times ... cause for some songs the procedural Generation works good and for some its braking... its something that has to do on how the song is transformed in .ogg on 441000 Hz or 32000 Hz etc also i did not tested yet... but i think it will be better for using mono mixes instead of stereos but again its not yet proven.

    then again im at the part of making a small "formula" to place the right beats in an array before playing the song and preLoad the samples in a song then i could generate any map or any song visually as Audacity does... but its to late here at this time so il see tomorrow about it...

    dont mistake the Audio.AnalyserPeakLevel with the Snares or high pitch ... same goes for the Audio.AnalyserRMSLevel its not the bass... Those are just the overall High and Medium dB of the song. they are not again... beat detection functions. they probably will help later on but at this current stage they did nothing but to make me look at the audio plugin in a wrong way. but then again its also my mistake not reading before using it haha... so yea... a lot of stuff to be read and applied before i have a near functional C2 beat detection using only the Already existing Audio Plugin... i dont have the time or skills to implement an already existing .js that does all this for us... so thats the story so far

    also let me know if you do some testings and if you manage to create something related with the audio plugin that might help me also

    Edited: in the current progress video the unaligned shape of the so called road... is the actual real waveform i compared the audacity form and the c2 2d audio form(proving im on the right track)... which i altered using the cos formula so its looking a bit smaller.

  • Some of you might seen some tests i have posted before... this is the next more polished stage of it.

    All started with this little test / test

    so ... here it is...Current Progress Video

    Milestones

    [Trying to implement the road assembly from this

    Test]

    [Custom 3D Ship obj]

    [Background Effects]

    [HUD&regular functions to be displayed (ie. scoring etc)]

    [importing .ogg files to be played]

    [Polishing the accuracy for Road Procedural Generation]

    [Adding beat/snare detection blocks]

    -> [A few more tests to be made to get a pre-rendered road before playing the audio..... i learned how C2 audio analyser effect its working and getting the frequencybitdataAt every 0.1 i have a good idea how to add a procedural pre-rendered before playing the audio.. even though normally we wold preload samples. In C2 doesn't exists that action... but it can be tricked ...so there i continue now ]

    Il start with last one.

    Current Events 28(from which 10 are for the 2d sprites and 5 or 10 global variables that i dont use anymore and forgot to delete them)

    As always il try keep everything under 100 events. And using the default C2 plugins ... minus the Q3d one

    another early test

    Keep in touch.

  • i think its a bit to hard at this stage to say something about it...

  • > some random thing i was occupied lately with <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> long way to finish it though <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    >

    > https://drive.google.com/open?id=0B0lqV ... Dd6Z2tkUUE

    >

    Cool! is this using the Q3D plugin or is it sprites?

    Q3D but was an early test road was unaligned ... i have it almost ready got a pretty close clone of audiosurf as much as i could get

    since the c2 audio plugin doesnt have the most 2 important calls from the node audio api which is

    getFloatTimeDomainData (Float32Array array);

    getByteTimeDomainData (Uint8Array array);

    attribute unsigned long fftSize;

    readonly attribute unsigned long frequencyBinCount;

    attribute float minDecibels;

    attribute float maxDecibels;

    attribute float smoothingTimeConstant;

    so its like working with half a measure ... but yea Q3D

    Edited:

    Last news ... managed to work around the missing min max decibels and the bytetimedomaindata requirements.... the development continues <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    soon will get a demo working merging this road assembly with this smooth road procedural generation

    then its a matter of adding a importing mp3 and converting in ogg inside the game so any song can be played by users choice ......

  • > Zelda Life v3 if you still need it... its similar with yours

    >

    Could you make this in the latest stable version, please? My gamekit is built in the latest stable version, so I prototype any features in separate projects in r227 before importing them.

    if you unzip the capx and go to the folder exported and edit with notepad the .caproj file inside... you will find on top of file version r229000 change the 9 to 7 and save and should work... its not recomended but i think the tilebg isnt changed in r229 so should work fine.

    its faster for you to just edit the caproj... i have to reinstall all plugins and etc again...

  • Zelda Life v3 if you still need it... its similar with yours

  • GameEnded

    curent score >localstorage highscore

      set localstorage highscore to score
      trigger once Audio play tadah.

    that should work hope it helps you.