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. Qt real time audio processing
Forum Updated to NodeBB v4.3 + New Features

Qt real time audio processing

Scheduled Pinned Locked Moved General and Desktop
16 Posts 3 Posters 7.5k 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.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by
    #4

    Ok, so the signal is connected to the slot successfully.

    [quote author="andrea993.93" date="1314450880"]
    I have declare these objects:
    @QAudioFormat audioformat;
    QAudioInput *input;
    QIODevice *intermediario;
    QByteArray buffer;@
    [/quote]
    The only explanation I would have now is that these pointer are destroyed when you are exiting one of your methods. You might want to check this. Furthermore, you can check the "state":http://doc.qt.nokia.com/4.7/qaudio.html#State-enum of your audio input.

    Vote the answer(s) that helped you to solve your issue(s)

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andrea993.93
      wrote on last edited by
      #5

      these objects
      @
      QAudioFormat audioformat;
      QAudioInput *input;
      QIODevice *intermediario;
      QByteArray buffer;
      @
      are declared out of methods; every method can access them

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koahnig
        wrote on last edited by
        #6

        Did you check the state of your audio stream ?

        [quote author="koahnig" date="1314458762"]Furthermore, you can check the "state":http://doc.qt.nokia.com/4.7/qaudio.html#State-enum of your audio input. [/quote]

        You can do with "state()":http://doc.qt.nokia.com/4.7/qaudioinput.html#state . Also you can use "bytesReady()":http://doc.qt.nokia.com/4.7/qaudioinput.html#bytesReady for checking.

        Otherwise hopefully somebody with QAudio experience is picking up this thread.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andrea993.93
          wrote on last edited by
          #7

          I' ve looked the state.
          Just I set intermediario->start the state is actived immediately after the state begins stopped and then never return active

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on last edited by
            #8

            Sounds a bit that whatever you are opening to deliver the audio information does not provide any data. If you are reading a file, it may various reasons like file empty or wrong format.
            If you are using a device supplying the data, it is probably stopped or disconnected for any reason.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vidar
              wrote on last edited by
              #9

              You might take a look at "this thread":http://developer.qt.nokia.com/forums/viewthread/7679/ , i posted an example for doing audio processing there.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andrea993.93
                wrote on last edited by
                #10

                I had already read that thread, thank you...

                I tried to compile for windows and the connect work correctly but I need to compile for symbian.

                The slot "cattura()" is called all times when "intermediario" is "readyread()"...is it right?
                Then which is the correct value of "bytescatturati"?
                @
                qint64 bytescatturati=1000; //????
                @

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vidar
                  wrote on last edited by
                  #11

                  Well, let's take a look at the API Documentation of QIODevice ... ;-)

                  bq. void QIODevice::bytesWritten ( qint64 bytes ) [signal]
                  This signal is emitted every time a payload of data has been written to the device. The bytes argument is set to the number of bytes that were written in this payload.
                  bytesWritten() is not emitted recursively; if you reenter the event loop or call waitForBytesWritten() inside a slot connected to the bytesWritten() signal, the signal will not be reemitted (although waitForBytesWritten() may still return true).
                  See also readyRead().

                  and

                  bq. qint64 QIODevice::bytesAvailable () const [virtual]
                  Returns the number of bytes that are available for reading. This function is commonly used with sequential devices to determine the number of bytes to allocate in a buffer before reading.
                  Subclasses that reimplement this function must call the base implementation in order to include the size of QIODevices' buffer. Example:
                  qint64 CustomDevice::bytesAvailable() const
                  {
                  return buffer.size() + QIODevice::bytesAvailable();
                  }
                  See also bytesToWrite(), readyRead(), and isSequential().

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andrea993.93
                    wrote on last edited by
                    #12

                    I've changed the cattura() function:
                    @void MainWindow::cattura()
                    {

                    qint64 Nbytesletti;
                    qint64 i;
                    qint64 media=0;
                    qint64 bytescatturati;
                    
                    bytescatturati=intermediario->bytesAvailable();
                    
                    
                    if (bytescatturati>0)
                    {
                        
                        Nbytesletti= intermediario->read(buffer.data(),bytescatturati);
                    
                        for (i=0;i<Nbytesletti;i++)
                        {
                            media+=(qint64)buffer.at(i);
                        }
                    
                        media/=Nbytesletti;
                    
                        ui->label->setText(QString("%1").arg(media));
                    }
                    

                    }
                    @
                    But "intermediario->bytesAvailable()" return ever "0".
                    Why?

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      andrea993.93
                      wrote on last edited by
                      #13

                      I've try to monitor the QAudio::State and after "input->start()" the state is Idle.

                      Why?

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        vidar
                        wrote on last edited by
                        #14

                        have you read this?

                        bq. Symbian Platform Security Requirements
                        On Symbian, processes which use this class must have the UserEnvironment platform security capability. If the client process lacks this capability, calls to either overload of start() will fail. This failure is indicated by the QAudioInput object setting its error() value to QAudio::OpenError and then emitting a stateChanged(QAudio::StoppedState) signal.
                        Platform security capabilities are added via the TARGET.CAPABILITY qmake variable.

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andrea993.93
                          wrote on last edited by
                          #15

                          thank you very much.

                          But it does'n work with windows :(
                          First I want it work with Windows

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            andrea993.93
                            wrote on last edited by
                            #16

                            nobody can help me?

                            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