Spectral Analyser / Ever made one?
-
Does anybody have any good advice on where to start making a spectral analyzer? I just want to be able to load an audio file and point out dominant frequencies in the spectrum and extract frequency values.
Something like this :
-
@Chazrox If it's not real time, then the FFT in the API list should do it. Otherwise it needs C++ and a global cable to send the data back to the interface
-
@ustk yup offline spectrum generation can be done with the inbuilt HISE tools:
Content.makeFrontInterface(600, 600); // Create a buffer with a second length const var b = Buffer.create(44100.0); // fill it up with some random signal - two sine sweeps and some noise reg uptime = 0.0; reg delta = 0.01; for(s in b) { s = Math.sin(uptime); s += 0.5 * Math.sin(uptime * 2.0); s += 0.3 * Math.random(); uptime += delta; delta += 0.00003; } // Create the FFT object that is used to create the spectrum const var fft = Engine.createFFT(); // Enable the spectrum generation fft.setEnableSpectrum2D(true); // Setup the FFT processing (FFT size & channel count) fft.prepare(1024, 1); // Fetch the spectrum options const var options = fft.getSpectrum2DParameters(); // Dump that Console.print(trace(options)); // change whatever property you want. options.ColourScheme = 2; options.Oversampling = 8; options.Gamma = 30; options.ResamplingQuality = "High"; // Send it back fft.setSpectrum2DParameters(options); // process the buffer. This creates the spectrum // that can then be painted fft.process(b); // create a panel const var p = Content.addPanel("P1", 0, 0); p.set("width", 600); p.set("height", 600); p.setPaintRoutine(function(g) { // This function paints the FFT spectrum on the panel g.drawFFTSpectrum(fft, this.getLocalBounds(0)); });
-
@ustk for my purpose it wouldn't have to be real time. I'll look into it. Thanks!
-
@Christoph-Hart woah! I cant wait to try this! Thank You!
-
@ustk Do you have a basic example of this you can share? I dont think im aiming for "real time" in a sense that these values have to be calculated during playback. Im guessing I want to use Scriptnode to build some chain but this is new territory for me so im not sure what modules are needed. I can guess that I probably need an audio file drop window that feeds it to an audio player, but thats as far as I can see at the moment. I can explain the logic, but Im unfamiliar with the implementation.
HiseSnippet 1825.3oc0XstaaaCEVJIJcwsaXcnXX+ZfHXXPoKyUJNIKEAEMWcavZR7hcS6+Jnkns3hDolHUb8F5+2azdM1iReC1NjTxVt0MKyqs.yAHw7bg76b34F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W4XfKRkYh9ubu8QML6JmzY9q0jNu2w6rO0y6Gn7wnW+GiyHAGjweQfYDIUr7mno.1MS2.dImiUqQ9VWZ5YN9NNApJ9hffI2p2Rw0lUEaLqJt9rp3FyphaNqJ9Cypha8Oqnpo0t4RdhIk0x53VGpGkw117uRRmcX82PtAWoA
The analyser shows the signals that @Christoph-Hart baked into it, how do I feed my own information into this script?
-
@Chazrox Scriptnode is not necessary if you don't go real time, so Chris's example has already (almost) what you need.
Ok you want to display an FFT, but from what source? sampler? internal AF? user drag/drop AF?
You must start here, then it'll only be a matter of getting a reference of that AF and feed the buffer.Here's a starting point
inline function onButton1Control(component, value) { if (value) { FileSystem.browse(FileSystem.Desktop, false, "", function(result) { arrayOfBuffers = result.loadAsAudioFile(); // do fft with this array of buffers }); } }; Content.getComponent("Button1").setControlCallback(onButton1Control);
-
@ustk Thank You
Im going to script a custom drop panel that will feed an audio file into an audio player. Atleast thats what I think I should do? Then run your script either in a button or inline my DROP script to run automatically. Am I right so far with using an AudioPlayer for that?..because I know we can just read the file AND load the audio file for auditioning at the same time, right?
-
@Chazrox no need for a audio player for a simple playback you can just use Engine.playBuffer()
-
@Chazrox Yeah AFs in Hise can be fetched from anywhere, AudioPlayer, Scriptnode, Sampler, etc...
The methods can differ but I imagine there are some examples in the doc and the snippet browser -
@Christoph-Hart hmm! I def have some reading to do. This is exciting. Anything you can recommend I read in documentation?
@ustk speaking of 'methods' im investigating and got these...
{ "normalise": Method, "toCharString": Method, "detectPitch": Method, "indexOfPeak": Method, "toBase64": Method, "fromBase64": Method, "getMagnitude": Method, "getRMSLevel": Method, "trim": Method, "getPeakRange": Method }
All new to me but looks promising!
I have no idea what "Method" is referring to tho. Never seen this before.
-
@Chazrox start from here:
-
@Christoph-Hart Thanks! Reading that now.
-
Sorry if this is an irrelevant question, but how can we use this with online processing?
For example, online pitch detection?
-
@resonant i'd like to know that too haha.
-
@resonant do you already know how to do offline analyzing?
-
@Chazrox said in Spectral Analyser / Ever made one?:
@resonant do you already know how to do offline analyzing?
No I donβt know how to do that. But Iβd really like to know real time spectral processing with Hise.
-
-
@griffinboy Can you suggest any reading material on DSP/C++ coding? I'd like to start studying that as well!
-
Honestly I've never read any! I learnt by jumping in the deep end.
Snex is almost c++
I recommend looking at the waveshaper snex nodes on the forum and asking chat gpt to explain what's happening in the code until you understand it.
That's how I got my start.That, or you could watch my old not-that-great Hise c++ video, if you want to jump right into hise c++ dsp.
(Windows only sorry, I do plan on doing a series on this at somepoint for both platforms)[Tutorial] How to create a c++ custom node
How to create a custom node, as promised. I apologise in advance for the awful quality video (quite dry and boring)! But the good news is that I have some ni...
Forum (forum.hise.audio)
For general reading material, I've never read any. I jumped straight into reading the latest papers on the area I was interested in, circuit modelling.
No matter your area of interest, I recommend making waveshaper distortions for starters. It's a simple dsp concept and it'll get you to grips with almost every aspect of making dsp as you progress to the more advanced shapers that contain filters etc.