Record buffer and apply FFT
-
@Christoph-Hart What would be your approach with Hise to record inside a buffer and perform an FFT?
The final goal would to search for peak frequencies and display the spectrum -
@ustk how long to you want to record? If 65536 samples are enough you can just use a oscilloscope node that you set to 65536 (I think this is the limit for the ring buffers), then you can always query the last 2 seconds (and if you want to explicitely record a time interval you could bypass and unbypass the node).
Then there is a FFT object that you can use in HiseScript to perform the FFT.
-
I've fixed a few things and added some safe checks so make sure you're using the latest HISE build when testing this example:
HiseSnippet 2557.3oc2YstaabbEdojW2RFW25hffh9qABEHjEJLjJ1x1MnH5JsUikMqn7EzfTig6NjbhVNy1cFJIl.Cze1Gi9H0Gg9HjGfB39clYWxkzxBNBsFMU+PVyYlyk46bcV2MSGILFcVPkpGOMUDT4Fg8lpri1cDWpBNXOPOrSmi2SLVGryzTtwHhCpTY0GPaWo50Bb+78ewN7DtJRLmTPvyzxHwijik14T6t0WJSR5viEGKGW5z2dqChzpc0I5IvTVMrUPJO5D9Pwi4zwVILnx02OVZ0Y8rbqvDT4Z6nim1aj9Lk+7OSZj8SDzh1A8ff7j6nShIKlnFr6HYRb2hqrIHnRX24.vpd.3CCOTFKmQeNP7KbavlyQY7nxJKZdqtf40tr40pj4cAlTkRlz07lzsB6EkISsy2grmOH7.kUjMfCXuro3OavJ+qpg6pwIT1li4mH5jgEy3n9lsZsNC+pwmWqFfdikcJOiEm1h86YtHflCE18jlzD9zclLXfHqG7Mfw07xm04EsWCLWlWvJDvavX8kTBhmdYuC9S6iieu12eCmL76b31u3kOZ+G+fieH1ay6bmOaSv3m9oLx9YlIYBlcjfkIUCY8chlIMLtg0WNj9mTswgx0hSaZD1iv47V..tTQlUJL0+tZL1ZdpORnFZGs1uqjZWm18wSFCutRIRLXyMp8pFdqHJS.mKiSW.lt+2HhrktUCFXgQuuZnTIZ5OJNW8bdg43r8yjpX8YLK7q0.GjY9bGIxSWmnrSBh7GyUOjmkIMKwt9TQVBOkU+LAKVq9XKSIDwyHORjIZTH2m3IVuUyV4R4OLA1Jr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hxUVtoeyOHrG7Wtuukya8Qt0rmitfrGHTzm2Pm09R9Rm+i20uzY567W5z2D9XzqzjpMKH3dhwxiw.KlxDotZXnTWKzxz2Esytvs99unCtjWHO831IYtLjhf+RU3W8x9hqsuhew0q8+bew0eDzGeglTUKrwdRJ8ce0ohDJymrweYX93WETWLV9PsRWT8ati9HQ9S5Ja6W3EZaqEyuMmxGt0QhDAubP6uYqGgfMd1gtpXWIrn8O3OP9E5u9UgdykQIfre7N+0p+e87WuWFn38gNFyixzuLxOGFEm9ScTv8V49+vpZ3gzZV6fS8c0BoYUBFiJbuLJhf3OAELuXd13JvymcE341WAdtyUfmMuB7b2q.O26R4gZtr8D7NVeJGHzce+vLU1WwQzqKRO3eCArQitB
The snippet has an oscilloscope in a scriptnode FX and a button that will analyze the last two seconds and prints out the frequency of the FFT bin with the highest magnitude. There's also a sine generator and when you press a note, it will print its frequency (so that you can confirm that the pitch detection from the FFT works correctly).
This is the relevant script part:
const var dp0 = Synth.getDisplayBufferSource("Script FX1"); const var dp = dp0.getDisplayBuffer(0); const var FFT_SIZE = 8192; cont var MAX_LENGTH = 65536; // make sure the ring buffer is as big as possible dp.setRingBufferProperties({ "BufferLength": MAX_LENGTH, "NumChannels": 2 }); // create a FFT object const var fft = Engine.createFFT(); // set the window type fft.setWindowType(fft.BlackmanHarris); // set the overlap (we don't need overlap here) fft.setOverlap(0.0); // Just converts the binIndex to its center frequency using the samplerate // and the FFT size. inline function binIndexToFreq(idx) { return (idx / FFT_SIZE) * Engine.getSampleRate(); } // set a function that will be executed with the magnitude information // for each slice. The function needs two arguments, the first holding // either a buffer or an array of buffers (for multiple channels) with // the magnitude information of each FFT bin for the given slice which // is determined by the FFT processing size and the overlap factor. // The second parameter will be the offset in the original buffer // the bool parameter will decide whether the magnitude should be // provided as (normalised) value or converted to decibels already fft.setMagnitudeFunction(function(magBuffer, offset) { // get the bin index with the highest peak var thisPeak = magBuffer[0].indexOfPeak(); Console.print(binIndexToFreq(thisPeak)); }, false); // now we can call prepare so that the FFT object can initialise all // required buffers. fft.prepare(FFT_SIZE, 2); // We'll create two buffers that we'll copy the read buffer to when // the button is pressed const var recordBuffer = [Buffer.create(MAX_LENGTH), Buffer.create(MAX_LENGTH)]; inline function analyse() { // Copy the buffer using the thread safe copy method dp.copyReadBuffer(recordBuffer); // process the buffer with the FFT object. This will repeatedly // call the magnitude function we specify with slices of the // source input so we can analyse it and perform whatever we // want to do fft.process(recordBuffer); }
-
@Christoph-Hart Oh ok so it's safe to do this way then (regarding the data being raw enough)
I remember not being successful at using the script FFT in the past (I don't know if it was broken or if it was just me being not smart enough to use it...). In the current project I record a predefined buffer length inside the processBlock of a scriptFX, that seems to work well enough (no need for FFT in this one) but I wanted to try a different approach for the next one.
So if I want the FFT then I could query the ring buffer of an FFT node at the same time than the ring buffer of an Oscilloscope, right? But how can I be guaranteed they are synchronised on the same chunk of data?
The issue with that technique though is that the duration is samplerate dependent, so I might go for the processBlock + FFT script if I always want 2-4 seconds for instance (which would be approximately what I need indeed)
The end goal is to get an FFT average on 2-4sec audio, and a spectrum with a smaller window size (probably in the 32-1024 range)
-
@Christoph-Hart Oh just seen your proposition while posting! Thanks I'm trying this ;)
-
@Christoph-Hart That is very interesting because in the end I want to detect the more prominent frequency spikes
-
If you need this to work with other lengths than 65536, you need to record the buffer manually in the process block:
HiseSnippet 1848.3oc2Xz1aaba9NaeESWy5VGJFZ2m3BFPk2bT0klkWpQRc7KJyHwIBQtIAqnsi5tGoiMmHuQxyNZAFX+D2Ok9OH6gjmj3Yq345sErNAXCwm24y6T8khTPoDxfvVGNsDBBuRzfobc9N4TFOX+cCBiiFPOBNDT5fsmVRUJHKHLb0GXvG1Zs.6me3K2lVP4ovBPAAOSvRgGwlvzKf1eqGxJJ5QyfCYS7n9FasepfuinPTg1xpQcCJooujNFdL0P1JQAgu2dYLsPNPS0fJHbssEYSGjKNl6n+YLEaXAXNjDL.EjCbOQQlwhMPC1ImUj0e1cVEDDF0egGXUmG3ihNfkwlCeg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big buffer so that I don't have to iterate over each sample in the processBlock method (which is super slow). -
@Christoph-Hart Yeah that was kinda what I was doing withe the processBlock, except that I am iterating over the samples using a loop. A design I don't like much so the buffer reference is way better :)
-
@Christoph-Hart These snippets are full of some seemingly forbidden HISE magic.
I'm trying to put together your two snippets here
HiseSnippet 2593.3oc2Y01aabbD9njufPF2zlhfhh9osFEvjsJzjJt9kJXGY8BcTikkpIisQBRcWd2Rdazwcub6dRh0P.4mX+IzeB4ef6L6t2aTzxNpsFMUePP6Kyry9Lyryyb5vTY.SojodMZNZdByqwU8GNWni1NhxEd6siWiV9CoGyFwTZuslmPUJVnWiFq9Pb8FMuhm4me3y1hFSEArxo77dpjGvdDeFWWN6ga9E733AzP1H9rJ69latWfTrsLVlA1xp987RnAGQmxdLE21J9dMducC4ZY5PMUyTdMtxVxv4CijmHr6+obEebLCGz2aHnH6zCjwgnEiy5scDON7v76rxyqg+gkHvpVD3i82mGxKluDI9ElEHkRTEOZrRcya0ZlW+plWuJl2RLoFULoqXMoOxeXPJOQWtBZOef+dBMKcBEf8plhcudq7cuu+1RXGBc2YziXCRgAERz9V85sFA9UmMZ0BfdkljxBjogakMYBKcH+uyH2irqXJWv5NkoGRmkDydBb4Z2g76IeZOProwxwzXTNqPJPhulX+6tAoLbyKpzNq0pI9C4MsuuYCbiUNCX48DgrSgC4S5uApgVsZcLMkLgmpzVIg0JslutGni7KGtwACF8hg68U6B65N8u65vh23FD64Sn3pD43ukEnqHxjI5RXvtUXes6XkUwzDcDibBWDJOgnAmUKPhtv7OyLE59ZiyrULDNOiJ9bZZJWsf3xiYowzDR6SXjPo35ZhfwBKlNhkx5jq2CrS1tW2dNs7my.aErXXAsxnuwbgEozRBGlKfgdcxjT12kwDAyIYJtXpYqJiaMEtVnpnhPyrHTn.mP2VbQLbyISxDAZtTTn5QxAf1ZyCOsSqW1pYJSmkJH3XxMJvYLPY4QPaz5rBDfVpccDUCfYbLYLivNkEjoAb3DtNxXVynSEbcVHivESjoynnPnZfADF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a6GKN4s9iEaYcNBXGpRjpZJdHaFeDP+VUcRjGGjTZHMVc9sABbKcoe3yF.WxkJyPJ7nlIO+AyjYBcMBKqdQez59WxOZ8U9etOZ8OAnkViyUybabHGeIYWwwrXHWvXi+ReWCG4yVOVdeoPlDIE7fpN5mvfT3oSYoUs8kdgdfVCcrTNyGu4SXwLZ0f1e2lOBB1noX+JWRrn+OZ9mK0e8q8slKAS.I+zschU++51IdmTG4cwYLiFjJeQfs7KFm99lYf6sv7uAro+93XReOSI4p9xYvqbuHHntpNmfqeYE7SurBdyKqf+wKqf25xJ3surBdm2rfXQnGjok1+QHvF1+vcMrQZzXWAEhxMYDd+K.GruEgC
Play a note, click and hold the button, release to analyse. The longer the hold, the longer the log , but it's always zeroes after a few entries with correct data.
Just like the OP, I would want to record for up to 10 seconds, then be able to analyse the spectrum: am I assuming correctly that 8192 size is the "resolution" of the spectrum? each of these is then a frequency point, no? I'd like to be able to get the gain in dB for all of these points, but across the entire capture. So, an average.
Would I just store data from the magnitude function, then average it?
How big are the chunks that the magnitude function is processing? Is it 8192 samples, if that's our FFT size?