AudioFile setRange won't increment
-
I was following this post https://forum.hise.audio/topic/10852/audiofile-range-odd-behaviour?_=1732628051201 but was unsolved.
The setRange function only seems to work to decrement the value, but does not increment it.
Check: (I was hitting F5 to compile)
-
Any ideas? Is it a bug or there is another way to achieve this?
-
I could be wrong but I think this is because HISE is working on a cached version of the audio file and each time you reduce the length a new cached version is created which is shorter than the original.
One solution would be to reload the original file before increasing the length, I don't know if this would have any negatives.
-
@d-healey That makes sense. However, I actually want to create a knob with the parameter setRange, so it would overload everything if it loaded the file thousands of times per second.
-
@d-healey said in AudioFile setRange won't increment:
One solution would be to reload the original file before increasing the length
Actually, it didn't crash on my system and worked fine, but it might crash on slower computers. (I first unload the file and then reload it each time the user moves the knob.)
-
A known glitch I believe. (edit: ah, yes you saw my post)
I wrote a whole new sampler just because it wasn't getting fixed.I also created a system to unload and load the audiofile on each change, but it was buggy and weird so I stopped using it.
-
@griffinboy said in AudioFile setRange won't increment:
I wrote a whole new sampler just because it wasn't getting fixed.
Wouldn't it have been easier to modify the source to add a function to refresh the cache with the original file?
-
@bendurso If you have a component that can store the length of the audio file, you could do like this:
This is code from one of my projects
the "WFPnl" is a panel that stores the file length when loaded
I then can use the length when setting the range to loop// ================= LOAD AUDIO FILE =================== inline function loadAudioFile() { FileSystem.browse(FileSystem.AudioFiles, false, "*", function(file) { if (file) { ALP.setFile(""); var fileName = file.toString(0); ALP.setFile(fileName); WFPnl.getValue().length = ALP.getSampleLength(); WFPnl.getValue().range = [0, ALP.getSampleLength()]; setLoopKnbs(); GridCmb.changed(); TimeSignatureCmb.changed(); SnapToGrid.changed(); updatePnl(WFPnl); } }); }
-
Yeah I've only just started dipping my toes into modifying the source. It's not gone super well haha