Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML MediaRecorder records very quiet audio on Android and distorted audio with noise on iOS
Forum Updated to NodeBB v4.3 + New Features

QML MediaRecorder records very quiet audio on Android and distorted audio with noise on iOS

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 136 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.
  • T Offline
    T Offline
    tekill
    wrote last edited by
    #1

    Environment

    Qt version: 6.9.2

    Platforms tested: Android 15 (Samsung Galaxy S22), iOS 18 (iPhone 13 Pro)

    Module: Qt Multimedia (QML, MediaRecorder / CaptureSession)

    Steps to reproduce
    Minimal QML example:

    MicrophonePermission {
    id: microphonePermission
    onStatusChanged: {}
    }

    CaptureSession {
        id: captureSession
        audioInput: AudioInput {
            volume: 1
        }
        recorder: MediaRecorder {
            id: recorder
            audioSampleRate: 48000
            audioChannelCount: 1
            mediaFormat {
                fileFormat: MediaFormat.Wave
                audioCodec: MediaFormat.AudioCodec.Wave
            }
            quality: MediaRecorder.NormalQuality
            onDurationChanged: (duration) => {}
            onRecorderStateChanged: {
                if (recorderState === MediaRecorder.StoppedState) {
                    app.onSpeechRecorded(actualLocation, duration);
                }
            }
        }
    }
    
    Button {
        id: recButton
        text: "Rec"
        onPressed: {
            if (microphonePermission.status === Qt.PermissionStatus.Undetermined) {
                microphonePermission.request();
            } else {
                recorder.record();
            }
        }
    }
    

    Expected result

    Normal audio recording volume on Android and iOS.

    Clean audio without noise/distortion.

    Actual result

    On Android: audio is recorded, but the volume is extremely low even with AudioInput.volume = 1.

    On iOS: audio is also very quiet, and additionally contains noticeable background noise/distortion.

    Notes

    Issue occurs with the minimal example above.

    Increasing audioSampleRate, volume, or quality does not improve the situation.

    1 Reply Last reply
    1
    • T Offline
      T Offline
      tekill
      wrote last edited by tekill
      #2

      adding this code solves the problem for IOS

      AVAudioSession *session = [AVAudioSession sharedInstance];
      NSError *err = nil;
      [session setCategory:AVAudioSessionCategoryPlayAndRecord
          withOptions:(AVAudioSessionCategoryOptionDefaultToSpeaker |
                       AVAudioSessionCategoryOptionAllowBluetooth |
                       AVAudioSessionCategoryOptionAllowBluetoothA2DP)
                error:&err];
      [session setMode:AVAudioSessionModeSpokenAudio error:&err];
      [session setPreferredSampleRate:48000 error:&err];
      [session setPreferredIOBufferDuration:0.01 error:&err];
      [session setActive:YES error:&err];
      
      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