HISE Logo Forum
    • Categories
    • Register
    • Login

    Basic Questions on ScriptAudioWaveforms…?

    Scheduled Pinned Locked Moved Solved Scripting
    7 Posts 2 Posters 130 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.
    • clevername27C
      clevername27
      last edited by clevername27

      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!

      clevername27C d.healeyD 2 Replies Last reply Reply Quote 0
      • clevername27C clevername27 marked this topic as a question on
      • clevername27C
        clevername27 @clevername27
        last edited by

        @clevername27 Bump.

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

          @clevername27

          1. 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

          2. What do you mean by play audio in?

          3. 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.

          4. 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");
          });
          
          1. AudioLoopPlayer1.setFile(-1);

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

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

            @d-healey Thank you, my dude. I shall see what is up…

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

              @d-healey

              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() and AudioLoopPlayer.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());

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

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

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

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

                  @d-healey

                  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.

                  1 Reply Last reply Reply Quote 0
                  • clevername27C clevername27 has marked this topic as solved on
                  • First post
                    Last post

                  55

                  Online

                  1.7k

                  Users

                  11.7k

                  Topics

                  101.8k

                  Posts