Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. what is a good way to store a huge data with QT C++?
Forum Updated to NodeBB v4.3 + New Features

what is a good way to store a huge data with QT C++?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 456 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.
  • A Offline
    A Offline
    Aa.Aa
    wrote on last edited by
    #1

    I have audio data and I am not sure what is the best way to store it as matrix.
    I have 4 large files of recordings from acoustic sensors, each file has 4 channels data interleaved.
    I am using Qt C++ to do some treatements of these data. I already made this approach using QVector of QVectors to store the data in. I tried this code:

    QVector<QVector<int>> buffer(16) // 4 * 4 : numberOfChannels * numberOfFiles
    for(int i = 0 ; i < 4 ; i++){ 
    	QFile file(fileList[i]);	// fileList is QList of QStrings contains 4 files path
    	if(file.open(QIODevice::ReadOnly)){
    		int k = 0;
    		while(!file.atEnd()){
    			QByteArray sample = file.read(depth/8); // depth here is 24
    			int integerSample = convertByteArrayToIntFunction(sample);
    			buffer[4 * i + (K%4)].append(integerSample);	
    			k++;
    
    		}
    	}
    }
    

    To have at the end this matrix of 16 columns like below(f:file, c:channel):
    f1c0 | f1c1 | f1c2 | f1c3 | f2c0 | f2c1 | ... | f4c2 | f4c3

    But this approach it takes ages for large files of few gigabytes. I am wondering if there is another efficient way to fulfill this task and gain a lot of time.
    Thanks in advance.

    jsulmJ 1 Reply Last reply
    0
    • A Aa.Aa

      I have audio data and I am not sure what is the best way to store it as matrix.
      I have 4 large files of recordings from acoustic sensors, each file has 4 channels data interleaved.
      I am using Qt C++ to do some treatements of these data. I already made this approach using QVector of QVectors to store the data in. I tried this code:

      QVector<QVector<int>> buffer(16) // 4 * 4 : numberOfChannels * numberOfFiles
      for(int i = 0 ; i < 4 ; i++){ 
      	QFile file(fileList[i]);	// fileList is QList of QStrings contains 4 files path
      	if(file.open(QIODevice::ReadOnly)){
      		int k = 0;
      		while(!file.atEnd()){
      			QByteArray sample = file.read(depth/8); // depth here is 24
      			int integerSample = convertByteArrayToIntFunction(sample);
      			buffer[4 * i + (K%4)].append(integerSample);	
      			k++;
      
      		}
      	}
      }
      

      To have at the end this matrix of 16 columns like below(f:file, c:channel):
      f1c0 | f1c1 | f1c2 | f1c3 | f2c0 | f2c1 | ... | f4c2 | f4c3

      But this approach it takes ages for large files of few gigabytes. I am wondering if there is another efficient way to fulfill this task and gain a lot of time.
      Thanks in advance.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Aa-Aa Well, don't read whole file at once. Read it in chunks.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Aa-Aa Well, don't read whole file at once. Read it in chunks.

        A Offline
        A Offline
        Aa.Aa
        wrote on last edited by
        #3

        @jsulm you mean divide the process in many times? as I understand, divide the reading from the files in different chunks and afterwords treat chunk after chunk, right!

        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