Waveform how to get playback position?
-
@d-healey Do you recall if this was ever resolved?
-
@clevername27 Not according to my last post here :)
-
@d-healey I'm baffled how anyone is able to ship a HISE-product. Obviously they do, but I am legit baffled.
-
@clevername27 These are edge-cases, the primary modules & UI elements are very well made and stable :)
-
@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.
-
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.

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.
-
@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:

Except, like so many things in HISE, it doesn't do that.
-
@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? -
@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?
-
@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 aScriptAudioWaveform.getPlaybackPosition(). -
@HISEnberg use a broadcaster with the
AudioFile.Displayevent 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); -
@Christoph-Hart Nice yes this is a bit more elegant than what I figured out yesterday. I actually just used a variable in the
drawThumbnailRulerso I could yank theobj.xPositionand 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.... -
@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.