Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAudiorecorder limit recording file size

QAudiorecorder limit recording file size

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 386 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.
  • mmjvoxM Offline
    mmjvoxM Offline
    mmjvox
    wrote on last edited by mmjvox
    #1

    I'm recording audio in pcm encoding from input and output device (It doesn't matter input or output) and no problem saving in file.
    The important thing is that i want to record only last minute or hour or ...
    I searched it and according to the recommendations i came to the conclusion that the best way is limit the Buffer or file that data is writing into that.
    but i don't know how do that

    QAudioRecorder doesn't have any option to limit file or ...
    i searched in all multimedia plugins files and classes to find a solution or best place to edit and add a function that i need.

    How do i do this?

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by Kent-Dorfman
      #2

      since it's essentially raw data, I'd save it in fixed sized chunks to a ring buffer. That way older chunks age out of the ring as newer chunks are written:

      It requires some real programming

      high level pseudo-code:

      ring_buffer ring;
      sample_reader reader;
      sample_buffer samples;
      while(!reader.done()) {
          samples=reader.read_samples();
          if (ring.isFull() {
              ring.pop_oldest();
          }
          ring.push(samples);
      }
      sample_buffer& last_minute=ring.concat(n); 
          // where n represents the number of buffers in the ring
          // that represent the last minute of data
      

      Actually, in hidsight, this could be simplified by using two buffers of size (n) and flipping back and forth between them as each one becomes full. You don't need a deque or ring. Just two work buffers and some flipping logic.

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      mmjvoxM 1 Reply Last reply
      1
      • Kent-DorfmanK Kent-Dorfman

        since it's essentially raw data, I'd save it in fixed sized chunks to a ring buffer. That way older chunks age out of the ring as newer chunks are written:

        It requires some real programming

        high level pseudo-code:

        ring_buffer ring;
        sample_reader reader;
        sample_buffer samples;
        while(!reader.done()) {
            samples=reader.read_samples();
            if (ring.isFull() {
                ring.pop_oldest();
            }
            ring.push(samples);
        }
        sample_buffer& last_minute=ring.concat(n); 
            // where n represents the number of buffers in the ring
            // that represent the last minute of data
        

        Actually, in hidsight, this could be simplified by using two buffers of size (n) and flipping back and forth between them as each one becomes full. You don't need a deque or ring. Just two work buffers and some flipping logic.

        mmjvoxM Offline
        mmjvoxM Offline
        mmjvox
        wrote on last edited by mmjvox
        #3

        @Kent-Dorfman

        thanks

        If during running app crashed all recorded buffers will be lost?
        When should i save ringbuffer to file?
        What i do to reduce file savings?
        (i save it every 1 second now)

        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