Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Recording audio from android device
Qt 6.11 is out! See what's new in the release blog

Recording audio from android device

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
11 Posts 2 Posters 5.6k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi and welcome to devnet,

    You can use QBuffer as output for your QAudioInput recording.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    1
    • F Offline
      F Offline
      fkop
      wrote on last edited by fkop
      #3

      Thanks,
      but i have another problem. I am trying open a device for Read mode, because i need to read data from device to buffer and then write them to file. I want to check that buffer really record audio.

      e.g. - qio->read(buffer.data(), size); - i hope this command is ok
      but - idk what have to be in bracket - if (qio->open(...) == true) - qio is name of QIODevice object

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Then why not write directly to the file ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fkop
          wrote on last edited by
          #5

          Because I need do fft from the audio signal and I don't want do it from file, but from memory.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            What is qio supposed to be ?

            Depending on your needs you can also simply work with the QIODevice created when calling start. You can then connect the readyRead signal from said device to your processing function and write the result to the file you want to create.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fkop
              wrote on last edited by
              #7

              qio is QIODevice object,
              I guess my problem is, that I don't know which "openMode" is used. I tried print number of mode, but i don't know, how to print it :-).. I tried qWarning, but it just print text and std::cout not run.
              My command was: qWarning << qio->openMode(); In documentation is written, that method returns which device is opened.

              Here is similar example:
              QAudioInput *m_audioInput;
              QIODevice *m_input;
              QByteArray buffer(262144,0);

              m_audioInput = new QAudioInput(m_format);
              m_audioInput->setBufferSize(262144);
              m_input = m_audioInput->start();

              qint64 bytes_ready;
              qint16 *ptr = new qint16[262144];

              bytes_ready = m_audioInput->bytesReady();
              m_input->read(buffer.data(), bytes_ready); - - My problem. In my opinion, here is device sets as Not opened.

              ptr = reinterpret_cast<qint16*>(buffer.data());

              1 Reply Last reply
              0
              • F Offline
                F Offline
                fkop
                wrote on last edited by
                #8

                My situation is, that I need record audio signal from device to buffer. Then i must do 50% overlay of signal for FFT. After I do FFT, I must count MFCC and send it somewhere. For FFT and MFCC I have prepare libraries. So I just need arrays with 50% overlay.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  From your code it seems that you are trying to read from the input directly after opening it. That's not how it works. Connect the readyRead signal from the device you received to a slot from your class where you'll read the content that is available and then you can further process it to your needs.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • F Offline
                    F Offline
                    fkop
                    wrote on last edited by
                    #10

                    Is there any option, that i get same count of samples in every calling of slot. I need 50 % overlap, so if count of samples were pretty aligned, it would be nice of Qt.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      IIRC with the defaults you get a pretty regular number of samples.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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
                      • Unsolved