Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Audio samples don't work on Android
Forum Updated to NodeBB v4.3 + New Features

Audio samples don't work on Android

Scheduled Pinned Locked Moved Solved Mobile and Embedded
2 Posts 1 Posters 721 Views
  • 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.
  • M Offline
    M Offline
    Magnus21
    wrote on last edited by
    #1

    Hello, so my app records audio and does audio processing on it.

    It works perfectly on Desktop, but on Mobile I don't seem to get any correct floating point audio samples.
    I use a chart to show the value of all samples and the Android version seems to only receive values of value 0 and negative values, but nothing that makes sense.

    Here are screenshots of what I mean:
    Desktop screenshot
    As you can see, on Desktop the audio samples are good.

    However, on mobile I only get weird values (values <= 0):
    Mobile screenshot

    When I try the audio example app from Qt, that does similar audio processing, I get correct samples on Android as well. But this example app uses integer samples. I need the floating point samples though.

    Here is my code for setting up the audio recording:

    m_format.setSampleRate(SAMPLE_RATE);
    // mono sound
    m_format.setChannelCount(1);
    // aubio requires float
    m_format.setSampleType(QAudioFormat::SampleType::Float);
    // floats have a size of 32 bit
    m_format.setSampleSize(sizeof(float) * 8);
    m_format.setCodec("audio/pcm");
    m_rec = new QAudioInput(m_format, this);
    

    Any idea what could be wrong with floating point samples on Android?

    If you need the full source code, it's available here: https://github.com/magnus-gross/quickpitch

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Magnus21
      wrote on last edited by
      #2

      OK, I found the problem. Qt doesn't support float samples on Android at all and changes the format to integer samples, even if you explicitly specify floating point samples. The QAudioDeviceInfo provides a isFormatSupported method to check for these cases.

      I now proceeded to write a int to float conversion method and it works well now.

      1 Reply Last reply
      1

      • Login

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