Replies: 2 comments 1 reply
-
UpdateI've added the code below right after initializing the sound and I can hear changes in the volume and pitch when I do : ma_sound_group_set_pitch(&soundGroup, 2);
ma_sound_group_set_volume(&soundGroup, 1);
Update 2It seems that I have to start the the sound with Updated code: #define MINIAUDIO_IMPLEMENTATION
//#define MA_DEBUG_OUTPUT
#include "../../../miniaudio/miniaudio.h"
#include <stdio.h>
void play(char *path)
{
ma_result result;
ma_engine engine;
ma_sound_group_config soundGroupConfig; // is this needed?
ma_sound_group soundGroup;
result = ma_engine_init(NULL, &engine);
if (result != MA_SUCCESS)
{
printf("Failed to initialize audio engine.");
exit(1);
}
// ma_engine* pEngine, ma_uint32 flags, ma_sound_group* pParentGroup, ma_sound_group* pGroup)
result = ma_sound_group_init(&engine, 0, NULL, &soundGroup);
if (result != MA_SUCCESS)
{
printf("Failed to init sound group.");
exit(1);
}
ma_sound sound;
result = ma_sound_init_from_file(&engine, path, MA_SOUND_FLAG_DECODE | MA_SOUND_FLAG_STREAM | MA_SOUND_FLAG_NO_SPATIALIZATION, &soundGroup, NULL, &sound);
if (result != MA_SUCCESS)
{
printf("Failed to load sound file.");
exit(1);
}
//ma_node_attach_output_bus(&soundGroup, 0, ma_engine_get_endpoint(&engine), 0);
ma_sound_group_set_pitch(&soundGroup, 2);
ma_sound_group_set_volume(&soundGroup, 1);
ma_sound_start(&sound);
result = ma_sound_group_stop(&soundGroup);
ma_sound_group_start(&soundGroup);
while (ma_sound_at_end(&sound) == 0)
{
}
ma_sound_stop(&sound);
ma_engine_uninit(&engine);
return;
}
int main()
{
printf("starting simple sound group\n\n");
char * filePath = "/Users/admin/Downloads/testing123.wav";
play(filePath);
return 0;
}
|
Beta Was this translation helpful? Give feedback.
-
Sound groups will not help you with that. There is no way to easily retrieve the list of sounds attached to a group (there's a lot of non-trivial details relating to lock-free stuff). It's expected that you will have your own list of sounds that you manage yourself. The idea of a sound group is to apply some audio processing (such as an effect or volume control) to a group of sounds after they've been mixed together. It's not for managing the state of your
Yes, this is expected behaviour. Like I mentioned above, sounds groups are not for managing the state of individual |
Beta Was this translation helpful? Give feedback.
-
I want to use sound groups in my code to help manage lists of sounds. I imagine instead of looping through all sounds to manipulate them (start, stop, etc.), I could assign sounds on the same "track" to a group and apply changes to them in a cleaner way.
After poking around, I see that there are no examples related to using sound groups, I guess because the API is the same as ma_sound. Despite that, I'm not clear on how to make sound groups work. I have a simple example below. In my mind a possible scenario is this:
Code:
In the code below If have
result = ma_sound_group_start(&soundGroup);
, which does not produce any sound. I'm wondering what I'm missing?Beta Was this translation helpful? Give feedback.
All reactions