HISE Logo Forum
    • Categories
    • Register
    • Login

    How does a custom c++ interface with one of its display buffers?

    Scheduled Pinned Locked Moved C++ Development
    9 Posts 3 Posters 452 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.
    • O
      Orvillain
      last edited by

      89e88a5c-e9e6-4086-b335-907c5b680cd1-image.png

      I am working on a custom node. I am taking in external audio data and processing it with a downsampler, a gate, and a high-pass filter.

      I want to plot the result of my processing chain to the display buffer. But I don't know how.

      This node is an offline node - it doesn't process frames. Well... actually that is not true... it does, but only for parameter debouncing. It processes the loaded audio in full, rather than frames or blocks; though I don't think this is really relevant to the question, it is just some background.

      griffinboyG 1 Reply Last reply Reply Quote 0
      • griffinboyG
        griffinboy @Orvillain
        last edited by

        @Orvillain

        Yeah it's possible. Take a look at the source for external data

        ExternalData.txt

        favicon

        Google Docs (drive.google.com)

        You can write to display buffers. But we warned, these are ring buffers and so personally I've had issues with it wrapping and having the wrong size, stuff like that. Christoph can probably set you straight. But the methods for writing into the data slot are in this header I think!

        O 1 Reply Last reply Reply Quote 0
        • O
          Orvillain @griffinboy
          last edited by

          @griffinboy said in How does a custom c++ interface with one of its display buffers?:

          @Orvillain

          Yeah it's possible. Take a look at the source for external data

          ExternalData.txt

          favicon

          Google Docs (drive.google.com)

          You can write to display buffers. But we warned, these are ring buffers and so personally I've had issues with it wrapping and having the wrong size, stuff like that. Christoph can probably set you straight. But the methods for writing into the data slot are in this header I think!

          Groovy, cheers!! I can't really suss it out.

          I don't need the buffer to update with the processFrame method or anything like that. I just want to effectively set its size once, and blat a bunch of data into it. I tried accessing the ring buffer using 'rb' like this:

          if (auto lock = DataReadLock(this))
          {
          	if (rb != nullptr)
          	{
          		rb->write(env.data(), static_cast<int>(env.size()));
          	}
          }
          
          But it doesn't like the data I'm trying to feed it.
          
          O 1 Reply Last reply Reply Quote 0
          • O
            Orvillain @Orvillain
            last edited by

            I resorted to ChatGPT. This compiles:

            		// === Write to display buffer ===
            		if (auto* ringBuffer = dynamic_cast<SimpleRingBuffer*>(this->externalData.obj))
            		{
            			DataWriteLock lock(this); // Required to write safely
            
            			auto& targetBuffer = ringBuffer->getWriteBuffer();
            			const int numSamples = static_cast<int>(env.size());
            
            			// Resize to match env
            			targetBuffer.setSize(1, numSamples, false, false, true);
            
            			for (int i = 0; i < numSamples; ++i)
            				targetBuffer.setSample(0, i, env[i]);
            
            		}
            

            But I don't get any data displaying in the display buffer; whether I look at embedded or the 0th external slot.

            O HISEnbergH 2 Replies Last reply Reply Quote 0
            • O
              Orvillain @Orvillain
              last edited by

              I ended up piping data through a global cable and plotting it to a scriptPanel - it is pretty good actually!!!

              But I would like to know how to utilise the display buffers directly on the node.

              1 Reply Last reply Reply Quote 0
              • HISEnbergH
                HISEnberg @Orvillain
                last edited by

                @Orvillain Thanks for sharing this! Did you ever solve the initial problem of using the display buffer however? It looks like it should be relatively straightforward but I'm not able to work through the source code and find an immediate solution.

                O 1 Reply Last reply Reply Quote 0
                • O
                  Orvillain @HISEnberg
                  last edited by

                  @HISEnberg I'm afraid not! I gave up after I figured out how to pipe what I needed through a global cable, and then HISEscript takes over and plots it to a script panel. So I never really went back.

                  HISEnbergH 1 Reply Last reply Reply Quote 0
                  • HISEnbergH
                    HISEnberg @Orvillain
                    last edited by

                    @Orvillain Okay no worries. I am in the same position for now (displaying compressor reduction) and managed to get the data out to a global cable so I can just draw that to a panel. I would like to know the proper way to do this for future purposes however (audio waveforms, etc.) Will post here if I figure it out!

                    griffinboyG 1 Reply Last reply Reply Quote 0
                    • griffinboyG
                      griffinboy @HISEnberg
                      last edited by

                      @HISEnberg

                      I think christoph would know for sure.
                      I did manage to do it but it had inconsistent quirks that seemed to do with the display buffer length not matching up with what I was sending it (Holding on to a longer history)

                      So I'm hesitant to share an incomplete solution. I'm not sure how resizing it works

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post

                      22

                      Online

                      1.8k

                      Users

                      12.0k

                      Topics

                      104.1k

                      Posts