Skip to content
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

multi instance support #20

Open
doing-fine-thanks opened this issue Dec 21, 2023 · 9 comments
Open

multi instance support #20

doing-fine-thanks opened this issue Dec 21, 2023 · 9 comments
Assignees

Comments

@doing-fine-thanks
Copy link

Hey! I was curious if there were any plans/timelines for multi instance support. I am working some Godot addons using this library (via gdext), but I am sort of stuck until multiple instances are supported. The global allocation means all patches play from all audio sources in a game scene at the same time (unless I am missing something).

Thank you so much in advanced/for all y'alls work!

@alisomay
Copy link
Owner

There were no plans currently but since a need has appeared, actually why not.
It is just that probably I'll not dive in and implement it until a few months later on the other hand I'm always open to PRs.

I kind of burnt myself out with these projects

On the other hand it is really nice to hear that somebody is using this ✨

About your issue, I understood the global instance as

  • There is only one instance of pd is allocated which means one audio processing block.
  • I didn't check how the multi instance feature behaves yet.

I am not familiar with game audio systems but I assume that you have some audio sources and they generate or process audio (each one has their own processing block) and then all is mixed in the main high prio audio thread?

@doing-fine-thanks
Copy link
Author

Hey! Super understand the burn out (hence me getting into game development after ~6 years doing big-data architecture work).

In terms of game audio: what you outlined is my understanding of it too (admittedly very new to game engines and rust programming).

My current usage of this library is passing a buffer stored on each audio object in a game scene to the global pd object, taking the buffer and handing them off a Generator playback in Godot and letting the audio server code manage the mix/spatialization of the various elements.

The issues I am running into are:

  • Loading of multiple patches (each audio source in the game may need a different patch, and these audio sources would have to be processes ~60 times a second).
  • Stuttering when trying to play more than a single audio source as the global instance swaps between more than a single patch.

I can take a look, but as a Rust nooby, I am not totally sure where to begin with that.

@alisomay
Copy link
Owner

I see, it seems that multi instance support seems a nice fit to widen your bottle neck.
It shouldn't be very complicated to add that. I was planning to do it sometime anyway.
I'll see what I can do and let you know here if there are any updates ✨
If there are other contributor candidates reading this issue, I'm open to PRs.

@doing-fine-thanks
Copy link
Author

Thank you so much!

@alisomay
Copy link
Owner

I took a look at it this morning.
I think it might take approximately ~3 days of work to

  • Reorganize the existing data structures to support multi instance while keeping the single instance functionality and put those under feature flags.
  • Update the comments, tests and doc tests to support multi instance
  • Change convenience module to support both cases single instance and multi instance
  • Add multi instance examples and introduction to the tutorial
  • Test for all major platforms
  • Fix bugs and obscure memory errors along the way.

I'll try to look at these whenever I have enough time budget to allocate.
I'll give updates.

@alisomay alisomay self-assigned this Dec 27, 2023
@alisomay
Copy link
Owner

alisomay commented Jan 2, 2024

It is progressing with no blocks.
I can not work on it very frequently but probably finish it sometime this month.

@alisomay
Copy link
Owner

@danomatika
Copy link

danomatika commented Feb 8, 2024

@doing-fine-thanks "Multi-instance" refers to entirely separate pure data environments. Think VST environments where audio plugins are running at different places and along different signal chains. It seems like what you are having issues with is working with multiple abstractions, aka instances of the same patch, within a single Pure Data environment. In this case, you can use the unique $0 id to differentiate between them and/or your own messaging structures ala send/recieve names. If you can make it work within a single desktop Pd, you don't need multiple Pd instances.

@doing-fine-thanks
Copy link
Author

Hey, sorry for not chiming in for a bit. I do actually mean separate patches with different buffers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants