I’m trying to make a thing in c# that displays the wave of a sound (like a sine/saw/square wave, idk if there’s a name for that type of thing). I’m working with Celeste’s game engine so I’m restricted to using FMOD version 1.10.00, and also cannot get debug information because Celeste initializes fmod in a place I can’t access easily.
I set up 4 events (for 4 different waves) and am playing them one after the other, with a 3 second delay. This is the code I’m using:
private IEnumerator testWaves()
{
inRoutine = true;
string[] waves = new string[] { "sine", "square", "tri", "saw" };
string path = "event:/PianoBoy/Soundwaves/";
for (int i = 0; i < waves.Length; i++)
{
SoundSource.Play(path + waves[i]);
while (SoundSource.instance is null)
{
yield return null;
}
SoundSource.instance.getChannelGroup(out ChannelGroup group);
while (group is null)
{
SoundSource.instance.getChannelGroup(out group);
yield return null;
}
group.getNumChannels(out int n);
if (n == 0)
{
Console.WriteLine("no channels in wave " + waves[i]);
}
else
{
Console.WriteLine("-----------Looping through " + n + " channels in wave " + waves[i] + "------------");
for (int j = 0; j < n; j++)
{
group.getChannel(j, out Channel channel);
channel.getFrequency(out float f);
Console.WriteLine($"Playing {waves[i]} wave with frequency {f}.");
}
}
yield return 3;
}
yield return null;
inRoutine = false;
}
Just for context, I’m using this IEnumerator method as a “Coroutine”, which is a Component in Celeste which will wait x amount of time using “yield return x” before continuing through the method. “yield return null” makes it wait a single frame.
Also, “SoundSource” is another Component that handles creating the event instance and other stuff like the position and the status of the instance.
This is what is sent to the Console after the Coroutine runs:
"no channels in wave sine"
"no channels in wave square"
"no channels in wave tri"
"no channels in wave saw"
I’ve looked around for why this is happening but I can’t find any issue related to an instance having no channels in it’s channel group, what’s going on?