本文整理汇总了C++中AudioEngine类的典型用法代码示例。如果您正苦于以下问题:C++ AudioEngine类的具体用法?C++ AudioEngine怎么用?C++ AudioEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AudioEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m_Engine
AudioWorld::AudioWorld(Engine::BaseEngine& engine, AudioEngine& audio_engine, const VDFS::FileIndex& vdfidx)
: m_Engine(engine)
, m_VDFSIndex(vdfidx)
, m_exiting(false)
{
#ifdef RE_USE_SOUND
if (!audio_engine.getDevice())
return;
m_Context = alcCreateContext(audio_engine.getDevice(), nullptr);
if (!m_Context)
{
LogWarn() << "Could not create OpenAL context: "
<< AudioEngine::getErrorString(alcGetError(audio_engine.getDevice()));
return;
}
alcMakeContextCurrent(m_Context);
alListener3f(AL_POSITION, 0, 0, 0.0f);
// check for errors
alListener3f(AL_VELOCITY, 0, 0, 0);
// check for errors
ALfloat listenerOri[] = {0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f};
alListenerfv(AL_ORIENTATION, listenerOri);
// Need this for AL_MAX_DISTANCE to work
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED);
createSounds();
initializeMusic();
#endif
}
示例2: tick
int tick(void *outputBuffer, void *inputBuffer, U32 nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *userData)
{
if (status == 0)
{
AudioEngine *engine = reinterpret_cast<AudioEngine *>(userData);
engine->processChannels(outputBuffer, nBufferFrames * 8);
}
return 0;
}
示例3: enqueue
void AudioHandleImpl::enqueue(std::function<void(AudioEmitter& src)> f)
{
size_t id = handleId;
AudioEngine* engine = facade.engine.get();
facade.enqueue([id, engine, f] () {
for (auto& src: engine->getSources(id)) {
f(*src);
}
});
}
示例4: AudioEngine_PortAudioCallback
static int AudioEngine_PortAudioCallback(
const void *inputBuffer
,void *outputBuffer
,unsigned long framesPerBuffer
,const PaStreamCallbackTimeInfo* timeInfo
,PaStreamCallbackFlags statusFlags
,void *userData
){
AudioEngine* engine = (AudioEngine*) userData;
return engine->fetchSoundData( outputBuffer, framesPerBuffer );
}
示例5: Java_com_prettysimple_audio_AudioPlayer_setParams
/**
* Change pitch, pan and gain of a sound
* Implementation of the setParams method in AudioPlayer.java
*/
JNIEXPORT bool JNICALL Java_com_prettysimple_audio_AudioPlayer_setParams(JNIEnv *env, jobject thiz, jfloat pitch, jfloat pan, jfloat volume) {
bool ret = false;
AudioEngine *engine = AudioEngine::getInstance();
const int audioId = getAudioId(env, thiz); // try to recover the audioIde from the AudioPlayer.java object
if (audioId > 0)
{
ret = engine->setParams(audioId, (float) pitch, (float) pan, (float) volume);
}
return ret;
}
示例6: startDecoding
void SoundNode::startDecoding()
{
AudioEngine* pEngine = AudioEngine::get();
m_pDecoder->startDecoding(false, pEngine->getParams());
m_AudioID = pEngine->addSource(*m_pDecoder->getAudioMsgQ(),
*m_pDecoder->getAudioStatusQ());
pEngine->setSourceVolume(m_AudioID, m_Volume);
if (m_SeekBeforeCanRenderTime != 0) {
seek(m_SeekBeforeCanRenderTime);
m_SeekBeforeCanRenderTime = 0;
}
}
示例7: Pa_ReadStream
/*! Read samples from the current audio device */
v8::Handle<v8::Value> Audio::AudioEngine::read( const v8::Arguments& args ) {
HandleScope scope;
AudioEngine* pEngine = AudioEngine::Unwrap<AudioEngine>( args.This() );
if (pEngine->m_bReadMicrophone) {
Pa_ReadStream( pEngine->m_pPaStream, pEngine->m_cachedInputSampleBlock, pEngine->m_uSamplesPerBuffer );
}
Handle<Array> input = pEngine->getInputBuffer();
return scope.Close( input );
} // end AudioEngine::Read()
示例8: Java_com_prettysimple_audio_AudioPlayer_resume
/**
* Resume a sound that has been paused
* Implementation of the resume method in AudioPlayer.java
*/
JNIEXPORT bool JNICALL Java_com_prettysimple_audio_AudioPlayer_resume(JNIEnv *env, jobject thiz)
{
bool ret = false;
AudioEngine *engine = AudioEngine::getInstance();
const int audioId = getAudioId(env, thiz);
if (audioId > 0)
{
ret = engine->resume(audioId);
}
return ret;
}
示例9: Java_com_prettysimple_audio_AudioPlayer_pause
/**
* Pause a sound
* Implementation of the pause method in AudioPlayer.java
*/
JNIEXPORT bool JNICALL Java_com_prettysimple_audio_AudioPlayer_pause(JNIEnv *env, jobject thiz)
{
bool ret = false;
AudioEngine *engine = AudioEngine::getInstance();
const int audioId = getAudioId(env, thiz); // try to recover the audioIde from the AudioPlayer.java object
if (audioId > 0)
{
ret = engine->pause(audioId);
}
return ret;
}
示例10: ThrowException
/*! Our V8 new operator */
v8::Handle<v8::Value> Audio::AudioEngine::New( const v8::Arguments& args ) {
HandleScope scope;
if (!args[0]->IsFunction()) {
return ThrowException( Exception::TypeError(String::New("Callback function required")) );
}
Local<Function> callback = Local<Function>::Cast( args[0] );
AudioEngine* engine = new AudioEngine( callback );
engine->Wrap( args.This() );
return scope.Close( args.This() );
} // end AudioEngine::New()
示例11: ThrowException
/*! Write samples to the current audio device */
v8::Handle<v8::Value> Audio::AudioEngine::write( const v8::Arguments& args ) {
HandleScope scope;
AudioEngine* pEngine = AudioEngine::Unwrap<AudioEngine>( args.This() );
if (args.Length() > 1 || !args[0]->IsArray()){
return scope.Close( ThrowException(Exception::TypeError(String::New("First argument should be an array."))) );
}
uv_mutex_lock( &pEngine->m_mutex );
pEngine->queueOutputBuffer( Local<Array>::Cast(args[0]) );
uv_mutex_unlock( &pEngine->m_mutex );
Handle<Boolean> result = Boolean::New( false );
return scope.Close( result );
} // end AudioEngine::Write()
示例12: FillBuffer
bool AudioEngine::FillBuffer(void** data, int* dataSize, void* context){
AudioEngine* engine = (AudioEngine*)context;
return engine->fillBuffer(data, dataSize);
}
示例13: audioCallback
void AudioEngine::audioCallback(void *userData, Uint8 *audioBuffer, int audioBufferLen)
{
AudioEngine *pThis = (AudioEngine*)userData;
pThis->mixAudio(audioBuffer, audioBufferLen);
}
示例14: main
//.........这里部分代码省略.........
// Load song - if wasn't already loaded with playlist
if ( ! pSong ) {
if ( !songFilename.isEmpty() ) {
pSong = Song::load( songFilename );
} else {
/* Try load last song */
bool restoreLastSong = preferences->isRestoreLastSongEnabled();
QString filename = preferences->getLastSongFilename();
if ( restoreLastSong && ( !filename.isEmpty() ))
pSong = Song::load( filename );
}
/* Still not loaded */
if (! pSong) {
___INFOLOG("Starting with empty song");
pSong = Song::get_empty_song();
pSong->set_filename( "" );
}
pHydrogen->setSong( pSong );
preferences->setLastSongFilename( songFilename );
}
if ( ! drumkitToLoad.isEmpty() ){
Drumkit* drumkitInfo = Drumkit::load_by_name( drumkitToLoad, true );
if ( drumkitInfo ) {
pHydrogen->loadDrumkit( drumkitInfo );
} else {
___ERRORLOG ( "Error loading the drumkit" );
}
}
AudioEngine* AudioEngine = AudioEngine::get_instance();
Sampler* sampler = AudioEngine->get_sampler();
switch ( interpolation ) {
case 1:
sampler->setInterpolateMode( Sampler::COSINE );
break;
case 2:
sampler->setInterpolateMode( Sampler::THIRD );
break;
case 3:
sampler->setInterpolateMode( Sampler::CUBIC );
break;
case 4:
sampler->setInterpolateMode( Sampler::HERMITE );
break;
case 0:
default:
sampler->setInterpolateMode( Sampler::LINEAR );
}
EventQueue *pQueue = EventQueue::get_instance();
signal(SIGINT, signal_handler);
bool ExportMode = false;
if ( ! outFilename.isEmpty() ) {
pHydrogen->startExportSong ( outFilename, rate, bits );
cout << "Export Progress ... ";
bool ExportMode = true;
}
// Interactive mode
while ( ! quit ) {
示例15: bq_player_callback
void AudioEngine::bq_player_callback(SLAndroidSimpleBufferQueueItf bq, void* data)
{
AudioEngine* engine = static_cast<AudioEngine*> (data);
engine->bq_player_callback_handler(bq);
}