Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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



  • 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);
    
    
    

  • Lifetime Qt Champion

    Hi,

    What is exactly your issue ?



  • @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.


  • Lifetime Qt Champion

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


Log in to reply