Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3845806
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:18:02+00:00 2026-05-19T16:18:02+00:00

Well, smth like this i was saw in tutorial, but i wanted to save

  • 0

Well, smth like this i was saw in tutorial, but i wanted to save in one of the readable formats for music player. Is it possible?

file   = new QFile("smth.raw");
file->open(QIODevice::WriteOnly | QIODevice::Truncate );

QAudioFormat format;
format.setFrequency(8000);
format.setChannels(1);
format.setSampleSize(8);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::UnSignedInt);
QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
if (!info.isFormatSupported(format)) {
    qWarning()<<"default format not supported try to use nearest";
    format = info.nearestFormat(format);
}
audioInput = new QAudioInput(format, this);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:18:03+00:00Added an answer on May 19, 2026 at 4:18 pm

    Well, if it interesting for somebody, that’s algorithm to convert. If you have the better idea, please, reply!

     #include <stdio.h>
     int rawToWav(const char *rawfn, const char *wavfn, long frequency)
     {
        long chunksize=0x10;
    
        struct
        {
            unsigned short    wFormatTag;
            unsigned short    wChannels;
            unsigned long     dwSamplesPerSec;
            unsigned long     dwAvgBytesPerSec;
            unsigned short    wBlockAlign;
            unsigned short    wBitsPerSample;
        } fmt;
    
        FILE *raw = fopen(rawfn,"rb");
        if(!raw)
            return -2;
    
        fseek(raw, 0, SEEK_END);
        long bytes = ftell(raw);
        fseek(raw, 0, SEEK_SET);
    
        long samplecount = bytes/2;
        long riffsize    = samplecount*2+0x24;
        long datasize    = samplecount*2;
    
        FILE *wav=fopen(wavfn,"wb");
        if(!wav)
        {
            fclose(raw);
            return -3;
        }
    
        fwrite( "RIFF",     1, 4, wav );
        fwrite( &riffsize,  4, 1, wav );
        fwrite( "WAVEfmt ", 1, 8, wav );
        fwrite( &chunksize, 4, 1, wav );
    
        fmt.wFormatTag = 1;      // PCM
        fmt.wChannels  = 1;      // MONO
        fmt.dwSamplesPerSec  = frequency*1;
        fmt.dwAvgBytesPerSec = frequency*1*2; // 16 bit
        fmt.wBlockAlign      = 2;
        fmt.wBitsPerSample   = 16;
    
        fwrite( &fmt,      sizeof(fmt), 1, wav );
        fwrite( "data",    1,           4, wav );
        fwrite( &datasize, 4,           1, wav );
        short buff[1024];
        while( !feof(raw) )
        {
              int cnt=fread(buff,2,1024,raw);
              if( cnt == 0 )
                  break;
              fwrite(buff,2,cnt,wav);
        }
        fclose( raw );
        fclose( wav );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

well i have a configuration like this in the components part of my config
Well my situation is like this: I am generating a report as a text
Well, I didn't know how to explain this one on the title, so I'll
Well im new to javascript but why does this not work, all i want
Well the problem is that I have this enum, BUT I don't want the
Well the problem is that I was using code like this: new Date().toJSON().slice(0, 10)
Well I think this is kinda dumb but, I wonder if there's any way
Well, first I know that this question was already asked several times. But I
Well friends, I have got this query which works but is very long for
Well, this one is my XML file <?xml version=1.0 encoding=utf-8?> <config> <setup> <Test>10</Test> <Copy>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.