Results 1 to 3 of 3

Thread: How to read RAW audio file ?

  1. #1
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default How to read RAW audio file ?

    Hello,

    I have some files written as raw audio data.

    The audio data I am trying to read is encoded in 16 bits, has only 1 channel and with rate 22050 Hz.

    Pb1: How can I retrieve the amplitude of the wave ?

    Here is what I tried to do to solve Pb1 (don't know if it is good) :
    Qt Code:
    1. QByteArray by = file->read(16);
    To copy to clipboard, switch view to plain text mode 
    but I get something like :
    Qt Code:
    1. "}??????? ©²¾É"
    To copy to clipboard, switch view to plain text mode 
    I tried to convert that to an integer but it doesn't work (I always get 0, but there are datas in the file, I checked with Audacity):
    Qt Code:
    1. qDebug() << by.toInt();
    To copy to clipboard, switch view to plain text mode 
    --
    Pb2: How can I create a RAW audio file if I have the amplitude of the wave ?


    Any idea ?


    .
    Last edited by fitzy; 6th August 2010 at 11:12.

  2. #2
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default Re: How to read RAW audio file ?

    Ok I have solved problem 1 :

    Qt Code:
    1. QFile *file = new QFile("D:/IA/recordSound/debug/test.raw");
    2. file->open(QIODevice::ReadOnly);
    3.  
    4. QDataStream in(file);
    5. for(int i=0; i<100; i++){
    6. // Read the data
    7. char buf[16];
    8. qint64 lineLength = in.readRawData(buf, sizeof(buf));
    9.  
    10. int test = qFromBigEndian(*(qint16 *)(buf));
    11. qDebug() << test;
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 

    This code retrieves the amplitude of the wave (in the RAW file).

  3. #3
    Join Date
    Oct 2009
    Posts
    38
    Thanks
    13
    Platforms
    Unix/X11 Windows

    Default Re: How to read RAW audio file ?

    I really have no idea !

    I am trying to change my integers into something like this :
    Qt Code:
    1. }??????? ©²¾É
    To copy to clipboard, switch view to plain text mode 
    (cf first post)

    but I don't know how !

Similar Threads

  1. Replies: 3
    Last Post: 4th July 2010, 14:43
  2. Read audio CD tracks as files
    By skepticalgeek in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2010, 12:25
  3. is qt phonon can read realmedia file and divx file
    By fayssalqt in forum Qt Programming
    Replies: 1
    Last Post: 27th January 2009, 16:42
  4. Replies: 1
    Last Post: 20th June 2008, 19:43
  5. To make audio and video file player in Qt
    By merry in forum Qt Programming
    Replies: 11
    Last Post: 24th January 2008, 07:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.