本文整理汇总了C++中fmod::System类的典型用法代码示例。如果您正苦于以下问题:C++ System类的具体用法?C++ System怎么用?C++ System使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了System类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Audio
// Initializes FMOD Studio and loads all sound banks.
Audio() :
Listener(system)
{
// Create the FMOD Studio system.
FmodCall(fmod::System::create(&system));
// Initialize the system.
FmodCall(system->initialize(
maxChannels, // max channels capable of playing audio
FMOD_STUDIO_INIT_NORMAL, // studio-specific flags
FMOD_INIT_3D_RIGHTHANDED, // regular flags
nullptr)); // extra driver data
vector<fmod::Bank*> banks;
// For each file in the Sounds directory with a *.bank extension:
for (const string& file : PathInfo(config::Sounds).FilesWithExtension("bank"))
{
// Load the sound bank from file.
fmod::Bank* bank = nullptr;
FmodCall(system->loadBankFile(file.c_str(), FMOD_STUDIO_LOAD_BANK_NORMAL, &bank));
banks.push_back(bank);
}
for (fmod::Bank* bank : banks)
{
// Get the number of events in the bank.
int eventCount = 0;
FmodCall(bank->getEventCount(&eventCount));
if (eventCount == 0) continue;
// Get the list of event descriptions from the bank.
auto eventArray = vector<fmod::EventDescription*>(static_cast<size_t>(eventCount), nullptr);
FmodCall(bank->getEventList(eventArray.data(), eventArray.size(), nullptr));
// For each event description:
for (fmod::EventDescription* eventDescription : eventArray)
{
// Get the path to the event, e.g. "event:/Ambience/Country"
auto path = string(512, ' ');
int retrieved = 0;
FmodCall(eventDescription->getPath(&path[0], path.size(), &retrieved));
path.resize(static_cast<size_t>(retrieved - 1)); // - 1 to account for null character
// Save the event description in the event map.
eventDescriptionMap.emplace(path, EventDescription(eventDescription, path));
}
}
Note(*this);
}
开发者ID:ItsRoyScott,项目名称:Lite,代码行数:52,代码来源:Audio.hpp
示例2: mouseDown
void StepTwoApp::mouseDown( MouseEvent event )
{
int n;
FMODErrorCheck( mSystem->getChannelsPlaying(&n) );
if(n>=32) {
console() << "Too many sounds playing!" << endl;
return;
}
FMOD::Sound* sound = mSounds[Rand::randInt(mSounds.size())];
// Channels inherit the modes of sounds.
FMOD::Channel* channel;
mSystem->playSound( FMOD_CHANNEL_FREE, sound, false, &channel );
}
开发者ID:KitchenTableCoders,项目名称:3daudio,代码行数:16,代码来源:StepTwoApp.cpp
示例3: update
void AudioVisualizerApp::update()
{
// update FMOD so it can notify us of events
mFMODSystem->update();
// handle signal: if audio has ended, play next file
if(mIsAudioPlaying && signalChannelEnd)
playAudio( nextAudio( mAudioPath ) );
// reset FMOD signals
signalChannelEnd= false;
// get spectrum for left and right channels and copy it into our channels
float* pDataLeft = mChannelLeft.getData() + kBands * mOffset;
float* pDataRight = mChannelRight.getData() + kBands * mOffset;
mFMODSystem->getSpectrum( pDataLeft, kBands, 0, FMOD_DSP_FFT_WINDOW_HANNING );
mFMODSystem->getSpectrum( pDataRight, kBands, 1, FMOD_DSP_FFT_WINDOW_HANNING );
// increment texture offset
mOffset = (mOffset+1) % kHistory;
// clear the spectrum for this row to avoid old data from showing up
pDataLeft = mChannelLeft.getData() + kBands * mOffset;
pDataRight = mChannelRight.getData() + kBands * mOffset;
memset( pDataLeft, 0, kBands * sizeof(float) );
memset( pDataRight, 0, kBands * sizeof(float) );
// animate camera if mouse has not been down for more than 30 seconds
if(!mIsMouseDown && (getElapsedSeconds() - mMouseUpTime) > mMouseUpDelay)
{
float t = float( getElapsedSeconds() );
float x = 0.5f + 0.5f * math<float>::cos( t * 0.07f );
float y = 0.1f - 0.2f * math<float>::sin( t * 0.09f );
float z = 0.25f * math<float>::sin( t * 0.05f ) - 0.25f;
Vec3f eye = Vec3f(kWidth * x, kHeight * y, kHeight * z);
x = 1.0f - x;
y = -0.3f;
z = 0.6f + 0.2f * math<float>::sin( t * 0.12f );
Vec3f interest = Vec3f(kWidth * x, kHeight * y, kHeight * z);
// gradually move to eye position and center of interest
mCamera.setEyePoint( eye.lerp(0.995f, mCamera.getEyePoint()) );
mCamera.setCenterOfInterestPoint( interest.lerp(0.990f, mCamera.getCenterOfInterestPoint()) );
}
}
开发者ID:20SecondsToSun,项目名称:Cinder-Samples,代码行数:47,代码来源:AudioVisualizerApp.cpp
示例4: shutdown
void AudioVisualizerApp::shutdown()
{
// properly shut down FMOD
stopAudio();
if( mFMODSystem )
mFMODSystem->release();
}
开发者ID:UIKit0,项目名称:Cinder-Samples,代码行数:8,代码来源:AudioVisualizerApp.cpp
示例5: playEnvironment
int Game::playEnvironment()
{
bool soundDone=false;
FMOD::System* system;
FMOD_RESULT result = FMOD::System_Create(&system);
system->init(32, FMOD_INIT_NORMAL, NULL);
FMOD::Sound* sound;
result = system->createSound("Ocean.WAV",FMOD_LOOP_NORMAL,NULL, &sound);
FMOD::Channel* channel = 0;
bool pauseSound = false;
channel->isPlaying(&pauseSound);
result = system->playSound(FMOD_CHANNEL_FREE, sound,false, &channel);
soundDone=true;
while (soundDone!=true)
{
channel->setPaused(false);
system->update();
result = sound->release();
result = system->close();
result = system->release();
}
return 0;
}
开发者ID:Acularius,项目名称:Pixel-Brother,代码行数:30,代码来源:Game.cpp
示例6:
void playBackground(void)
{
FMOD::System * Syst = NULL;
FMOD::Channel * Chan = NULL;
FMOD::Sound * s;
if (Syst == NULL)
{
if (FMOD::System_Create(&Syst) != FMOD_OK)
fmod_exit();
if (Syst->init(32, FMOD_INIT_NORMAL, 0) != FMOD_OK)
fmod_exit();
}
if (Syst->createSound("mp3/background.mp3", FMOD_LOOP_NORMAL, 0, &s) != FMOD_OK)
fmod_exit();
if (Syst->playSound(s, NULL, false, &Chan) != FMOD_OK)
fmod_exit();
Syst->update();
}
开发者ID:alelievr,项目名称:md5,代码行数:19,代码来源:loadSounds.cpp
示例7: setup
void cinderFFmpegApp::setup()
{
m_Font = ci::Font("Consolas", 48);
setupGui();
gl::enableAlphaBlending();
std::shared_ptr<_2RealFFmpegWrapper::FFmpegWrapper> testFile = std::shared_ptr<_2RealFFmpegWrapper::FFmpegWrapper>(new _2RealFFmpegWrapper::FFmpegWrapper());
testFile->dumpFFmpegInfo();
//if(testFile->open(".\\data\\morph.avi"))
if(testFile->open("d:\\vjing\\Wildlife.wmv"))
{
m_Players.push_back(testFile);
m_VideoTextures.push_back(gl::Texture());
m_Players.back()->play();
}
m_dLastTime = 0;
m_iCurrentVideo = 0;
m_fSpeed = 1;
m_iLoopMode = _2RealFFmpegWrapper::eLoop;
m_iTilesDivisor = 1;
m_fSeekPos = m_fOldSeekPos = 0;
//setup fmod
FMOD::System_Create(&m_pSystem);
m_pSystem->init(32, FMOD_INIT_NORMAL, 0);
memset(&createsoundexinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
createsoundexinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); /* required. */
createsoundexinfo.decodebuffersize = 1024; /* Chunk size of stream update in samples. This will be the amount of data passed to the user callback. */
createsoundexinfo.numchannels = 2; /* Number of channels in the sound. */
createsoundexinfo.length = -1; /* Length of PCM data in bytes of whole song. -1 = infinite. */
createsoundexinfo.defaultfrequency = (int)44100; /* Default playback rate of sound. */
createsoundexinfo.format = FMOD_SOUND_FORMAT_PCM16; /* Data format of sound. */
createsoundexinfo.pcmreadcallback = pcmreadcallback; /* User callback for reading. */
result = m_pSystem->createStream(0, FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_OFF, &createsoundexinfo, &m_pSound);
result = m_pSystem->playSound(FMOD_CHANNEL_FREE, m_pSound, 0, &m_pChannel);
//std::shared_ptr<audio::Callback<cinderFFmpegApp,unsigned short>> audioCallback = audio::createCallback( this, &cinderFFmpegApp::audioCallback );
//audio::Output::play( audioCallback );
}
开发者ID:cadet,项目名称:_2RealFFmpegWrapper,代码行数:42,代码来源:cinderFFmpegApp.cpp
示例8: PlayRollSound
void FMOD_System::PlayRollSound()
{
if( roll != nullptr )
{
if( !IsPlaying( rollChannel ) && !IsPlaying( collisionChannel ) )
{
system->playSound( FMOD_CHANNEL_FREE, roll, true, &rollChannel );
rollChannel->set3DAttributes( &ballPosition, nullptr );
rollChannel->setPaused( false );
}
}
}
开发者ID:gemini14,项目名称:AirBall,代码行数:12,代码来源:SoundSystem.cpp
示例9: PlayJetSound
void FMOD_System::PlayJetSound()
{
if( jet != nullptr )
{
if( !IsPlaying( jetChannel ) )
{
system->playSound( FMOD_CHANNEL_FREE, jet, true, &jetChannel );
jetChannel->set3DAttributes( &ballPosition, nullptr );
jetChannel->setPaused( false );
}
}
}
开发者ID:gemini14,项目名称:AirBall,代码行数:12,代码来源:SoundSystem.cpp
示例10: PlayCollisionSound
void FMOD_System::PlayCollisionSound()
{
if( collision != nullptr )
{
if( !IsPlaying( collisionChannel ) )
{
system->playSound( FMOD_CHANNEL_FREE, collision, true, &collisionChannel );
collisionChannel->set3DAttributes( &ballPosition, nullptr );
collisionChannel->setPaused( false );
}
}
}
开发者ID:gemini14,项目名称:AirBall,代码行数:12,代码来源:SoundSystem.cpp
示例11: initializeSound
void initializeSound()
{
FMOD::System *system;
unsigned int version;
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
printf("Error! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION);
exit(-3);
}
result = system->init(32, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);
result = system->createSound("/Users/adrtwin/Music/What You Know (Mustang Remix).mp3", FMOD_SOFTWARE, 0, &sound1);
ERRCHECK(result);
/*
result = system->createSound("CALIBRATING", FMOD_SOFTWARE, 0, &sound2);
ERRCHECK(result);
result = system->createSound("SHOT", FMOD_SOFTWARE, 0, &sound3);
ERRCHECK(result);
result = system->createSound("SHOT_NO_AMMO", FMOD_SOFTWARE, 0, &sound4);
ERRCHECK(result);
result = system->createSound("RELOADING", FMOD_SOFTWARE, 0, &sound5);
ERRCHECK(result);
*/
globalSystem = system;
}
开发者ID:indieknite,项目名称:Super-Spray,代码行数:40,代码来源:SoundEffectsLibrary.cpp
示例12: createStreamingSound
FMOD::Sound* FMODAudioClip::createStreamingSound() const
{
if(getReadMode() != AudioReadMode::Stream || mStreamData == nullptr)
{
LOGERR("Invalid audio stream data.");
return nullptr;
}
FMOD_MODE flags = FMOD_CREATESTREAM;
FMOD_CREATESOUNDEXINFO exInfo;
memset(&exInfo, 0, sizeof(exInfo));
exInfo.cbsize = sizeof(exInfo);
// Streaming from memory not supported.
assert(mStreamData->isFile());
exInfo.length = mStreamSize;
exInfo.fileoffset = mStreamOffset;
SPtr<FileDataStream> fileStream = std::static_pointer_cast<FileDataStream>(mStreamData);
String pathStr = fileStream->getPath().toString();
if (is3D())
flags |= FMOD_3D;
else
flags |= FMOD_2D;
FMOD::Sound* sound = nullptr;
FMOD::System* fmod = gFMODAudio()._getFMOD();
if (fmod->createSound(pathStr.c_str(), flags, &exInfo, &sound) != FMOD_OK)
{
LOGERR("Failed creating a streaming sound.");
return nullptr;
}
sound->setMode(FMOD_LOOP_OFF);
return sound;
}
开发者ID:maximwreznikov,项目名称:BansheeEngine,代码行数:39,代码来源:BsFMODAudioClip.cpp
示例13: switch
MicrophoneRecorder::MicrophoneRecorder(int frequency, int channels, FMOD_SOUND_FORMAT format)
: m_fmodsnd(nullptr)
, m_fmodsys(nullptr)
, m_dataLength(0)
, m_byteSize(0)
, m_frequency(frequency)
, m_channels(channels)
{
switch (format)
{
case FMOD_SOUND_FORMAT_PCM8: m_byteSize = 1; break;
case FMOD_SOUND_FORMAT_PCM16: m_byteSize = 2; break;
case FMOD_SOUND_FORMAT_PCM24: m_byteSize = 3; break;
case FMOD_SOUND_FORMAT_PCM32: m_byteSize = 4; break;
case FMOD_SOUND_FORMAT_PCMFLOAT: m_byteSize = 4; break;
}
CHECK(m_byteSize > 0);
FMOD::System * fmodSys = SoundMngr::Get()->GetSys();
FMOD_CREATESOUNDEXINFO exinfo;
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels = channels;
exinfo.format = format;
exinfo.defaultfrequency = frequency;
exinfo.length = exinfo.defaultfrequency * m_byteSize * exinfo.numchannels * 2;
unsigned int flags = FMOD_SOFTWARE | FMOD_2D | FMOD_OPENUSER;
FMOD_ERRCHECK(fmodSys->createSound(0, flags, &exinfo, &m_fmodsnd));
m_fmodsys = fmodSys;
m_data.resize(channels);
}
开发者ID:kalineh,项目名称:nao-gm,代码行数:36,代码来源:MicrophoneRecorder.cpp
示例14: setup
void StepTwoApp::setup()
{
FMODListDevices();
FMODErrorCheck(FMOD::System_Create( &mSystem ));
FMODErrorCheck(mSystem->setDriver(0));
FMOD_INITFLAGS flags = FMOD_INIT_NORMAL; // right-click, Go To Definition
FMODErrorCheck(mSystem->init( 32, flags, NULL ));
vector<fs::path> paths;
paths.push_back( getAssetPath("gong-loud-hit.mp3") );
paths.push_back( getAssetPath("orch-hit.wav") );
paths.push_back( getAssetPath("trumpethit07.wav") );
for(auto& path: paths) {
FMOD::Sound* sound;
mSystem->createSound( path.string().c_str(), FMOD_SOFTWARE, NULL, &sound );
// You can change the mode of sounds at any time.
FMOD_MODE mode = FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_OFF;
FMODErrorCheck( sound->setMode( mode ) );
mSounds.push_back(sound);
}
}
开发者ID:KitchenTableCoders,项目名称:3daudio,代码行数:24,代码来源:StepTwoApp.cpp
示例15: draw
void _TBOX_PREFIX_App::draw()
{
gl::clear();
// grab 512 samples of the wave data
float waveData[512];
mSystem->getWaveData( waveData, 512, 0 );
// render the 512 samples to a VertBatch
gl::VertBatch vb( GL_LINE_STRIP );
for( int i = 0; i < 512; ++i )
vb.vertex( getWindowWidth() / 512.0f * i, getWindowCenter().y + 100 * waveData[i] );
// draw the points as a line strip
gl::color( Color( 1.0f, 0.5f, 0.25f ) );
vb.draw();
}
开发者ID:AbdelghaniDr,项目名称:Cinder,代码行数:17,代码来源:_TBOX_PREFIX_App.cpp
示例16: StartPlayingLoopingSounds
void FMOD_System::StartPlayingLoopingSounds()
{
if( bgmusic != nullptr )
{
system->playSound( FMOD_CHANNEL_FREE, bgmusic, false, nullptr );
}
if( ventSound != nullptr )
{
std::for_each( vents.begin(), vents.end(), [&]( VentPoint v )
{
FMOD::Channel *vent_channel;
FMOD_System::system->playSound( FMOD_CHANNEL_FREE, ventSound, true, &vent_channel );
FMOD_VECTOR position = { v.x, v.y, v.z };
vent_channel->set3DAttributes( &position, nullptr );
vent_channel->setPaused( false );
});
}
}
开发者ID:gemini14,项目名称:AirBall,代码行数:19,代码来源:SoundSystem.cpp
示例17: UpdateScene
void DuckHuntMain::UpdateScene(float dt)
{
//
// Control the camera.
//
if (GetAsyncKeyState('W') & 0x8000)
mCam.Walk(10.0f*dt);
if (GetAsyncKeyState('S') & 0x8000)
mCam.Walk(-10.0f*dt);
if (GetAsyncKeyState('A') & 0x8000)
mCam.Strafe(-10.0f*dt);
if (GetAsyncKeyState('D') & 0x8000)
mCam.Strafe(10.0f*dt);
//
// Animate the lights (and hence shadows).
//
////
//// Walk/fly mode
////
//if (GetAsyncKeyState('2') & 0x8000)
// mWalkCamMode = true;
//if (GetAsyncKeyState('3') & 0x8000)
// mWalkCamMode = false;
////
//// Clamp camera to terrain surface in walk mode.
////
XMFLOAT3 camPos = mCam.GetPosition();
float y = mTerrain.GetHeight(camPos.x, camPos.z);
mCam.SetPosition(camPos.x, y + 2.0f, camPos.z);
BuildShadowTransform();
mCam.UpdateViewMatrix();
mSystem->update();
}
开发者ID:mathewmanton,项目名称:DuckHunt,代码行数:42,代码来源:DuckHuntMain.cpp
示例18: playSound
int Game::playSound(bool Sound)
{
bool soundDone= false;
//declare variable for FMOD system object
FMOD::System* system;
//allocate memory for the FMOD system object
FMOD_RESULT result = FMOD::System_Create(&system);
//initialize the FMOD system object
system->init(32, FMOD_INIT_NORMAL, NULL);
//declare variable for the sound object
FMOD::Sound* sound;
//created sound object and specify the sound
result = system->createSound("Cathedral_of_Light.mp3",FMOD_LOOP_NORMAL,NULL, &sound);
// play sound - 1st parameter can be combined flags (| separator)
FMOD::Channel* channel = 0;
//start sound
bool pauseSound=false;
channel->isPlaying(&pauseSound);
result = system->playSound(FMOD_CHANNEL_FREE, sound, Sound, &channel);
soundDone=true;
while (soundDone!=true)
{
channel->setPaused(false);
system->update();
//}
// release resources
result = sound->release();
result = system->close();
result = system->release();
}
return 0;
}
开发者ID:Acularius,项目名称:Pixel-Brother,代码行数:42,代码来源:Game.cpp
示例19: FMOD_Main
int FMOD_Main()
{
FMOD::System *system;
FMOD::Channel *channel = 0;
FMOD::DSP *dsp;
FMOD_RESULT result;
unsigned int version;
void *extradriverdata = 0;
Common_Init(&extradriverdata);
/*
Create a System object and initialize.
*/
result = FMOD::System_Create(&system);
ERRCHECK(result);
result = system->getVersion(&version);
ERRCHECK(result);
if (version < FMOD_VERSION)
{
Common_Fatal("FMOD lib version %08x doesn't match header version %08x", version, FMOD_VERSION);
}
result = system->init(32, FMOD_INIT_NORMAL, extradriverdata);
ERRCHECK(result);
/*
Create an oscillator DSP units for the tone.
*/
result = system->createDSPByType(FMOD_DSP_TYPE_OSCILLATOR, &dsp);
ERRCHECK(result);
result = dsp->setParameterFloat(FMOD_DSP_OSCILLATOR_RATE, 440.0f); /* Musical note 'A' */
ERRCHECK(result);
/*
Main loop
*/
do
{
Common_Update();
if (Common_BtnPress(BTN_ACTION1))
{
if (channel)
{
result = channel->stop();
ERRCHECK(result);
}
result = system->playDSP(dsp, 0, true, &channel);
ERRCHECK(result);
result = channel->setVolume(0.5f);
ERRCHECK(result);
result = dsp->setParameterInt(FMOD_DSP_OSCILLATOR_TYPE, 0);
ERRCHECK(result);
result = channel->setPaused(false);
ERRCHECK(result);
}
if (Common_BtnPress(BTN_ACTION2))
{
if (channel)
{
result = channel->stop();
ERRCHECK(result);
}
result = system->playDSP(dsp, 0, true, &channel);
ERRCHECK(result);
result = channel->setVolume(0.125f);
ERRCHECK(result);
result = dsp->setParameterInt(FMOD_DSP_OSCILLATOR_TYPE, 1);
ERRCHECK(result);
result = channel->setPaused(false);
ERRCHECK(result);
}
if (Common_BtnPress(BTN_ACTION3))
{
if (channel)
{
result = channel->stop();
ERRCHECK(result);
}
result = system->playDSP(dsp, 0, true, &channel);
ERRCHECK(result);
result = channel->setVolume(0.125f);
ERRCHECK(result);
result = dsp->setParameterInt(FMOD_DSP_OSCILLATOR_TYPE, 2);
ERRCHECK(result);
result = channel->setPaused(false);
ERRCHECK(result);
}
if (Common_BtnPress(BTN_ACTION4))
{
if (channel)
//.........这里部分代码省略.........
开发者ID:Athlos,项目名称:Circuit-Collector,代码行数:101,代码来源:generate_tone.cpp
示例20: setup
void AudioVisualizerApp::setup()
{
// initialize signals
signalChannelEnd = false;
// make a list of valid audio file extensions and initialize audio variables
const char* extensions[] = { "mp3", "wav", "ogg" };
mAudioExtensions = vector<string>( extensions, extensions + 2 );
mAudioPath = getAssetPath( "" );
mIsAudioPlaying = false;
// setup camera
mCamera.setPerspective( 50.0f, 1.0f, 1.0f, 10000.0f );
mCamera.lookAt( vec3( -kWidth / 4, kHeight / 2, -kWidth / 8 ), vec3( kWidth / 4, -kHeight / 8, kWidth / 4 ) );
mCameraUi.setCamera( &mCamera );
// create channels from which we can construct our textures
mChannelLeft = Channel32f( kBands, kHistory );
mChannelRight = Channel32f( kBands, kHistory );
memset( mChannelLeft.getData(), 0, mChannelLeft.getRowBytes() * kHistory );
memset( mChannelRight.getData(), 0, mChannelRight.getRowBytes() * kHistory );
// create texture format (wrap the y-axis, clamp the x-axis)
mTextureFormat.setWrapS( GL_CLAMP_TO_BORDER );
mTextureFormat.setWrapT( GL_REPEAT );
mTextureFormat.setMinFilter( GL_LINEAR );
mTextureFormat.setMagFilter( GL_LINEAR );
mTextureFormat.loadTopDown( true );
// compile shader
try {
mShader = gl::GlslProg::create( loadAsset( "shaders/spectrum.vert" ), loadAsset( "shaders/spectrum.frag" ) );
}
catch( const std::exception& e ) {
console() << e.what() << std::endl;
quit();
return;
}
// create static mesh (all animation is done in the vertex shader)
std::vector<vec3> positions;
std::vector<Colorf> colors;
std::vector<vec2> coords;
std::vector<uint32_t> indices;
for( size_t h = 0; h < kHeight; ++h ) {
for( size_t w = 0; w < kWidth; ++w ) {
// add polygon indices
if( h < kHeight - 1 && w < kWidth - 1 ) {
size_t offset = positions.size();
indices.emplace_back( offset );
indices.emplace_back( offset + kWidth );
indices.emplace_back( offset + kWidth + 1 );
indices.emplace_back( offset );
indices.emplace_back( offset + kWidth + 1 );
indices.emplace_back( offset + 1 );
}
// add vertex
positions.emplace_back( vec3( float( w ), 0, float( h ) ) );
// add texture coordinates
// note: we only want to draw the lower part of the frequency bands,
// so we scale the coordinates a bit
const float part = 0.5f;
float s = w / float( kWidth - 1 );
float t = h / float( kHeight - 1 );
coords.emplace_back( vec2( part - part * s, t ) );
// add vertex colors
colors.emplace_back( Color( CM_HSV, s, 0.5f, 0.75f ) );
}
}
gl::VboMesh::Layout layout;
layout.usage( GL_STATIC_DRAW );
layout.attrib( geom::Attrib::POSITION, 3 );
layout.attrib( geom::Attrib::COLOR, 3 );
layout.attrib( geom::Attrib::TEX_COORD_0, 2 );
mMesh = gl::VboMesh::create( positions.size(), GL_TRIANGLES, { layout }, indices.size(), GL_UNSIGNED_INT );
mMesh->bufferAttrib( geom::POSITION, positions.size() * sizeof( vec3 ), positions.data() );
mMesh->bufferAttrib( geom::COLOR, colors.size() * sizeof( vec3 ), colors.data() );
mMesh->bufferAttrib( geom::TEX_COORD_0, coords.size() * sizeof( vec2 ), coords.data() );
mMesh->bufferIndices( indices.size() * sizeof( uint32_t ), indices.data() );
// play audio using the Cinder FMOD block
FMOD::System_Create( &mFMODSystem );
mFMODSystem->init( 32, FMOD_INIT_NORMAL | FMOD_INIT_ENABLE_PROFILE, NULL );
mFMODSound = nullptr;
mFMODChannel = nullptr;
playAudio( findAudio( mAudioPath ) );
mIsMouseDown = false;
mMouseUpDelay = 30.0;
mMouseUpTime = getElapsedSeconds() - mMouseUpDelay;
//.........这里部分代码省略.........
开发者ID:UIKit0,项目名称:Cinder-Samples,代码行数:101,代码来源:AudioVisualizerApp.cpp
注:本文中的fmod::System类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论