-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shared usage of buffers by multiple instances of rnbo? #32
Comments
Unfortunately RNBO's buffers are always read/write as far as the plugin knows so to be safe we have to make copies of the data. I figure we could make an "unsafe" interface that would let you set a buffer without doing a copy if you know for sure that your rnbo patch doesn't do any writing/resizing, and this way you might be able to point directly to audio assets and simply have them loaded once? |
that would be awesome!!! i'm working with spatial grains and there will be no recording in the rnbo plugin whatsoever! |
@chausch I just created a new The loading approach is the same as before, but you'll just have to manage having some global Let me know if/how this works for you? |
thank you so much! do i understand that correctly that i have to load the audio data into this float array at another location, and pass it to the rnbo plugin? |
HA! it seems to work!! 🥳 |
Yeah, if you look at the buffer documentation that I linked above you'll see the approach, loading the data into a float array. Something like: using UnityEngine;
using Cycling74.RNBOTypes;
public class PlayerMovement : MonoBehaviour
{
const int instanceIndex = 1;
BufferPlayerHelper helper;
BufferPlayerHandle plugin;
public float speed = 6f;
private static float[] samples;
[SerializeField] AudioClip buffer;
void Start() {
helper = BufferPlayerHelper.FindById(instanceIndex);
plugin = helper.Plugin;
if (buffer != null && plugin != null)
{
if (samples == null) {
samples = new float[buffer.samples * buffer.channels];
}
buffer.GetData(samples, 0);
plugin.LoadUnsafeReadOnlyDataRef("playback", samples, buffer.channels, buffer.frequency);
}
}
} seems like you figured it out though! |
we still have to make a single copy of the data as it could be MP3, int16 wav, etc etc and we need 32-bit float, but I'm curious to hear about the memory usage you're seeing after this change. |
merged to main |
hi there,
is it possible to access the same buffers by multiple instances by a rnbo plugin, without the need to load the same data into multiple buffers?
i have many instances running at the same time (though not all activated at the same time) and the current implementation, by which one has to load the sample directly into the plugin quickly amounts to gigabytes of gigabytes of memory usage!
thanks for any advice!
The text was updated successfully, but these errors were encountered: