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. Synchronize an QOpengl line with audio file

Synchronize an QOpengl line with audio file

Scheduled Pinned Locked Moved Unsolved General and Desktop
qopenglaudiomultimedia
16 Posts 2 Posters 2.5k 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.
  • M mrjj
    28 Nov 2018, 15:00

    Hi
    you mean some method or signal to move the red line ?

    H Offline
    H Offline
    HW-Developer
    wrote on 28 Nov 2018, 15:14 last edited by
    #3

    @mrjj Yes that's right

    M 1 Reply Last reply 28 Nov 2018, 15:16
    0
    • H HW-Developer
      28 Nov 2018, 15:14

      @mrjj Yes that's right

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 28 Nov 2018, 15:16 last edited by
      #4

      @HW-Developer
      well did u subclass QOpenglWidget ?
      If yes, you can just add a slot to it like
      public slots:
      void PositionChanged( int pos) ;

      and in cpp
      void yourclassname:: PositionChanged( int pos) {
      change the variable that controls the red line.
      }

      H 1 Reply Last reply 28 Nov 2018, 15:28
      0
      • M mrjj
        28 Nov 2018, 15:16

        @HW-Developer
        well did u subclass QOpenglWidget ?
        If yes, you can just add a slot to it like
        public slots:
        void PositionChanged( int pos) ;

        and in cpp
        void yourclassname:: PositionChanged( int pos) {
        change the variable that controls the red line.
        }

        H Offline
        H Offline
        HW-Developer
        wrote on 28 Nov 2018, 15:28 last edited by HW-Developer
        #5

        @mrjj for example if we have this code to draw the red line

        glColor3f(1.0, 0.0, 0.0);
        glBegin(GL_LINES);
        glVertex3f(-1 + (redLine*scaleFactor), 1 + -(0 * 0.016), -1.0);
        glVertex3f(-1 + (redLine*scaleFactor), 1 + -(130 * 0.016), -1.0);
        glEnd();
        

        //scaleFactor is a float variable which determines the space before the red line
        //redline is a float variable = 320 + 160;

        and i create the positionChanged(int position) methode, what should i change using the position variable?

        M 1 Reply Last reply 28 Nov 2018, 15:32
        0
        • H HW-Developer
          28 Nov 2018, 15:28

          @mrjj for example if we have this code to draw the red line

          glColor3f(1.0, 0.0, 0.0);
          glBegin(GL_LINES);
          glVertex3f(-1 + (redLine*scaleFactor), 1 + -(0 * 0.016), -1.0);
          glVertex3f(-1 + (redLine*scaleFactor), 1 + -(130 * 0.016), -1.0);
          glEnd();
          

          //scaleFactor is a float variable which determines the space before the red line
          //redline is a float variable = 320 + 160;

          and i create the positionChanged(int position) methode, what should i change using the position variable?

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 28 Nov 2018, 15:32 last edited by
          #6

          @HW-Developer
          I would assume redLine variable ?

          H 1 Reply Last reply 28 Nov 2018, 15:42
          0
          • M mrjj
            28 Nov 2018, 15:32

            @HW-Developer
            I would assume redLine variable ?

            H Offline
            H Offline
            HW-Developer
            wrote on 28 Nov 2018, 15:42 last edited by HW-Developer
            #7

            @mrjj When i use redLine =0, it gives me this result:
            0_1543423125490_cap1.PNG
            so 160 is the space between the small grey lines
            and 320 is just a number that i added so the red line will be in the same line with my slider
            0_1543423370788_cap2.PNG

            M 1 Reply Last reply 28 Nov 2018, 15:44
            0
            • H HW-Developer
              28 Nov 2018, 15:42

              @mrjj When i use redLine =0, it gives me this result:
              0_1543423125490_cap1.PNG
              so 160 is the space between the small grey lines
              and 320 is just a number that i added so the red line will be in the same line with my slider
              0_1543423370788_cap2.PNG

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 28 Nov 2018, 15:44 last edited by
              #8

              @HW-Developer
              so the redline default offset is 320+160.
              so if you add to that, it will move the redline.
              Do you mean to hook up the slider so it moves the redline or what is task?

              H 1 Reply Last reply 28 Nov 2018, 15:46
              0
              • M mrjj
                28 Nov 2018, 15:44

                @HW-Developer
                so the redline default offset is 320+160.
                so if you add to that, it will move the redline.
                Do you mean to hook up the slider so it moves the redline or what is task?

                H Offline
                H Offline
                HW-Developer
                wrote on 28 Nov 2018, 15:46 last edited by
                #9

                @mrjj The slider was my first test so to have the same result i did have with my slider i initialize the red line on the same line with that slider so when the audio is playing, they will be moving in the same time

                M 1 Reply Last reply 28 Nov 2018, 15:52
                0
                • H HW-Developer
                  28 Nov 2018, 15:46

                  @mrjj The slider was my first test so to have the same result i did have with my slider i initialize the red line on the same line with that slider so when the audio is playing, they will be moving in the same time

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 28 Nov 2018, 15:52 last edited by
                  #10

                  @HW-Developer
                  ok.
                  so now you want a method in QOpenglWidget that also moves the redLine ?

                  H 1 Reply Last reply 28 Nov 2018, 15:54
                  0
                  • M mrjj
                    28 Nov 2018, 15:52

                    @HW-Developer
                    ok.
                    so now you want a method in QOpenglWidget that also moves the redLine ?

                    H Offline
                    H Offline
                    HW-Developer
                    wrote on 28 Nov 2018, 15:54 last edited by
                    #11

                    @mrjj Yes that's right

                    M 1 Reply Last reply 28 Nov 2018, 15:56
                    0
                    • H HW-Developer
                      28 Nov 2018, 15:54

                      @mrjj Yes that's right

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 28 Nov 2018, 15:56 last edited by
                      #12

                      @HW-Developer
                      Ok, i assumed you subclassed it ?
                      like
                      class MyGLWidget : public QOpenGLWidget ...

                      so you can just add a new method to it to alter the redLine variable.

                      H 1 Reply Last reply 28 Nov 2018, 15:57
                      0
                      • M mrjj
                        28 Nov 2018, 15:56

                        @HW-Developer
                        Ok, i assumed you subclassed it ?
                        like
                        class MyGLWidget : public QOpenGLWidget ...

                        so you can just add a new method to it to alter the redLine variable.

                        H Offline
                        H Offline
                        HW-Developer
                        wrote on 28 Nov 2018, 15:57 last edited by
                        #13

                        @mrjj Yes of course i already did what is necessary to have the drawing ruler that i upload it above

                        M 1 Reply Last reply 28 Nov 2018, 15:59
                        0
                        • H HW-Developer
                          28 Nov 2018, 15:57

                          @mrjj Yes of course i already did what is necessary to have the drawing ruler that i upload it above

                          M Offline
                          M Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on 28 Nov 2018, 15:59 last edited by
                          #14

                          @HW-Developer
                          ok but you question was
                          " how to create positionchanged method in my QOpenglWidget class,"
                          so i must be missing something you ask about ?
                          (if you already did make such method)

                          H 1 Reply Last reply 28 Nov 2018, 16:52
                          0
                          • M mrjj
                            28 Nov 2018, 15:59

                            @HW-Developer
                            ok but you question was
                            " how to create positionchanged method in my QOpenglWidget class,"
                            so i must be missing something you ask about ?
                            (if you already did make such method)

                            H Offline
                            H Offline
                            HW-Developer
                            wrote on 28 Nov 2018, 16:52 last edited by HW-Developer
                            #15

                            @mrjj I already draw the qopenglwidget but I did not synchronize it with the audio file using positionchanged method that I did ask you about

                            M 1 Reply Last reply 28 Nov 2018, 17:03
                            0
                            • H HW-Developer
                              28 Nov 2018, 16:52

                              @mrjj I already draw the qopenglwidget but I did not synchronize it with the audio file using positionchanged method that I did ask you about

                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 28 Nov 2018, 17:03 last edited by
                              #16

                              hi
                              well you can hook up the AUDIO positionchanged
                              signal to your own method (slot)
                              using connect.
                              http://doc.qt.io//qt-5/signalsandslots.html

                              so it will directly call your method when it changes.

                              1 Reply Last reply
                              0

                              12/16

                              28 Nov 2018, 15:56

                              • Login

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