Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Spectrum analyzer demo, the HZ is 0 ~ 1000, how to change this?
Forum Updated to NodeBB v4.3 + New Features

Spectrum analyzer demo, the HZ is 0 ~ 1000, how to change this?

Scheduled Pinned Locked Moved General and Desktop
21 Posts 5 Posters 9.1k Views 1 Watching
  • 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.
  • X Offline
    X Offline
    xhsoldier
    wrote on last edited by
    #10

    Yes. I change all the value.
    SpectrumNumBands is the 10, that's fine for me.

    when I debug I notice that all the frequency will result a bar index, either 0 or 1.
    So I think there may be a bug in the Spectrograph::updateBars()

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #11

      I can't help on that. You'll have to check the sources. They seem quite simple to me.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • G Offline
        G Offline
        grisza50
        wrote on last edited by
        #12

        I have the following :

        Where exactly in spectrumanalyser demo is a code for getting the RAW PCM data from .wav file? and how to use this demo's functions to get it.

        i'm working on sound processing system and i'm new with qt.

        I would be grateful if someone could paste small example how to do get pcm data ;)

        thanks for your reply ;)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          shoyeb
          wrote on last edited by
          #13

          hey can you please elaborate your problem this way we cant help u out be specific with your problem....

          then only we can help you...

          There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            grisza50
            wrote on last edited by
            #14

            thanks,
            Ok, so I want to open the .wav file, get audio (PCM) data, and do some signal processing using external library (for example mel-cepstrum coefficients analysis)
            so i open the wav file using:
            @showFileDialog(){
            }@
            this function calls m_engine->loadFile(fileNames.front()); function
            In next step i would like to create the buffer/vector for audio data and write this data to it and then analyse them. I don't know how to create this buffer and get the pcm data.
            i look for adequate functions and find this:
            @if (m_file) {
            m_file->seek(0);
            m_bufferPosition = 0;
            m_dataLength = 0;
            if (isPCMS16LE(m_file->fileFormat())) {
            result = initialize();
            }if(m_spectrumAnalyser.isReady()) {
            m_spectrumBuffer = QByteArray::fromRawData(m_buffer.constData() + position m_bufferPosition, m_spectrumBufferLength);
            m_spectrumPosition = position;
            m_spectrumAnalyser.calculate(m_spectrumBuffer, m_format);
            }@
            so i see that i have to get some kind of m_buffer and m_format from .wav file and i don't see the proper way to do it. It would be great if someone could paste some simple code with solution to open .wav file, creating the buffer, getting the necessary parameters from this file (for example number of samples, m_format?), writting pcm data to the buffer, and how to read this data. In MATLAB there is wavread function for reading this kind of data.
            thanks for your reply ;)

            1 Reply Last reply
            0
            • S Offline
              S Offline
              shoyeb
              wrote on last edited by
              #15

              spectrum analyser is having that functuionality u dont have to write anything for that...

              when u say,

              @result = initialize();@

              this method automatically initialises tha m_buffer and m_format..

              check it properly..

              There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                grisza50
                wrote on last edited by
                #16

                Thank you shoyeb ;)

                ok, I created the pushbutton and and i want to calculate the spectrum of 30000 us with step of 10000 us. how can i set up this values for my use?
                I connected my slot to this button and this work properly spectrum. How to enable that the spectrum is calculated only if the position of calculating is less than the signal? - my program is still crushing after a few click ;(
                @my function{
                if (isPCMS16LE(m_file->fileFormat())) {
                result = initialize();
                }
                if (m_file) {
                m_file->seek(0);
                m_bufferPosition = 0;
                m_dataLength = 0;
                }

                        //bufor itd
                        if(m_spectrumAnalyser.isReady()) {
                            m_spectrumBuffer = QByteArray::fromRawData(m_buffer.constData() + classify_position - m_bufferPosition,
                                                                       m_spectrumBufferLength);
                            m_spectrumPosition = classify_position + 10000;// step of windowing
                
                            m_spectrumAnalyser.calculate(m_spectrumBuffer, m_format);
                

                }
                }

                @ how to initialize m_spectrumBufferLength and position to the values i mentioned?
                and where/how i can add spectrumanalyser functions to calculate the spectrum only if the position is less than duration of signal?

                please help me

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  shoyeb
                  wrote on last edited by
                  #17

                  in engine.cpp file on top there are two constants..

                  @const qint64 BufferDurationUs = 1 * 1000000;
                  const int NotifyIntervalMs = 10;@

                  where first value is amount of data to be processed in microseconds and second one is to set the notify interval, watever value u set in notify interval after that duration only ur data processing is done...

                  m_spectrumBufferLength is fixed and its value is initialized in utils.h or utils.h u dat can check ...

                  There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    grisza50
                    wrote on last edited by
                    #18

                    and how can i add the functionality of computing spectrum only if the position of computing is less than duration of whole signal,

                    or mayby how can i get the info about duration of whole signal (in microseconds or sample number )?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      shoyeb
                      wrote on last edited by
                      #19

                      the first line tells you the duration of entire signal i.e

                      @const qint64 BufferDurationUs = 1 * 1000000;@

                      this tells that the duration of entire singnal is one second...

                      There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        grisza50
                        wrote on last edited by
                        #20

                        yes, but i mean not recorded signal but opened and played wave file, how to obtain this information.
                        thanks

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          shoyeb
                          wrote on last edited by
                          #21

                          check this...

                          @if (isPCMS16LE(m_file->fileFormat())) {
                          result = initialize();@

                          and

                          if (result) {
                          m_analysisFile = new WavFile(this);
                          m_analysisFile->open(fileName);
                          }

                          There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved