A 3d fps game made in OpenGL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Symmetry/include/common/soloud/soloud_bus.h

86 lines
3.2 KiB

/*
SoLoud audio engine
Copyright (c) 2013-2014 Jari Komppa
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
#ifndef SOLOUD_BUS_H
#define SOLOUD_BUS_H
#include "soloud.h"
namespace SoLoud
{
class Bus;
class BusInstance : public AudioSourceInstance
{
Bus *mParent;
unsigned int mScratchSize;
AlignedFloatBuffer mScratch;
public:
// Mono-mixed wave data for visualization and for visualization FFT input
float mVisualizationWaveData[256];
BusInstance(Bus *aParent);
virtual void getAudio(float *aBuffer, unsigned int aSamples);
virtual bool hasEnded();
virtual ~BusInstance();
};
class Bus : public AudioSource
{
public:
Bus();
virtual BusInstance *createInstance();
// Set filter. Set to NULL to clear the filter.
virtual void setFilter(unsigned int aFilterId, Filter *aFilter);
// Play sound through the bus
handle play(AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f, bool aPaused = 0);
// Play sound through the bus, delayed in relation to other sounds called via this function.
handle playClocked(time aSoundTime, AudioSource &aSound, float aVolume = 1.0f, float aPan = 0.0f);
// Start playing a 3d audio source through the bus
handle play3d(AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f, bool aPaused = 0);
// Start playing a 3d audio source through the bus, delayed in relation to other sounds called via this function.
handle play3dClocked(time aSoundTime, AudioSource &aSound, float aPosX, float aPosY, float aPosZ, float aVelX = 0.0f, float aVelY = 0.0f, float aVelZ = 0.0f, float aVolume = 1.0f);
// Set number of channels for the bus (default 2)
result setChannels(unsigned int aChannels);
// Enable or disable visualization data gathering
void setVisualizationEnable(bool aEnable);
// Calculate and get 256 floats of FFT data for visualization. Visualization has to be enabled before use.
float *calcFFT();
// Get 256 floats of wave data for visualization. Visualization has to be enabled before use.
float *getWave();
public:
BusInstance *mInstance;
unsigned int mChannelHandle;
// FFT output data
float mFFTData[256];
// Snapshot of wave data for visualization
float mWaveData[256];
// Internal: find the bus' channel
void findBusHandle();
};
};
#endif