-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
reduce sample buffer memory usage #11988
reduce sample buffer memory usage #11988
Conversation
9216fa7
to
9aefb27
Compare
I'll take a look at the compiler errors later today, this is strange my build didn't pick it up. |
9aefb27
to
638c747
Compare
I've run the tests and some failed:
Let's see if it is a regression. |
The regression is caused by: |
638c747
to
4f798ae
Compare
Actually the problem found by the test suite is in the test itself. The test will perform a for loop to consume all the input and only the latest block will remain in memory, while it will then compare it to the full length buffer. |
4f798ae
to
d4c5bea
Compare
d4c5bea
to
72eda03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for the pedantic comments in regards to our codestyle, but we really want to maintain some consistency here. If there are good reasons to change something we'd love to discuss possible improvements.
72eda03
to
d6d7f40
Compare
It is your house, keep it clean. 👍 |
Regarding the max buffer size, a few thing.
I don't think there is a point in working in higher sample rate than 48K except if your HW can't do it. Then in soundmanagerconfig.h: // Size1xms presents the first buffer size of 2^X
// that results in a buffer time above 1 ms
// It is 1.45 ms @ 44.1 kHz
// The other values are representing the following 2^X sizes.
enum class AudioBufferSizeIndex {
Size1xms = 1,
Size2xms = 2,
Size5xms = 3,
Size10xms = 4,
Size20xms = 5,
Size40xms = 6,
Size80xms = 7,
};
// Represents the sample rate independent frame/period
// index values in case of Jack
enum class JackAudioBufferSizeIndex {
SizeAuto = 5,
Size2048fpp = 6,
Size4096fpp = 7,
};
static constexpr auto kMaxAudioBufferSizeIndex =
static_cast<unsigned int>(AudioBufferSizeIndex::Size80xms);
static constexpr auto kDefaultAudioBufferSizeIndex =
static_cast<unsigned int>(AudioBufferSizeIndex::Size20xms); So at 44.1, min is 64 samples, max 4096. Now the sample rate: static constexpr value_t kValueMin = 8000; // lower bound (inclusive, = minimum MP3 sample rate)
static constexpr value_t kValueMax = 192000; // upper bound (inclusive) You've decided to support up to 192kHz. Here I suggest three things:
I really think that offering 2K at 44.1kHz is not a service to the user. Let me know in which direction we're going and I'll adjust the settings dialog and clamp it well. |
I'm not familiar with many parts of the audio engine, but I think we already do support low latency's via low periods, the thing is just that sometimes we just allocate
That might be true for the majority of users, but some users still want that higher samplerate. Same applies for latency (better to have high latency and no underruns instead of constant underruns). Unless this forces us to make tradeoffs that worsens the experience for the majority, I don't see why we shouldn't support those buffer sizes & samplerates.
I think its reasonable to expect users to know what settings they're choosing. If people want to use those settings because they might be forced to its better to let them instead of patronizing them in that regard. |
Not necessarily, it could be that someone just wants to try mixing, doesn't know about buffer size and its implications and ends up with a setting leading to a bad user experience. Having more options doesn't means a better beginner experience. Let's keep the current settings then, but maybe consider advertising 256@44.1kHz as a good default (or even 128). Currently the drop down menu doesn't give any hint, maybe add an |
d6d7f40
to
b464684
Compare
Yes, we should definitely try to choose a good default, but we shouldn't take options away from power users or people that know what they're doing just so beginners don't accidentally choose the wrong setting. |
b464684
to
dbd21c1
Compare
dbd21c1
to
7edfd32
Compare
Something you could consider, is to always run the engine at 44.1kHz or 48kHz, and then down/up sample before reading/writing to the audio interface. |
5810308
to
72ccc99
Compare
693f0e5
to
298dc78
Compare
I've made |
8c7f587
to
84255ce
Compare
84255ce
to
c8b99a5
Compare
3eb8bdb
to
ba1ac45
Compare
BTW, I've run the tests with ASAN. |
Hi, |
Yes, I had a brief review and it looks good now. I just want to do some test. Hope I find time soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All is working good. Thank you very much.
This set of changes reduce the amount of memory used by the application for storing audio samples.
Here two memory dump (SVG), before and after so you can compare.
pprof-after
pprof-before
I had a look over BalanceGroupState, and this one is safe to shrink.