HISE Logo Forum
    • Categories
    • Register
    • Login

    Waveform how to get playback position?

    Scheduled Pinned Locked Moved Unsolved Scripting
    playheadwaveform
    19 Posts 7 Posters 1.6k Views
    Loading More Posts
    • 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.
    • d.healeyD
      d.healey
      last edited by

      I can see a function to set the playback position, but how do we get it?

      My idea is to create a pause button. So the user clicks play, the audio file plays back, they hit pause and it stores the position, when they hit play again I resume from that position.

      Free HISE Bootcamp Full Course for beginners.
      YouTube Channel - Public HISE tutorials
      My Patreon - HISE tutorials

      ulrikU 1 Reply Last reply Reply Quote 0
      • d.healeyD d.healey marked this topic as a question on
      • ulrikU
        ulrik @d.healey
        last edited by

        @d-healey is it not

        AudioFile.getCurrentlyDisplayedIndex()
        

        ?

        Hise Develop branch
        MacOs 15.3.1, Xcode 16.2
        http://musikboden.se

        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey @ulrik
          last edited by

          @ulrik Yes, if I had an audio file, but I have a waveform control linked to a sampler.

          Free HISE Bootcamp Full Course for beginners.
          YouTube Channel - Public HISE tutorials
          My Patreon - HISE tutorials

          ulrikU 2 Replies Last reply Reply Quote 0
          • ulrikU
            ulrik @d.healey
            last edited by

            @d-healey Oh, ok I see

            Hise Develop branch
            MacOs 15.3.1, Xcode 16.2
            http://musikboden.se

            1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey
              last edited by

              @Christoph-Hart Any pointers?

              Free HISE Bootcamp Full Course for beginners.
              YouTube Channel - Public HISE tutorials
              My Patreon - HISE tutorials

              1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey
                last edited by

                Still haven't found a solution to this one. Also it seems ScriptAudioWaveform.setPlaybackPosition() doesn't do anything, at least when it's connected to a sampler?

                Free HISE Bootcamp Full Course for beginners.
                YouTube Channel - Public HISE tutorials
                My Patreon - HISE tutorials

                C 1 Reply Last reply Reply Quote 2
                • C
                  clevername27 @d.healey
                  last edited by

                  @d-healey Do you recall if this was ever resolved?

                  d.healeyD 1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @clevername27
                    last edited by

                    @clevername27 Not according to my last post here :)

                    Free HISE Bootcamp Full Course for beginners.
                    YouTube Channel - Public HISE tutorials
                    My Patreon - HISE tutorials

                    C 1 Reply Last reply Reply Quote 1
                    • C
                      clevername27 @d.healey
                      last edited by

                      @d-healey I'm baffled how anyone is able to ship a HISE-product. Obviously they do, but I am legit baffled.

                      ? 1 Reply Last reply Reply Quote 0
                      • ?
                        A Former User @clevername27
                        last edited by

                        @clevername27 These are edge-cases, the primary modules & UI elements are very well made and stable :)

                        C 1 Reply Last reply Reply Quote 1
                        • C
                          clevername27 @A Former User
                          last edited by

                          @iamlamprey I appreciate your response. I do not believe there is a such a thing as an "edge case". An API either works, or it doesn't.

                          1 Reply Last reply Reply Quote 0
                          • OrvillainO
                            Orvillain
                            last edited by Orvillain

                            Surely the sampler itself should be reporting this, not the WaveForm view ???

                            My brain looks at this problem more along these lines:

                            • Get sampler.
                            • Get currently playing file.
                            • Get sample position for currently playing file.
                            • Use a ScriptPanel and a timer.
                            • Convert sample position into a pixel value.
                            • Draw a vertical line at the pixel value on the X axis, and as tall as you need it on the Y axis.
                            • Each time you want to update the position, clear the old line, and draw a new line.

                            This ScriptPanel would be placed over the top of the existing waveform panel.

                            This is more or less how I did my sample start/end and loop start/end mechanics.
                            9acedb12-7fa2-401d-b99c-4278144257aa-image.png

                            The only thing I haven't done is any kind of update logic. But I'm sure it is possible. Provided you can get the data from the sampler or currently playing audio file.

                            Musician - Instrument Designer - Sonic Architect - Creative Product Owner
                            Crafting sound at every level. From strings to signal paths, samples to systems.

                            C ulrikU 2 Replies Last reply Reply Quote 1
                            • C
                              clevername27 @Orvillain
                              last edited by

                              @Orvillain Thank you - I'm confused, though, because I don't want to use a sampler. I just want to play an audio file. And HISE has a Module to do that:

                              ce814e3f-0f5a-4001-9e99-385a55da192e-image.png

                              Except, like so many things in HISE, it doesn't do that.

                              1 Reply Last reply Reply Quote 0
                              • ulrikU
                                ulrik @Orvillain
                                last edited by

                                @Orvillain said in Waveform how to get playback position?:

                                Surely the sampler itself should be reporting this, not the WaveForm view ???

                                My brain looks at this problem more along these lines:

                                • Get sampler.
                                • Get currently playing file.
                                • Get sample position for currently playing file.

                                I'm sorry to dig in this old topic.
                                As I undertand, you are using a sampler for this right?
                                Could you please explain, or make a very small snippet, how to get the play position of the file?

                                Hise Develop branch
                                MacOs 15.3.1, Xcode 16.2
                                http://musikboden.se

                                1 Reply Last reply Reply Quote 0
                                • ulrikU
                                  ulrik @d.healey
                                  last edited by

                                  @d-healey said in Waveform how to get playback position?:

                                  @ulrik Yes, if I had an audio file, but I have a waveform control linked to a sampler.

                                  Did you find a solution for this?

                                  Hise Develop branch
                                  MacOs 15.3.1, Xcode 16.2
                                  http://musikboden.se

                                  HISEnbergH 1 Reply Last reply Reply Quote 0
                                  • HISEnbergH
                                    HISEnberg @ulrik
                                    last edited by

                                    @Christoph-Hart I'm gonna add a bump to this topic to see if there is any progress. I feel like if there is a ScriptAudioWaveform.setPlaybackPosition() then it should be fairly trivial to add a ScriptAudioWaveform.getPlaybackPosition().

                                    Christoph HartC 1 Reply Last reply Reply Quote 0
                                    • Christoph HartC
                                      Christoph Hart @HISEnberg
                                      last edited by

                                      @HISEnberg use a broadcaster with the AudioFile.Display event type:

                                      const var playbackWatcher = Engine.createBroadcaster({
                                        "id": "playbackWatcher",
                                        "args": ["processor", "index", "value"],
                                        "tags": []
                                      });
                                      
                                      // Note that DisplayIndex doesn't work in the previous HISE version (it expects AudioFile.Display)
                                      // so if you use the broadcaster wizard like I did here it will spit out non-working code.
                                      playbackWatcher.attachToComplexData("AudioFile.DisplayIndex", "Audio Loop Player1", 0, "");
                                      
                                      inline function onPlaybackUpdate(p, i, v)
                                      {
                                      	Console.print(v);
                                      };
                                      
                                      playbackWatcher.addListener(0, "show the playback position", onPlaybackUpdate);
                                      
                                      HISEnbergH 1 Reply Last reply Reply Quote 2
                                      • HISEnbergH
                                        HISEnberg @Christoph Hart
                                        last edited by

                                        @Christoph-Hart Nice yes this is a bit more elegant than what I figured out yesterday. I actually just used a variable in the drawThumbnailRuler so I could yank the obj.xPosition and pass it to my panel. Your version is giving the actual sample value so it seems preferable:

                                        reg thumbnailXPos = 0.0;
                                        Laf_Waveform.registerFunction("drawThumbnailRuler", function(g, obj)
                                        {
                                            thumbnailXPos = obj.xPosition;
                                            Console.print(thumbnailXPos);
                                        });
                                        
                                        // Then I just pass thumbnailXPos over to the panel....
                                        
                                        Christoph HartC 1 Reply Last reply Reply Quote 0
                                        • Christoph HartC
                                          Christoph Hart @HISEnberg
                                          last edited by

                                          @HISEnberg said in Waveform how to get playback position?:

                                          Your version is giving the actual sample value so it seems preferable:

                                          It also runs if your waveform is not visible.

                                          1 Reply Last reply Reply Quote 2
                                          • First post
                                            Last post

                                          19

                                          Online

                                          2.0k

                                          Users

                                          12.8k

                                          Topics

                                          110.9k

                                          Posts