Create a Flash Equalizer (change the output sound)

Hi, he would like to know if it is even possible to create a “parametric” equalizer in flash. Not only regular graphic effects, but also a tool for changing the output of sound passing through the application. Any recommendation, hint idea is welcome. Thanks

+3
source share
5 answers

It won't be terribly easy ... but there could be a way:

var parameters:Array = [1,1,1,1,0.5]
var sound:Sound = new Sound();
sound.addEventListener(SampleDataEvent.SAMPLE_DATA, filter); 
sound.load(soundURLRequest);
sound.play();

private function filter(event:SampleDataEvent):void
{
    var freqDomain:Array = FFT(event.data, parameters.length); // You will need to find a FFT(Fast Fourier Transform) function to generate an array. 
    for(var i:int = 0; i < freqDomain.length; i++)
    {
        freqDomain[i] = freqDomain[i] * parameters[i]; // This is where your EQ parameters get applied.
    }
    var timeDomain:Array = IFFT(freqDomain, event.data.length); // Inverse FFT

    for(value:Number in timeDomain) 
    {
        event.data.writeFloat(value);
    }
}

FFT IFFT, FFT ( + ), . , = (sqrt (real ^ 2 + complex ^ 2)). ​​ ( , ), , , . , .

( Fast, (O (n ^ 2)) vs FFT O (nlogn)) (.. , ):

// Note that this only returns the magnitude, I am discarding the phase.
function FFT(sample:Array, size):Array
{
    var frequencies = new Array(size);
    for(int i = 0; i < sample.size; i++)
    {
        for(int j = 0; i < frequencies.size; j++)
        {
            var real:Number = sample[i] * Math.cos(Math.PI/2 * i * j);
            var complex:Number = sample[i] * Math.sin(Math.PI/2 * i * j);
            frequencies[j] += Math.sqrt(real * real + complex * complex);
        }
    }
    return frequencies;
}
+6

Andre Michelle labs. Flash... , . , , .

+1

, - . FFT, , / . , , . .

There is a free book on digital filters , which has some basic theory, but where you can also just scroll and select formulas. For example, a quick reading of chap. Listed in Figure 19 are simple formulas for recursive filters with top, bottom, and band passages that are likely to do this trick, but if you want to become more attractive, there will be many other filters in the book.

0
source

Source: https://habr.com/ru/post/1712119/


All Articles