Basic Questions on ScriptAudioWaveforms…?
-
1) Dragging an audio file to the ScriptAudioWaveform appears to do nothing—how do you enable that. (Right-clicking on the DAW produces the expected OS filesystem dialogue box.) What am I doing wrong?
2) How do you present a UI to the user to play the audio in the SAW?
3) How do you present a UI to the user wherein she can position a playhead on the ScriptAudioWaveform, and begin playback from there?
4) How do you register a callback that fires when the user loads an audio file into the SAW?
Here is an elegant callback-based version from @d-healey:
const AudioLoopPlayer1 = Synth.getAudioSampleProcessor("Audio Loop Player1"); const af = AudioLoopPlayer1.getAudioFile(0); af.setContentCallback(function() { Console.print("HELLO WORLD"); });
And a Broadcaster-based one I managed to piece together:
// In your Module Tree, create a LoopAudioPlayer called "AudioPlayer." // Register the AudiofileWave Component. const var wave_ENGINE_Encode_ImportAudio_GUI = Content.getComponent("wave_ENGINE_Encode_ImportAudio_GUI"); // Get a reference the Module Tree's audio player. const var AudioPlayer = Synth.getChildSynth("AudioPlayer"); const var AudioPlayerASP = Synth.getAudioSampleProcessor("AudioPlayer"); // Connect the Audiowaveform component to the audio player. wave_ENGINE_Encode_ImportAudio_GUI.referToData(AudioPlayer); // Create the broadcaster. const var encoderFileBroadcaster = Engine.createBroadcaster({ "id": "File Watcher", "colour": -1, "args": ["processorId", "fileIndex", "value"] }); // This makes the broadcast work. If you don't do this, it won't. encoderFileBroadcaster.setEnableQueue(true); // An audio file is a complex data type. To attach it to the audio player, we need this funciton. // Ensure you have set the sample index in the AudioWaveform Component to 0. encoderFileBroadcaster.attachToComplexData( "AudioFile.Content", "AudioPlayer", 0, "Audio Player File"); // Add something to listen to the audio file broadcast message. You can use any component that exists in your project. // I'm using the AudioFile Component to keep things clear. encoderFileBroadcaster.addListener({"id": "wave_ENGINE_Encode_ImportAudio_GUI"}, "some description about the target", function(index, isTrue) { // Your function goes here. });
5) How do you clear the waveform from an SAW (and by extension, the Audio Sample Processor and Loop Player)?
As per @d-healey (cheers):
AudioLoopPlayer1.setFile(-1);
Thank you!
-
C clevername27 marked this topic as a question
-
@clevername27 Bump.
-
-
It should work automatically, as long as the control is connected to a loop player or sampler. Interestingly Simon had a similar issue with drag n drop MIDI
-
What do you mean by play audio in?
-
You'd need to overlay a panel on top of the waveform control I think. Check out Christoph's custom sample import tutorial project - I think it has a bug in the recent versions of HISE so you might need to tweak it when you first open it.
-
You can get a reference to your audio loop player, from that you can get a reference to its Audio File, and to that you can attach a callback - I don't know if there is another way.
const AudioLoopPlayer1 = Synth.getAudioSampleProcessor("Audio Loop Player1"); const af = AudioLoopPlayer1.getAudioFile(0); af.setContentCallback(function() { Console.print("HELLO WORLD"); });
AudioLoopPlayer1.setFile(-1);
-
-
@d-healey Thank you, my dude. I shall see what is up…
-
It should work automatically, as long as the control is connected to a loop player or sampler. Interestingly Simon had a similar issue with drag n drop MIDI.
I'm wondering if something may be timing out. I have like 700 Components in my tree. In any case, I can live with right-click. :)
What do you mean by play audio in?
Poorly worded on my part. I'm looking please to start and stop the loop player. Something like:
AudioLoopPlayer.start()
andAudioLoopPlayer.stop()
.You can get a reference to your audio loop player, from that you can get a reference to its Audio File, and to that you can attach a callback - I don't know if there is another way.
Thank you, yes! I was so inspired, I did a Broadcaster implementation, as well.
You'd need to overlay a panel on top of the waveform control I think. Check out Christoph's custom sample import tutorial project - I think it has a bug in the recent versions of HISE so you might need to tweak it when you first open it.
Thank you - I did check that out - very cool; lets you recreate part of the sample editor in your own code!
So thinking about it more, I'm just looking for the playhead to display in the Audiowave Component while it plays (i.e., after
AudioLoopPlayer.start()
); -
@clevername27 said in Basic Questions on ScriptAudioWaveforms…?:
I'm wondering if something may be timing out. I have like 700 Components in my tree
Easy to test. Make a blank project and add a waveform controls and loop player.
@clevername27 said in Basic Questions on ScriptAudioWaveforms…?:
Poorly worded on my part. I'm looking please to start and stop the loop player. Something like: AudioLoopPlayer.start() and AudioLoopPlayer.stop().
The loop player is triggered by MIDI note on and off I think, so
Synth.playNote
maybe - I'm just guessing. -
Easy to test. Make a blank project and add a waveform controls and loop player.
@clevername27 said in Basic Questions on ScriptAudioWaveforms…?:
Good thought. Yes, it works with a canonical implementation. But not in my plugin. :(
The loop player is triggered by MIDI note on and off I think, so Synth.playNote maybe - I'm just guessing.
Thank you, yes — we're exploring that in another thread. I'll post the answer if/when we find it.
-
C clevername27 has marked this topic as solved