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. Qaudiooutput Double values
Forum Update on Monday, May 27th 2025

Qaudiooutput Double values

Scheduled Pinned Locked Moved Unsolved General and Desktop
qbytearrayqbufferqvectorqaudiooutput
1 Posts 1 Posters 442 Views
  • 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.
  • S Offline
    S Offline
    Sareban
    wrote on 19 Mar 2019, 21:44 last edited by
    #1

    Hi. I am a newbie to qt and c++. I am writing a simple signal generator right now. ı am tryimg to create a qbytearray from doubles but qbytearray changes all of the doubles to integer. So i lose precision on the sound waves. How can i make qbytearray store double or float variables?
    My code is like this which generates a simple sinewave
    @
    int len= m_seconds*SAMPLE_RATE;

    sinbuf.resize(len);
    
    for(int i=0;i<len;i++){
        qreal t = m_freq*i;
        t *= FREQ_CONST;
        t = t+ m_ph;
        t = qSin(t);
        t*= m_amp;
    
        sinbuf[i] = t;
    }
    
    sininput.setBuffer(&sinbuf);
    sininput.open(QIODevice::ReadWrite);
    

    @

    It just invludes integers from -100 to 100. I need it to include floats or doubles. I tried populating a qvector and stream it to the array via qdatastream but it just made every element put randomly and also integers.
    Thamks for your help

    1 Reply Last reply
    0

    1/1

    19 Mar 2019, 21:44

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved