Sound Visualization

This forum is currently in read-only mode.
From the Asset Store
Grenade Sound Library contains: 135 sounds 50 grenade sounds and 85 surface sounds
  • I'm don't no how it name, but possible maked in construct something like winamp <img src="http://img511.imageshack.us/img511/7157/clipboard03sq2.jpg">

  • I don't think so, but I could be wrong.

  • The spectral analysis of audio (which equalizers like that do) requires pretty hardcore math, so unless there is some tools for that in the new XAudio2, it would be hardly possilbe.

    AFAIK the audio is divided into different (ie. bass, mid and treble... of course there could be more) bands in digital enviroments using so-called Fourier transformations. (Or discrete cosine transofrmations) but that would require a direct access to the waveform and pretty hc math... Is here anybody here with signal engineering degree :D?

  • maybe just add some plugin or new Expressions for audio.

  • maybe just add some plugin or new Expressions for audio.

    Yeah, and if the XAudio2 doesn't offer the features, some 3rd party library could be used :)

  • Fourier transformation is needed, that's for sure. How to achieve it and make it fast at once? "Normal" Fourier Transformation algorithm uses O^2, and Fast Fourier Transformation uses n*log2(n). I can recommend getting FFTW:

    one of the fastest FFT algorithms - see benchmark results (and one sample to let you know which one to check)

    deals with non 2^N arrays of probes (but takes more time then)

    open source, free for noncommercial use

    AFAIR written in ANSI C

    support for optimalization of FFT-ing signal (but I don't think this would be useful in non-industrial use)

    AFAIR applications like Winamp uses FFTW to make spectrum analysis.

    The only problem is how to access XAudio2's pointer to actually played buffer. And I don't know how many samples are taken to analysis every "frame" (maybe 1k?). Anyways, FFTW deals with 2^19 samples in about 100ms.

  • BROO: That FFTW looks promising... but yes, there is the problem of getting the buffer. I don't know much about Construct's plugin architecture, but even if there would be an function retrieving the buffer in XAudio2 plugin, how would it pass to separate audio analyser plugin?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Method for making FFT

    FFTW has functions to which you have to pass:

    input buffer

    output buffer

    number of samples

    (and some other flags for optimalization and stuff).

    If you happen to retrieve pointer to XAudio2 buffer, you'll have to create your Output memory buffer. FFTW operation will populate the Output buffer with calculated Fourier Transformation.

    There are some ways (AFAIR in FFTW it's called kinds) of getting output data buffer. I'll explain it on example later in this post.

    Accessible frequencies depend on amount of probes you pass in Input Buffer. If you pass 8192-element Input Buffer, you'll get frequencies from -4095Hz to 4096 Hz. Then in order to get 20kHz spectrum you'd probably want to pass 40000 elements buffer. Since processing 2^N sized arrays is better, I recommend 65536 elements sized arrays to get -32767Hz to 32768Hz.

    Don't worry about working with transfering data, retrieving and stuff, it'll be done within 10msec for sure.

    And how to know which table indexes are the positive and negative frequencies? Well it depends on KIND of getting output data.

    Sample of usage:

    Let's say you want frequencies 1..8Hz. You have then to pass Input Buffer array of 16 float numbers. Then, you have to prepare memory for Output Buffer: it'll be array of 16 float numbers. FFTW works like this:

    retrieve/malloc Input/Output buffers

    select PLAN you want to do (as for us it'll be fftw_plan fftw_plan_r2r_1d(int n, double *in, double *out, fftw_r2r_kind kind, unsigned flags);

    execute PLAN

    free memory

    When you execute plan, your Output array will be probably populated with such points ( x(n) = amplitude at n Hz freq):

    x(0), x(1), x(2), x(3), x(4), x(5), x(6), x(7), x(8), x(-7), x(-6), x(-5), x(-4), x(-3), x(-2), x(-1). So get rid if last 7 elements and you get what you're interested in.

    If XAudio2 would have "get pointer to buffer" expression, then everything should be all right. And if you're going to make 0..20kHz in few bars like in Winamp, you'll have to sum/average parts of array.

  • The best way to implement this would be via a custom XAPO effect in XAudio2. You could probably get it working with FFTW. I might get round to it, but it's a bit of a gimmick really.

  • If XAudio2 would have "get pointer to buffer" expression, then everything should be all right. And if you're going to make 0..20kHz in few bars like in Winamp, you'll have to sum/average parts of array.

    BROO: What are the minus frequencies representing :o? I don't quite get why does the function return those also.

    I just began to wonder if it is possible to combine the frequencies afterwards and input them back to XAudio2 :D. I was thinking some kind of controllable equalizer...

  • I don't have that much theorethical knowledge, but I know that negative frequencies don't have representation in real world, althought they're part of it. If you think about electrical stuff alternating current: it has its Real and Imaginary part. Only te Real part is useful, but they both are vital to describe the current.

    Similar situation is with FFT. Normally FFT algorithms does output array of Complex Numbers (this conversion I shown in 3 posts above is shortcut: Real->Complex conversion and Complex.Abs() conversion put together). You can do IFFT (Inverted FFT) only when giving output array of Complex Numbers containing both positive and negative frequencies.

    To put it simply: negative frequencies aren't useful for you, but when trying to get FFT^-1 function, you need them.

    [quote:30aw7lup]I just began to wonder if it is possible to combine the frequencies afterwards and input them back to XAudio2 . I was thinking some kind of controllable equalizer...

    IFFT would theorethically do that (available in FFTW as well). Anyway I haven't seen anybody implementing such functionality.

    Edit:

    ...Well actually Winamp's Eqaualizer does something like this ^^.

  • I just began to wonder if it is possible to combine the frequencies afterwards and input them back to XAudio2 . I was thinking some kind of controllable equalizer...

    There is a built-in four-band equalizer in the XAudio2 SDK, but I haven't got round to adding any effects to XAudio2 yet. Do you think I should add it?

  • Well I think that basic equalizing would be cool effect, and very useful for mood changes in the background voices/music. If it isn't huge trouble to add, go ahead! At least I would appreciate it :)

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