Reaction to sound?

This forum is currently in read-only mode.
  • I'm working on a couple projects with Construct after starting a few days ago, and I love the program. I had a bit of a random idea to test if I COULD do something, and I'm wondering if there's any known way to make something react to music in Construct?

    I know how to make music play with the Xaudio plugin, but I want to make something react to the actual beat of it, kinda like a visualizer, or an equalizer-looking effect.It doesn't even have to be specific types of sounds, just beats in general.

    Is there a way to do this, or would I have to import some python scripts that can analyze audio files in order to effectively do it?

  • You can get the peak/rms levels from XAudio2. Apart from that if you need something more sophisticated you might be using the wrong tool for the job. Construct is a game creator, not an advanced music/FFT analysis system!

  • Yeah, I figured as much. That was about all I could figure out from the wiki. I might just mess around with volume detectors and try to get it going. I don't want something SUPER advanced, but I was hoping to get a synesthetic experience going between the music and the game around it. Things would pulse colors and waves, etc., along with the music.

    The volume levels idea might be basic enough to get the concept in place, though. I'll try fiddling with stuff. =P

  • alright, far as I can tell, the values don't change with the music, and my attempts at even getting text to display properly with it, or anything dynamic related to the audio, isn't working. I guess I'll have to give up on the idea, unless I'm REALLY missing something. =/

  • alright, far as I can tell, the values don't change with the music, and my attempts at even getting text to display properly with it, or anything dynamic related to the audio, isn't working. I guess I'll have to give up on the idea, unless I'm REALLY missing something. =/

    I don't see any option to get levels for music, no, but you can for sound. Here's an example of some dynamic stuffs happening with peak levels:

    http://dl.dropbox.com/u/529356/peak%20level%20test.zip

    A sprite moves across the screen and makes a blippy wave when the sound is played, kind of like a heart monitor. The levels are rounded and displayed in a text box. It would pretty much be up to you to experiment with how to manipulate the data the peak levels kick back at you.

    You could convert your music to one of the channel-supported formats and play it in a channel. Or you could hit up the feature request forum and ask that peak level info be added for music.

  • My suggestion would be: hardcode the beat.

    Unless you're going for an audiosurf kind of thing, in which case I'd say analyze the audio in a separate offline program and write down files that Construct can easily read. Kinda like audiosurf does.

  • Deadeye, you got exactly what I was looking for. I didn't realize the peak and RMS info only worked with WAV files. I converted the mp3 over and used the WAV, and it worked perfectly. it held constant at 0 before, but now it's great. I need to work on smoothing it out a bit, but it's definitely something I can work with.

    I was hoping it was something small like that I was missing, rather than something impossible, but it's good now. Thanks! =)

  • Keep in mind it's not just .wav, you can play .ogg or .wma on a channel as well if you want more compression. You just can't play .mp3 in a channel.

    Check out the XAudio2 entry on the wiki for more info.

  • Yeah, everything I'd gotten so far was from the wiki, I just didn't realize the expressions wouldn't fetch for music files like they would channel sounds.

    The example you linked isn't working for me for some reason, but the only thing I'm curious about how he did was rounding the values, though I think I have an idea of doing that so it isn't so skippy...

  • The example you linked isn't working for me for some reason

    Um... my 'peak level test.cap?' The one that I thought cleared things up for you before? Uh, okay. Strange. I assumed it had worked before since you said you got it.

    Anyway, if you're getting an error when you open it it's probably because you aren't using 0.99.72.

    but the only thing I'm curious about how he did was rounding the values, though I think I have an idea of doing that so it isn't so skippy...

    The... he? Me? What example? I am so confused by almost everything in your post . If it's my example... and it's the one that doesn't work... then how did you know about the rounding? And what... I mean... gah I lost my train of thought.

    Okay, start again. The example which helped you before now doesn't work and may or may not work retroactively in the past due to - quantum fluctuations in the time stream? let's just go with that - yet in some alternate universe that you have mystical knowledge of an alternate you understands that a) I had a rounding action in my example and b) it looks kind of skippy, but that other you, by proxy of you who is you-you, doesn't understand the rounding works but perhaps has a way of making it not so skippy.

    Okay, I think I got it.

    What was the question, again?

    <img src="http://i46.tinypic.com/2d0jqd1.gif">

  • hey that's a sweet example!

  • Ugh, I feel silly now. Okay, I didn't realize the .cap you posted was actually MADE by you right off. I thought you'd linked me to something someone else had done. hence the mixup with 'he' instead of you.

    You mentioned using the .wav format, or the channel audio, instead of the. mp3. Even without looking at the example, I tested that out, and it DID work, so that was what solved it for me.

    You mentioned rounding it in your post, so I knew you'd done something to make it smoother, even though I couldn't see it to figure out how or what did it.

    And no, I'm not running 99.72, i had 99.6. So, i'll install the new one and properly look at the .cap. =P

    Basically, I understood what you said, I just couldn't check your example to see exactly what you meant.

  • Oh, okay. That makes more sense than the whole alternate universe thing. I guess I should have read my own previous post too, would have cleared up some confusion.

    Oh and just in case you were wondering, the peak levels are returned in their raw format as a floating point value less than 1, so I multiplied the value by 100 and rounded it to get a more useful, readable number.

  • Heh, I love similar thinking. I actually did that with a circle sprite I had (multiplied by 100), then made it so the sprite's opacity was set always to the value of the peaklevel * 100. with the music, it's VERY skippy, as the peaks are constantly changing, so I'm working on either averaging out the value every 50 milliseconds or so to smooth it out, or I might just smooth the audio file itself, though I'm not sure what effect this would have on the end sound.

    Ah well, it's an experimental WIP, no reason not to try random stuff. =P

    And thanks for all your input, by the way. Very helpful, even if this doesn't end up working out quite as planned. =P

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • audio equipments usually hold the highest peak for a little while. Maybe that's what you're after?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)