Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. Independent Developers
  4. how do i write processed audio samples to a file in realtime.

how do i write processed audio samples to a file in realtime.

Scheduled Pinned Locked Moved Solved Independent Developers
4 Posts 2 Posters 841 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.
  • N Offline
    N Offline
    NIvil Wilson
    wrote on 3 Dec 2020, 13:26 last edited by
    #1

    sir,
    please help.the code is given below.

    code_text
     //Return if audio input is null
         if(!input)
             return;
    
    
    
         //Check the number of samples in input buffer
         qint64 len =input->bytesReady();
    
         //Limit sample size
         if(len > 4096)
             len = 4096;
         //Read sound samples from input device to buffer
         qint64 l = input_device->read(_buffer.data(), len);
         if(l > 0)
         {
             //Assign sound samples to short array
             short* resultingData = (short*)_buffer.data();
    
    
             short *outdata=resultingData;
             outdata[ 0 ] = resultingData [ 0 ];
    
              int iIndex;
              if(_chk_state == Qt::Checked)
              {
                     //Remove noise using Low Pass filter algortm[Simple algorithm used to remove noise]
                     for ( iIndex=1; iIndex < len; iIndex++ )
                     {
                         outdata[ iIndex ] = 0.333 * resultingData[iIndex ] + ( 1.0 - 0.333 ) * outdata[ iIndex-1 ];
                     }
               }
    
              for ( iIndex=0; iIndex < len; iIndex++ )
              {
                  //Change volume to each integer data in a sample
                  outdata[ iIndex ] = ApplyVolumeToSample( outdata[ iIndex ]);
              }
    
              //write modified sond sample to outputdevice for playback audio
               output_device->write((char*)outdata, len);
    
    
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 3 Dec 2020, 18:19 last edited by
      #2

      Hi,

      What is exactly your issue ?

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

      N 1 Reply Last reply 4 Dec 2020, 02:05
      0
      • S SGaist
        3 Dec 2020, 18:19

        Hi,

        What is exactly your issue ?

        N Offline
        N Offline
        NIvil Wilson
        wrote on 4 Dec 2020, 02:05 last edited by NIvil Wilson 12 Apr 2020, 02:14
        #3

        @SGaist
        sir,
        i want to record that processed aduio(outdata in code) to a mp3 or mp4 file.how do i do that.i dont know how to do that.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 4 Dec 2020, 19:39 last edited by
          #4

          In that case you will need something like ffmpeg or VLC.

          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

          2/4

          3 Dec 2020, 18:19

          • Login

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