How to Load Audio File Using Scripting? (External Data)
-
This is causing a crash. I'm not sure why.
I'm trying to figure out how to load an audio file into an external data slot using scripting.It works fine when done manually, or through the use of an audioWaveform UI component. But my scripting attempt has been less than successful.
Is this an incorrect way to access the external data slot? Have I accidently grabbed something else instead?
-
@griffinboy Probably need an audio sample reference rather than complex data
-
mmm I'm really not experienced when it comes to Hise API.
I'm fumbling around fairly aimlesslyI've been putting this off since I joined Hise.
edit* is there a way to dump all the methods belonging to slot 0 here?
-
@griffinboy said in How to Load Audio Using Scripting? (External Data):
edit* is there a way to dump all the methods belonging to slot 0 here?
If slot0 is actually an audio sample processor, then look up audio sample processor in the API browser to see all the methods. They should also show up in the auto-complete.
HiseSnippet 1452.3ocuWEzaaaCElxIJc1qcaEX8tZN4TDXXmjllfhg4Dm3UiMmZTkEzdpfVhJlvTjBhTIwasm1kdam6s8SXW2s9GXm1ej8OX6QQYKoZitDi1k.DH93683G+368QlAwBOhTJhQV0NcRDAYcaa2Ib0nNivTNp2QHquzFm3SEcoLxoDoBc3jHrTR7QVVq7cZmrptJJ8m+9aODyvbORtID5LA0i7CzPpJ25f1eOkw5h8ImRCK38Ns64I3cDLQB.nUrahhvdiwmSNAqcqhM5IX4Hj0Cr2JXn2VAOZ68Zseq8ezN62p0C2a3NM2xy+g6u816tsevV6g2cOHn0N1mpDwtJrhHgjdnveh6HwkbyBbFURGxH5AsPtvJaLi5Lhx7GLkcjHj0pCx4pULb0Wa2m5SmYOmy9pzIbxinHoYU4CAoV2.HYU.RqZfzcsc8hoQp7Yz34ys6wUj3.Lb1TDJFeQUhpX2Q.dvUMBwiIcigAyhn9tMatoC7mMdbsZv4iT4bAN1wDa2m2x4abRKYZbNQcftTwEGFwHyPP80Mt5.9ttNGTNixINAIbOEUvcD7CSTJAukFCwBVcOQXjfCnYSXkXIjMp8y0pRCbpmMpZ0XhJIl+X3qZU0UltSjJRXigwhKkj5Er.Xpqf4ShKZ7HfqYBrubiMcBvLIYSm0ePiKwWr9lyPU8.ve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EZtzrPLA1Qe5qoticeXkopQwDr+xvV5dtCEhwg3Twzk5cV+uH8Gh8hEuzybalti8yRs.5G7TMmp180icZgt382sgv+c2K87Jmp4BbqkMvsW1.2YYC7gKaf6trA9nkMv89uCT+OeePhRDZtgFZKFbrQH25XNFd7Q5MKn+EvW2cZm
To clear the loaded file you can use
setFile(-1)
-
I wonder if I need to compile to the latest version of Hise, because this doesn't work for me. The filename seems to update in the external data, but the audio files don't load properly. Neither in the snippet nor my actual project, the waveform display never updates and no sound is audible.
we get the filename sure enough, but there seems to be something the matter.
-
@griffinboy said in How to Load Audio File Using Scripting? (External Data):
Neither in the snippet nor my actual project, the waveform display never updates and no sound is audible
Hmmm, I'm on the latest version so it's not that, let me check
-
I appreciate the help, if it's working on your end but not mine, I'll have to just investigate and poke around.
-
I mean, is this correct?
We are using the file load function, but the actual info that ends up getting fed is just the file name, not any path.
edit* Ah then again, even loading files that are located inside of the project folder, we get the same result, so it's not that. I'm probably just ignorant of the workings
-
@griffinboy said in How to Load Audio File Using Scripting? (External Data):
but the actual info that ends up getting fed is just the file name, not any path.
Yes that was the problem.
Should have been
ScriptFX1.setFile(file.toString(file.FullPath));
Of course if you're using it from the project's audio files folder then the path from
loadAudioFilesIntoPool()
will work too. -
Worked!
Great, thanks David.Answer:
const var ScriptnodeSynthesiser1 = Synth.getAudioSampleProcessor("Scriptnode Synthesiser1"); inline function onButton1Control(component, value) { if (!value) return; FileSystem.browse(FileSystem.getFolder(FileSystem.Downloads), false, "*.wav", function(file) { if (!isDefined(file) || !file.isFile()) return; ScriptnodeSynthesiser1.setFile(file.toString(file.FullPath)); }); }; Content.getComponent("Button1").setControlCallback(onButton1Control);
-
-