HISE Logo Forum
    • Categories
    • Register
    • Login

    Spectral Analyser / Ever made one?

    Scheduled Pinned Locked Moved Scripting
    17 Posts 4 Posters 114 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ChazroxC
      Chazrox
      last edited by

      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 :

      Screenshot 2025-08-13 at 11.47.18 PM.png

      ustkU 1 Reply Last reply Reply Quote 0
      • ustkU
        ustk @Chazrox
        last edited by

        @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

        Hise made me an F5 dude, browser just suffers...

        Christoph HartC ChazroxC 3 Replies Last reply Reply Quote 1
        • Christoph HartC
          Christoph Hart @ustk
          last edited by

          @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));
          });
          
          ChazroxC 1 Reply Last reply Reply Quote 5
          • ChazroxC
            Chazrox @ustk
            last edited by

            @ustk for my purpose it wouldn't have to be real time. I'll look into it. Thanks! 🙏

            1 Reply Last reply Reply Quote 0
            • ChazroxC
              Chazrox @Christoph Hart
              last edited by

              @Christoph-Hart woah! I cant wait to try this! Thank You! 🙏

              1 Reply Last reply Reply Quote 0
              • ChazroxC
                Chazrox @ustk
                last edited by

                @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.yAHw7bg76b34FSqLd.QH3YV105LLkXYeKm1CYxn8ivTl0QGXY+0Nm18mIARzwXFMMOFKobFpUFNPRCHV6MLEKDjPKa64ejRG6kVvR+40ObObLlAxLhjk04bPomPSnxwTasyORiiahCIcnIUjd8cNJfy1mGyyA7MuimUJN3BbexIXkXy4X8XrHxx9tNqsVufs771pQiM7v3FgX759jF2mzaydAa3ceuvta3A+rok8hGFRk7r1RrjHrrWXOd3v1Q7ALyAbNUP6FSTK7sZCmrgbSdbnxDUTs1OhFG1pzwIrrrcZM1MNuwMdGmiogzQzG6N+bMCzXMp5.smaR3M+DvyuJ77p.uo.I6JPZACjtsS6fLZpbLGEdtoyQLIIqG9MtKMxZM2e33rOGjfIqmfufzLCVLRC2M87VEA+ZksqU6d2CseFA.NBi5l2qGICMfJifUBBbOFhhIr9xnZv2ERzk3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D0749SaXF6e2oRcASanN7Vw3gt5Ztjy.LtJpaLO3h1P+q2Nqqnr2dJIbK5sIlkjyEu1dE+q9RwTFrOLrQFUkcbRdRanOT.Y+BzoRTTIBEq8JSbTsQzK9K3SASe0Z6Bl9kLqjdeBAF2J6B80Qw2srugw2KzN4Wz6k9V6FGyGnRpoEQovcflVKd7vzHNiFnHYjnDo6lnlQnDtvn8cvzXUXc6bnnMK7TVaPX86Irm+bnAmdiugCL5TcvPl6DdHvZwlvCS3YCagUkEtsipdFDbpFwbTP5DXsZbh4gESvVsqkOAw33.TmnKUAO.wd9J02Lgn54C.llC5Hw4JtP2CqyUg.J6Qum5DpQ8pgE6w4Wjf091YpJZ0zyOyv7lNsAKW+dNsc+k50nmgujfdjYVOdl+U7Dt+759Dtzq8S3NMPBGeGXtXQJWLwF2ljP6.sADUI9TA7lCxublJNpJ8843rox50OrIXjSUm1XYtY91xXsJkIm+pdY36LibxNFUjeJEvV3C0yDW35US8peE6+C5RNQKfkJwXappz8grKIwPRhFieAjUzCmGKKoNYP9wbFurJz3HfyHPIz98IYUw9TMnckRX16wTtyNmQhI3pQyeyNOAhBwYGqKJMS9B++0sCm580W4XfKRkYh9ubu8QML6JmzY9q0jNu2w6rO0y6Gn7wnW+GiyHAGjweQfYDIUr7mno.1MS2.dImiUqQ9VWZ5YN9NNApJ9hffI2p2Rw0lUEaLqJt9rp3FyphaNqJ9Cypha8Oqnpo0t4RdhIk0x53VGpGkw117uRRmcX82PtAWoA
                

                The analyser shows the signals that @Christoph-Hart baked into it, how do I feed my own information into this script?

                Screenshot 2025-08-14 at 11.59.15 AM.png

                ustkU 1 Reply Last reply Reply Quote 0
                • ustkU
                  ustk @Chazrox
                  last edited by

                  @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);
                  

                  Hise made me an F5 dude, browser just suffers...

                  ChazroxC 1 Reply Last reply Reply Quote 2
                  • ChazroxC
                    Chazrox @ustk
                    last edited by Chazrox

                    @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?

                    Christoph HartC ustkU 2 Replies Last reply Reply Quote 0
                    • Christoph HartC
                      Christoph Hart @Chazrox
                      last edited by

                      @Chazrox no need for a audio player for a simple playback you can just use Engine.playBuffer()

                      ChazroxC 1 Reply Last reply Reply Quote 1
                      • ustkU
                        ustk @Chazrox
                        last edited by

                        @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

                        Hise made me an F5 dude, browser just suffers...

                        1 Reply Last reply Reply Quote 0
                        • ChazroxC
                          Chazrox @Christoph Hart
                          last edited by Chazrox

                          @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.

                          Christoph HartC 1 Reply Last reply Reply Quote 0
                          • Christoph HartC
                            Christoph Hart @Chazrox
                            last edited by

                            @Chazrox start from here:

                            Link Preview Image
                            HISE | Scripting | Buffer

                            A buffer of floating point data

                            favicon

                            (docs.hise.audio)

                            ChazroxC 1 Reply Last reply Reply Quote 0
                            • ChazroxC
                              Chazrox @Christoph Hart
                              last edited by

                              @Christoph-Hart Thanks! Reading that now.

                              1 Reply Last reply Reply Quote 0
                              • resonantR
                                resonant
                                last edited by resonant

                                Sorry if this is an irrelevant question, but how can we use this with online processing?

                                For example, online pitch detection?

                                ChazroxC 2 Replies Last reply Reply Quote 1
                                • ChazroxC
                                  Chazrox @resonant
                                  last edited by

                                  @resonant i'd like to know that too haha.

                                  1 Reply Last reply Reply Quote 0
                                  • ChazroxC
                                    Chazrox @resonant
                                    last edited by

                                    @resonant do you already know how to do offline analyzing?

                                    resonantR 1 Reply Last reply Reply Quote 0
                                    • resonantR
                                      resonant @Chazrox
                                      last edited by

                                      @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.

                                      1 Reply Last reply Reply Quote 0
                                      • First post
                                        Last post

                                      22

                                      Online

                                      1.9k

                                      Users

                                      12.3k

                                      Topics

                                      107.0k

                                      Posts