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. Playing Wav over modem.
Qt 6.11 is out! See what's new in the release blog

Playing Wav over modem.

Scheduled Pinned Locked Moved Unsolved General and Desktop
24 Posts 5 Posters 7.6k Views 2 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.
  • aha_1980A aha_1980

    @An-other-french said in Playing Wav over modem.:

    mainwindow.cpp:396: erreur : conversion from 'QString' to non-scalar type 'const QByteArray' requested
    const QByteArray data = flux->read(1024);

    Ah, you read from a QTextStream. Citing the documentation: "The QTextStream class provides a convenient interface for reading and writing text." This class converts your file data to QString, which is not what you want!

    Well, you don't want to write text! You want to write binary data. So either operate directly on QFile (as I would do) or dig into QDataStream.

    Regards.

    A Offline
    A Offline
    An other french
    wrote on last edited by
    #14

    Thanks for info.
    I had probleme to follow the position in the QFile.
    Perhaps made a mistake.
    So i try again.

    aha_1980A 1 Reply Last reply
    0
    • A An other french

      Thanks for info.
      I had probleme to follow the position in the QFile.
      Perhaps made a mistake.
      So i try again.

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #15

      @An-other-french

      Another tip: get yourself a serial port monitor to see what you actually write to the serial port. This makes also sure you get the timing right.

      Good luck :)

      Qt has to stay free or it will die.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        An other french
        wrote on last edited by An other french
        #16
        QByteArray data = wavFile->read(1024);
        

        Ok for a truncate data of 1024b , qDebug show this. I put a newline after "

        "\xB3\xDEV\xDD\xAA\xDB"
        "c\xDA\xC6\xDA\t\xDD\xF4\xE0^\xE5\x89\xEB\xAC\xF0"
        "7\xF6\x13\xFA\x9A\xFD\xCB\xFF"
        "5\x02|\x04\xC3\x07\x84\x0B\x17\x12\xE0\x19\x90%\\0\xA7<>E!M\xF8Q7V|X\xC1YpY\xB4WBU&Q\xFAL.G\xBE"
        "A7:R3\xA8*\\#\xAA\x1A\xCA\x13\xC5\x0B\xF6\x04\x8A\xFC)\xF5\xED\xEB\x96\xE2\n\xDB\x96\xD2"
        "1\xCCS\xC5K\xC0\xF9\xBA\x1E\xB7P\xB3\x06\xB1v\xAF \xAF\xC8\xAFX\xB1\xD7\xB3"
        "0\xB6\xEC\xB8\x96\xBBQ\xBF\xC8\xC2\x00\xC7j\xCA"
        "2\xCE""3\xD1v\xD5\x9C\xD9\xC5\xDE\xC2\xE2\xDC\xE6\xF6\xE9t\xED\xD2\xF0"
        "9\xF5\xD9\xF8~\xFC\xC0\xFE\x98\x00\x83\x01\xA8\x02$\x04\x94\x05g\x07\xC2\bf\n&\f\x98\x0E\x8C\x10p\x12\xB0\x13\xCB\x14\xC8\x15(\x17"
        

        this part is strong :

        %\\0\xA7<>E!M\xF8Q7V|X\xC1YpY\xB4WBU&Q\xFAL.G\xBE
        

        I except to read something like this:

        a9 de ce e4 86 e3 af e1 c8 de 64 e1 97 e0 ad df
        

        Sure there is a conversion somewhere.

        the last 16b line:

        Qbebug \xE5\x06 \x05$\x06\xFF\x06\x13\x05*\xFF
        wave file e5 06 20 05 24 06 ff 06 13 05 2a ff
        

        I can anderstand /x but $ or * is an other way.

        Ps: My purpose is to play wave on the phone

        aha_1980A 1 Reply Last reply
        0
        • A An other french
          QByteArray data = wavFile->read(1024);
          

          Ok for a truncate data of 1024b , qDebug show this. I put a newline after "

          "\xB3\xDEV\xDD\xAA\xDB"
          "c\xDA\xC6\xDA\t\xDD\xF4\xE0^\xE5\x89\xEB\xAC\xF0"
          "7\xF6\x13\xFA\x9A\xFD\xCB\xFF"
          "5\x02|\x04\xC3\x07\x84\x0B\x17\x12\xE0\x19\x90%\\0\xA7<>E!M\xF8Q7V|X\xC1YpY\xB4WBU&Q\xFAL.G\xBE"
          "A7:R3\xA8*\\#\xAA\x1A\xCA\x13\xC5\x0B\xF6\x04\x8A\xFC)\xF5\xED\xEB\x96\xE2\n\xDB\x96\xD2"
          "1\xCCS\xC5K\xC0\xF9\xBA\x1E\xB7P\xB3\x06\xB1v\xAF \xAF\xC8\xAFX\xB1\xD7\xB3"
          "0\xB6\xEC\xB8\x96\xBBQ\xBF\xC8\xC2\x00\xC7j\xCA"
          "2\xCE""3\xD1v\xD5\x9C\xD9\xC5\xDE\xC2\xE2\xDC\xE6\xF6\xE9t\xED\xD2\xF0"
          "9\xF5\xD9\xF8~\xFC\xC0\xFE\x98\x00\x83\x01\xA8\x02$\x04\x94\x05g\x07\xC2\bf\n&\f\x98\x0E\x8C\x10p\x12\xB0\x13\xCB\x14\xC8\x15(\x17"
          

          this part is strong :

          %\\0\xA7<>E!M\xF8Q7V|X\xC1YpY\xB4WBU&Q\xFAL.G\xBE
          

          I except to read something like this:

          a9 de ce e4 86 e3 af e1 c8 de 64 e1 97 e0 ad df
          

          Sure there is a conversion somewhere.

          the last 16b line:

          Qbebug \xE5\x06 \x05$\x06\xFF\x06\x13\x05*\xFF
          wave file e5 06 20 05 24 06 ff 06 13 05 2a ff
          

          I can anderstand /x but $ or * is an other way.

          Ps: My purpose is to play wave on the phone

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #17

          @An-other-french to output binary data for debugging, I recommend you to use QByteArray::toHex().

          Qt has to stay free or it will die.

          A 1 Reply Last reply
          1
          • aha_1980A aha_1980

            @An-other-french to output binary data for debugging, I recommend you to use QByteArray::toHex().

            A Offline
            A Offline
            An other french
            wrote on last edited by
            #18

            No way to play any sound.
            In the purpose to see modem response, i want to show Modem answer.
            So, i need to connect the serial com to the text object

            connect (m_serial, &QSerialPort::readyRead, this, &MainWindow::readData); 
            
            void MainWindow::readData(){ 
            QByteArray data = m_serial->readAll();
            ...
            ui->textEdit->append("1-"+ data.left(data.size()));
            ...
            }
            

            My function don't make difference between input or output(response).

            Do you have a idea to show them distinctly?

            1 Reply Last reply
            0
            • aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #19

              @An-other-french said in Playing Wav over modem.:

              Your connect and the readAll in the slot looks good so far.

              data.left(data.size())

              What do you expect from this construct? It should be the same as data alone.

              As suggested earlier, use a serial port monitor to see which commands you actually send to the modem and wheter it answers.

              Qt has to stay free or it will die.

              A 1 Reply Last reply
              0
              • aha_1980A aha_1980

                @An-other-french said in Playing Wav over modem.:

                Your connect and the readAll in the slot looks good so far.

                data.left(data.size())

                What do you expect from this construct? It should be the same as data alone.

                As suggested earlier, use a serial port monitor to see which commands you actually send to the modem and wheter it answers.

                A Offline
                A Offline
                An other french
                wrote on last edited by An other french
                #20

                @aha_1980 said in Playing Wav over modem.:

                data.left(data.size())

                It's a tentative to cut the data. Just data is better.

                As suggested earlier, use a serial port monitor to see which commands you actually send to the modem and wheter it answers.

                I don t know how to distinct the write and the read. m_serial->readAll(); give all of us.

                aha_1980A 1 Reply Last reply
                0
                • A An other french

                  @aha_1980 said in Playing Wav over modem.:

                  data.left(data.size())

                  It's a tentative to cut the data. Just data is better.

                  As suggested earlier, use a serial port monitor to see which commands you actually send to the modem and wheter it answers.

                  I don t know how to distinct the write and the read. m_serial->readAll(); give all of us.

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #21

                  @An-other-french said in Playing Wav over modem.:

                  I don t know how to distinct the write and the read. m_serial->readAll(); give all of us.

                  Sorry, what do you mean? serial->readAll() returns everything that the modem has send to your program since the last serial->readAll() call.

                  That's why I recommended to use a serial port monitor, which captures the data between your program and the modem so you can easier debug.

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    An other french
                    wrote on last edited by An other french
                    #22

                    To put header into the blocks send to the comserial, I need to size sample.
                    Show bellow a wave file header.

                    header  "RIFF>\xC1\x1B\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x02\x00@\x1F\x00\x00\x80>\x00\x00\x02\x00\b\x00""data\b\xC0\x1B\x00\x7F\x7F\x7F\x7F"
                    header Hex data "52 49 46 46 3e c1 1b 00 57 41 56 45 66 6d 74 20 10 00 00 00 01 00 02 00 40 1f 00 00 80 3e 00 00 02 00 08 00 64 61 74 61 08 c0 1b 00 7f 7f 7f 7f"
                    

                    I need to get the Bitspersample with an offet of 34 and 4 bits long.

                              QByteArray header = wavFile->read(48);                  // header of wave file (.... 00 **08 00** 64...)
                               
                               qint8 BitsPerSample =header.toHex().data()[34];       //And the [35]   after anderstand how to do                        
                             
                               qDebug() << "header "<< header ;
                               qDebug() << "header "<< header.toHex(' ') ;
                               qDebug() << "Bits per sample" << BitsPerSample;     // print out 48
                    

                    Why debug print 48? I want 08.
                    In reading, in base 10, 48 gives 2048.
                    Thanks for reading.

                    Whynot BitsPerSample =qint8(header[34]);

                    A 1 Reply Last reply
                    0
                    • A An other french

                      To put header into the blocks send to the comserial, I need to size sample.
                      Show bellow a wave file header.

                      header  "RIFF>\xC1\x1B\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x02\x00@\x1F\x00\x00\x80>\x00\x00\x02\x00\b\x00""data\b\xC0\x1B\x00\x7F\x7F\x7F\x7F"
                      header Hex data "52 49 46 46 3e c1 1b 00 57 41 56 45 66 6d 74 20 10 00 00 00 01 00 02 00 40 1f 00 00 80 3e 00 00 02 00 08 00 64 61 74 61 08 c0 1b 00 7f 7f 7f 7f"
                      

                      I need to get the Bitspersample with an offet of 34 and 4 bits long.

                                QByteArray header = wavFile->read(48);                  // header of wave file (.... 00 **08 00** 64...)
                                 
                                 qint8 BitsPerSample =header.toHex().data()[34];       //And the [35]   after anderstand how to do                        
                               
                                 qDebug() << "header "<< header ;
                                 qDebug() << "header "<< header.toHex(' ') ;
                                 qDebug() << "Bits per sample" << BitsPerSample;     // print out 48
                      

                      Why debug print 48? I want 08.
                      In reading, in base 10, 48 gives 2048.
                      Thanks for reading.

                      Whynot BitsPerSample =qint8(header[34]);

                      A Offline
                      A Offline
                      An other french
                      wrote on last edited by An other french
                      #23

                      See here a methode
                      It uses a data stream in little Endian.
                      I really don't understand the sens of chunkDataSize and if this makes trouble along the sample data sending.

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        An other french
                        wrote on last edited by An other french
                        #24

                        Where i am now...

                        I put a timer to prevent the modem buffer from being saturated

                                   m_command = "AT+VTX;\r";
                                   output = m_command.toStdString().c_str();
                                   m_serial->write(output);
                                   m_serial->flush();
                        
                                   timer = new QTimer(this);
                                   connect(timer, SIGNAL(timeout()), this, SLOT(sendWave()));
                                   timer->start(Latence);
                        

                        The first bugg is the time it takes for the Hayes command to respond before sending a wave sample data to the modem.
                        I don't know how to wait the answer.
                        I think about a boolean to stop timer.
                        But I saw the example talking about waitForReadyRead.

                        I will not certain where i need to put this wait because of use connect(m_serial, &QSerialPort::readyRead, this, &MainWindow::readData);

                        An idea.
                        Thanks for reading.

                        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