The audio engine provides a mean to play simple wav files and to stream audio directly to the hardware.
The audio engine in You.i Engine allows for audio playback of wave files. It can also be used to play streams from custom sources.
The simplest way to play sounds using the audio engine, is to call PlaySound:
// Get the global instance of the audio engine
CYIAudioEngine *pAudioEngine = CYIFramework::GetInstance()->GetAudioEngine();
// Play a sound using asset name
pAudioEngine->PlaySound("sound1.wav");
This loads the asset if it is not cached in the audio engine already, creates a sound instance and plays it immediately.
The You.i Engine provides a way to stream any audio output to the audio engine by simply inheriting from CYIAudioStream and implementing the pure virtual method Process().
Here example code to create a noise generator:
class NoiseGenerator : public CYIAudioStream
{
bool Process(CYIAudioEngine *pAudioEngine, float *pData, uint32_t uFrameCount)
{
uint32_t uCount = uFrameCount * pAudioEngine->GetChannelCount();
for (uint32_t i = 0; i < uCount; ++i)
{
pData[i] += ((float)(rand() % 10001) - 5000.0f) / 50000.0f; // Noise at 10% volume
}
return true;
}
};Classes | |
| class | CYIAudioEngine |
| Object responsible for processing audio streams and output to the platform. More... | |
| class | CYIAudioStream |
| Base audio stream class that can process raw audio PCM. More... | |
| class | CYISoundInstance |
| Object representing a sound instance. More... | |
| class | CYISpeechSynthesizer |
| Provides text-to-speech functionality using the underlying platform's technology. More... | |