您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ soundLock函数代码示例

51自学网 2021-06-03 08:07:15
  C++
这篇教程C++ soundLock函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中soundLock函数的典型用法代码示例。如果您正苦于以下问题:C++ soundLock函数的具体用法?C++ soundLock怎么用?C++ soundLock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了soundLock函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sound_al_update

/** * @brief Updates the group sounds. */void sound_al_update (void){   int i, j;   alGroup_t *g;   ALfloat d, v;   unsigned int t, f;   t = SDL_GetTicks();   for (i=0; i<al_ngroups; i++) {      g = &al_groups[i];      /* Handle fadeout. */      if (g->state != VOICE_FADEOUT)         continue;      /* Calculate fadeout. */      f = t - g->fade_timer;      if (f < SOUND_FADEOUT) {         d = 1. - (ALfloat) f / (ALfloat) SOUND_FADEOUT;         v = d * svolume * g->volume;         if (g->speed)            v *= svolume_speed;         soundLock();         for (j=0; j<g->nsources; j++)            alSourcef( g->sources[j], AL_GAIN, v );         /* Check for errors. */         al_checkErr();         soundUnlock();      }      /* Fadeout done. */      else {         soundLock();         v = svolume * g->volume;         if (g->speed)            v *= svolume_speed;         for (j=0; j<g->nsources; j++) {            alSourceStop( g->sources[j] );            alSourcei( g->sources[j], AL_BUFFER, AL_NONE );            alSourcef( g->sources[j], AL_GAIN, v );         }         /* Check for errors. */         al_checkErr();         soundUnlock();         /* Mark as done. */         g->state = VOICE_PLAYING;      }   }}
开发者ID:naev,项目名称:naev,代码行数:52,


示例2: sound_al_playGroup

/** * @brief Plays a sound in a group. */int sound_al_playGroup( int group, alSound *s, int once ){   int i, j;   alGroup_t *g;   ALint state;   for (i=0; i<al_ngroups; i++) {      /* Find group. */      if (al_groups[i].id != group)         continue;      g = &al_groups[i];      g->state = VOICE_PLAYING;      soundLock();      for (j=0; j<g->nsources; j++) {         alGetSourcei( g->sources[j], AL_SOURCE_STATE, &state );         /* No free ones, just smash the last one. */         if (j == g->nsources-1) {            if (state != AL_STOPPED) {               alSourceStop( g->sources[j] );               alSourcef( g->sources[j], AL_GAIN, svolume );            }         }         /* Ignore playing/paused. */         else if ((state == AL_PLAYING) || (state == AL_PAUSED))            continue;         /* Attach buffer. */         alSourcei( g->sources[j], AL_BUFFER, s->u.al.buf );         /* Do not do positional sound. */         alSourcei( g->sources[j], AL_SOURCE_RELATIVE, AL_TRUE );         /* See if should loop. */         alSourcei( g->sources[j], AL_LOOPING, (once) ? AL_FALSE : AL_TRUE );         /* Start playing. */         alSourcePlay( g->sources[j] );         /* Check for errors. */         al_checkErr();         soundUnlock();         return 0;      }      soundUnlock();      WARN("Group '%d' has no free sounds.", group );      /* Group matched but not found. */      break;   }   if (i>=al_ngroups)      WARN("Group '%d' not found.", group);   return -1;}
开发者ID:AvanWolf,项目名称:naev,代码行数:63,


示例3: engineLock

void CCoreAudioAE::Shutdown(){  CSingleLock engineLock(m_engineLock);  Stop();  Deinitialize();  /* free the streams */  CSingleLock streamLock(m_streamLock);  while (!m_streams.empty())  {    CCoreAudioAEStream *s = m_streams.front();    m_sounds.pop_front();    delete s;  }  /* free the sounds */  CSingleLock soundLock(m_soundLock);  while (!m_sounds.empty())  {    CCoreAudioAESound *s = m_sounds.front();    m_sounds.pop_front();    delete s;  }  delete HAL;  HAL = NULL;}
开发者ID:AFFLUENTSOCIETY,项目名称:SPMC,代码行数:29,


示例4: music_al_exit

/** * @brief Frees the music. */void music_al_exit (void){   /* Kill the thread. */   music_kill();   SDL_WaitThread( music_player, NULL );   soundLock();   /* Free the music. */   alDeleteBuffers( 2, music_buffer );   alDeleteSources( 1, &music_source );   /* Check for errors. */   al_checkErr();   soundUnlock();   /* Free the buffer. */   if (music_buf != NULL)      free(music_buf);   music_buf = NULL;   /* Destroy the mutex. */   SDL_DestroyMutex( music_vorbis_lock );   SDL_DestroyMutex( music_state_lock );   SDL_DestroyCond( music_state_cond );}
开发者ID:ekrumme,项目名称:naev,代码行数:30,


示例5: sound_al_updateListener

/** * @brief Updates the listener. */int sound_al_updateListener( double dir, double px, double py,      double vx, double vy ){   double c, s;   ALfloat ori[6], pos[3], vel[3];   c = cos(dir);   s = sin(dir);      soundLock();   ori[0] = c;   ori[1] = s;   ori[2] = 0.;   ori[3] = 0.;   ori[4] = 0.;   ori[5] = 1.;   alListenerfv( AL_ORIENTATION, ori );   pos[0] = px;   pos[1] = py;   pos[2] = 0.;   alListenerfv( AL_POSITION, pos );   vel[0] = vx;   vel[1] = vy;   vel[2] = 0.;   alListenerfv( AL_VELOCITY, vel );   /* Check for errors. */   al_checkErr();   soundUnlock();   return 0;}
开发者ID:Delll,项目名称:naev,代码行数:37,


示例6: sound_al_env

/** * @brief Creates a sound environment. */int sound_al_env( SoundEnv_t env, double param ){   int i;   ALuint s;   ALfloat f;   soundLock();   switch (env) {      case SOUND_ENV_NORMAL:         /* Set global parameters. */         alSpeedOfSound( 3433. );         if (al_info.efx == AL_TRUE) {            /* Disconnect the effect. */            nalAuxiliaryEffectSloti( efx_directSlot,                  AL_EFFECTSLOT_EFFECT, AL_EFFECT_NULL );            /* Set per-source parameters. */            for (i=0; i<source_ntotal; i++) {               s = source_total[i];               alSourcef( s, AL_AIR_ABSORPTION_FACTOR, 0. );            }         }         break;      case SOUND_ENV_NEBULA:         f = param / 1000.;         /* Set global parameters. */         alSpeedOfSound( 3433./(1. + f*2.) );         if (al_info.efx == AL_TRUE) {            if (al_info.efx_reverb == AL_TRUE) {               /* Tweak the reverb. */               nalEffectf( efx_reverb, AL_REVERB_DECAY_TIME, 10. );               nalEffectf( efx_reverb, AL_REVERB_DECAY_HFRATIO, 0.5 );               /* Connect the effect. */               nalAuxiliaryEffectSloti( efx_directSlot,                     AL_EFFECTSLOT_EFFECT, efx_reverb );            }            /* Set per-source parameters. */            for (i=0; i<source_ntotal; i++) {               s = source_total[i];               alSourcef( s, AL_AIR_ABSORPTION_FACTOR, 3.*f );            }         }         break;   }   /* Check for errors. */   al_checkErr();   soundUnlock();   return 0;}
开发者ID:Delll,项目名称:naev,代码行数:62,


示例7: sound_al_resume

/** * @brief Resumes all sounds. */void sound_al_resume (void){   soundLock();   al_resumev( source_ntotal, source_total );   /* Check for errors. */   al_checkErr();   soundUnlock();}
开发者ID:Delll,项目名称:naev,代码行数:11,


示例8: sound_al_free

/** * @brief Frees the source. */void sound_al_free( alSound *snd ){   soundLock();   /* free the stuff */   alDeleteBuffers( 1, &snd->u.al.buf );   soundUnlock();}
开发者ID:Delll,项目名称:naev,代码行数:12,


示例9: sound_al_exit

/** * @brief Cleans up after the sound subsytem. */void sound_al_exit (void){   int i;   soundLock();   /* Free groups. */   for (i=0; i<al_ngroups; i++) {      if (al_groups[i].sources != NULL) {         free(al_groups[i].sources);      }      al_groups[i].sources  = NULL;      al_groups[i].nsources = 0;   }   if (al_groups != NULL)      free(al_groups);   al_groups  = NULL;   al_ngroups = 0;   /* Free stacks. */   if (source_all != NULL) {      alSourceStopv(   source_nall, source_all );      alDeleteSources( source_nall, source_all );      free(source_all);   }   source_all        = NULL;   source_nall       = 0;   if (source_total)      free(source_total);   source_total      = NULL;   source_ntotal     = 0;   if (source_stack != NULL)      free(source_stack);   source_stack      = NULL;   source_nstack     = 0;   source_mstack     = 0;   /* Clean up EFX stuff. */   if (al_info.efx == AL_TRUE) {      nalDeleteAuxiliaryEffectSlots( 1, &efx_directSlot );      if (al_info.efx_reverb == AL_TRUE)         nalDeleteEffects( 1, &efx_reverb );      if (al_info.efx_echo == AL_TRUE)         nalDeleteEffects( 1, &efx_echo );   }   /* Clean up global stuff. */   if (al_context) {      alcMakeContextCurrent(NULL);      alcDestroyContext( al_context );   }   if (al_device)      alcCloseDevice( al_device );   soundUnlock();   SDL_DestroyMutex( sound_lock );}
开发者ID:s0be,项目名称:naev,代码行数:60,


示例10: texLock

void ResourceManager::unloadAll(){	sf::Lock texLock( texMutex );	sf::Lock soundLock( soundMutex );	sf::Lock fontLock( fontMutex );		textures.clear();	soundBuffers.clear();	fonts.clear();}
开发者ID:spacechase0,项目名称:Farming-Game,代码行数:10,


示例11: sound_al_setSpeed

/** * @brief Set the playing speed. */void sound_al_setSpeed( double s ){   int i;   soundLock();   for (i=0; i<source_nall; i++)      alSourcef( source_all[i], AL_PITCH, s );   /* Check for errors. */   al_checkErr();   soundUnlock();}
开发者ID:Delll,项目名称:naev,代码行数:13,


示例12: sound_al_resumeGroup

/** * @brief Resumes a group. */void sound_al_resumeGroup( int group ){   alGroup_t *g;   g = sound_al_getGroup( group );   if (g == NULL)      return;   soundLock();   al_resumev( g->nsources, g->sources );   soundUnlock();}
开发者ID:naev,项目名称:naev,代码行数:14,


示例13: sound_al_stop

/** * @brief Stops playing sound. */void sound_al_stop( alVoice* voice ){   soundLock();   if (voice->u.al.source != 0)      alSourceStop( voice->u.al.source );   /* Check for errors. */   al_checkErr();   soundUnlock();}
开发者ID:Delll,项目名称:naev,代码行数:15,


示例14: sound_al_volume

/** * @brief Sets all the sounds volume to vol */int sound_al_volume( double vol ){   int i;   svolume = (ALfloat) vol;   soundLock();   for (i=0; i<source_nall; i++)      alSourcef( source_all[i], AL_GAIN, svolume );   soundUnlock();   return 0;}
开发者ID:Delll,项目名称:naev,代码行数:15,


示例15: sound_al_load

/** * @brief Loads the sound. * *    @param snd Sound to load. *    @param filename Name of the file to load into sound. */int sound_al_load( alSound *snd, const char *filename ){   int ret;   SDL_RWops *rw;   OggVorbis_File vf;   ALint freq, bits, channels, size;   /* get the file data buffer from packfile */   rw = ndata_rwops( filename );   /* Check to see if it's an OGG. */   if (ov_test_callbacks( rw, &vf, NULL, 0, sound_al_ovcall_noclose )==0) {      ret = sound_al_loadOgg( snd, &vf );   }   /* Otherwise try WAV. */   else {      /* Destroy the partially loaded vorbisfile. */      ov_clear(&vf);      /* Try to load Wav. */      ret = sound_al_loadWav( snd, rw );   }   /* Close RWops. */   SDL_RWclose(rw);   /* Failed to load. */   if (ret != 0) {      WARN("Failed to load sound file '%s'.", filename);      return ret;   }   soundLock();   /* Get the length of the sound. */   alGetBufferi( snd->u.al.buf, AL_FREQUENCY, &freq );   alGetBufferi( snd->u.al.buf, AL_BITS, &bits );   alGetBufferi( snd->u.al.buf, AL_CHANNELS, &channels );   alGetBufferi( snd->u.al.buf, AL_SIZE, &size );   if ((freq==0) || (bits==0) || (channels==0)) {      WARN("Something went wrong when loading sound file '%s'.", filename);      snd->length = 0;   }   else      snd->length = (double)size / (double)(freq * (bits/8) * channels);   /* Check for errors. */   al_checkErr();   soundUnlock();   return 0;}
开发者ID:Delll,项目名称:naev,代码行数:59,


示例16: sound_al_volume

/** * @brief Sets all the sounds volume to vol */int sound_al_volume( double vol ){   int i;   svolume_lin = vol;   if (vol > 0.) /* Floor of -48 dB (0.00390625 amplitude) */      svolume = (ALfloat) 1 / pow(2, (1 - vol) * 8);   else      svolume     = 0.;   soundLock();   for (i=0; i<source_nall; i++)      alSourcef( source_all[i], AL_GAIN, svolume );   soundUnlock();   return 0;}
开发者ID:AvanWolf,项目名称:naev,代码行数:19,


示例17: al_playVoice

/** * @brief Plays a voice. */static int al_playVoice( alVoice *v, alSound *s,      ALfloat px, ALfloat py, ALfloat vx, ALfloat vy, ALint relative ){   /* Must be below the limit. */   if (sound_speed > SOUND_SPEED_PLAY_LIMIT)      return 0;   /* Set up the source and buffer. */   v->u.al.source = sound_al_getSource();   if (v->u.al.source == 0)      return -1;   v->u.al.buffer = s->u.al.buf;   soundLock();   /* Attach buffer. */   alSourcei( v->u.al.source, AL_BUFFER, v->u.al.buffer );   /* Enable positional sound. */   alSourcei( v->u.al.source, AL_SOURCE_RELATIVE, relative );   /* Update position. */   v->u.al.pos[0] = px;   v->u.al.pos[1] = py;   v->u.al.pos[2] = 0.;   v->u.al.vel[0] = vx;   v->u.al.vel[1] = vy;   v->u.al.vel[2] = 0.;   /* Set up properties. */   alSourcef(  v->u.al.source, AL_GAIN, svolume*svolume_speed );   alSourcefv( v->u.al.source, AL_POSITION, v->u.al.pos );   alSourcefv( v->u.al.source, AL_VELOCITY, v->u.al.vel );   /* Defaults just in case. */   alSourcei( v->u.al.source, AL_LOOPING, AL_FALSE );   /* Start playing. */   alSourcePlay( v->u.al.source );   /* Check for errors. */   al_checkErr();   soundUnlock();   return 0;}
开发者ID:naev,项目名称:naev,代码行数:50,


示例18: music_al_init

/** * @brief Initializes the OpenAL music subsystem. */int music_al_init (void){   ALfloat v[] = { 0., 0., 0. };   /* Create threading mechanisms. */   music_state_cond  = SDL_CreateCond();   music_state_lock  = SDL_CreateMutex();   music_vorbis_lock = SDL_CreateMutex();   music_vorbis.rw   = NULL; /* indication it's not loaded */   /* Create the buffer. */   music_bufSize     = conf.al_bufsize * 1024;   music_buf         = malloc( music_bufSize );   soundLock();   /* music_source created in sound_al_init. */   /* Generate buffers and sources. */   alGenBuffers( 2, music_buffer );   /* Set up OpenAL properties. */   alSourcef(  music_source, AL_GAIN, music_vol );   alSourcei(  music_source, AL_SOURCE_RELATIVE, AL_TRUE );   alSourcefv( music_source, AL_POSITION, v );   alSourcefv( music_source, AL_VELOCITY, v );   /* Check for errors. */   al_checkErr();   /* Set state to none. */   music_state = 0;   soundUnlock();   /*    * Start up thread and have it inform us when it already reaches the main loop.    */   musicLock();   music_state  = MUSIC_STATE_STARTUP;   music_player = SDL_CreateThread( music_thread, NULL );   SDL_CondWait( music_state_cond, music_state_lock );   musicUnlock();   return 0;}
开发者ID:ekrumme,项目名称:naev,代码行数:49,


示例19: sound_al_loadWav

/** * @brief Loads a wav file from the rw if possible. * * @note Closes the rw. * *    @param snd Sound to load wav into. *    @param rw Data for the wave. */static int sound_al_loadWav( alSound *snd, SDL_RWops *rw ){   SDL_AudioSpec wav_spec;   Uint32 wav_length;   Uint8 *wav_buffer;   ALenum format;   SDL_RWseek( rw, 0, SEEK_SET );   /* Load WAV. */   if (SDL_LoadWAV_RW( rw, 0, &wav_spec, &wav_buffer, &wav_length) == NULL) {      WARN(_("SDL_LoadWav_RW failed: %s"), SDL_GetError());      return -1;   }   /* Handle format. */   switch (wav_spec.format) {      case AUDIO_U8:      case AUDIO_S8:         format = (wav_spec.channels==1) ? AL_FORMAT_MONO8 : AL_FORMAT_STEREO8;         break;      case AUDIO_U16LSB:      case AUDIO_S16LSB:         format = (wav_spec.channels==1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;         break;      case AUDIO_U16MSB:      case AUDIO_S16MSB:         WARN( _("Big endian WAVs unsupported!") );         return -1;      default:         WARN( _("Invalid WAV format!") );         return -1;   }   /* Load into openal. */   soundLock();   /* Create new buffer. */   alGenBuffers( 1, &snd->u.al.buf );   /* Put into the buffer. */   alBufferData( snd->u.al.buf, format, wav_buffer, wav_length, wav_spec.freq );   soundUnlock();   /* Clean up. */   free( wav_buffer );   return 0;}
开发者ID:naev,项目名称:naev,代码行数:54,


示例20: sound_al_loadOgg

/** * @brief Loads an ogg file from a tested format if possible. * *    @param snd Sound to load ogg into. *    @param vf Vorbisfile containing the song. */static int sound_al_loadOgg( alSound *snd, OggVorbis_File *vf ){   int ret;   long i;   int section;   vorbis_info *info;   ALenum format;   ogg_int64_t len;   char *buf;   /* Finish opening the file. */   ret = ov_test_open(vf);   if (ret) {      WARN("Failed to finish loading OGG file: %s", vorbis_getErr(ret) );      return -1;   }   /* Get file information. */   info   = ov_info( vf, -1 );   format = (info->channels == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;   len    = ov_pcm_total( vf, -1 ) * info->channels * 2;   /* Allocate memory. */   buf = malloc( len );   /* Fill buffer. */   i = 0;   while (i < len) {      /* Fill buffer with data in the 16 bit signed samples format. */      i += ov_read( vf, &buf[i], len-i, VORBIS_ENDIAN, 2, 1, &section );   }   soundLock();   /* Create new buffer. */   alGenBuffers( 1, &snd->u.al.buf );   /* Put into buffer. */   alBufferData( snd->u.al.buf, format, buf, len, info->rate );   soundUnlock();   /* Clean up. */   free(buf);   ov_clear(vf);   return 0;}
开发者ID:Delll,项目名称:naev,代码行数:51,


示例21: sound_al_resumeGroup

/** * @brief Resumes a group. */void sound_al_resumeGroup( int group ){   int i;   alGroup_t *g;   for (i=0; i<al_ngroups; i++) {      if (al_groups[i].id == group) {         g = &al_groups[i];         soundLock();         al_resumev( g->nsources, g->sources );         soundUnlock();         break;      }   }   if (i>=al_ngroups)      WARN("Group '%d' not found.", group);}
开发者ID:Delll,项目名称:naev,代码行数:21,


示例22: sound_al_updateVoice

/** * @brief Updates the voice. * *    @param v Voice to update. */void sound_al_updateVoice( alVoice *v ){   ALint state;   /* Invalid source, mark to delete. */   if (v->u.al.source == 0) {      v->state = VOICE_DESTROY;      return;   }   soundLock();   /* Get status. */   alGetSourcei( v->u.al.source, AL_SOURCE_STATE, &state );   if (state == AL_STOPPED) {      /* Remove buffer so it doesn't start up again if resume is called. */      alSourcei( v->u.al.source, AL_BUFFER, AL_NONE );      /* Check for errors. */      al_checkErr();      soundUnlock();      /* Put source back on the list. */      source_stack[source_nstack] = v->u.al.source;      source_nstack++;      v->u.al.source = 0;      /* Mark as stopped - erased next iteration. */      v->state = VOICE_STOPPED;      return;   }   /* Set up properties. */   alSourcef(  v->u.al.source, AL_GAIN, svolume );   alSourcefv( v->u.al.source, AL_POSITION, v->u.al.pos );   alSourcefv( v->u.al.source, AL_VELOCITY, v->u.al.vel );   /* Check for errors. */   al_checkErr();   soundUnlock();}
开发者ID:Delll,项目名称:naev,代码行数:49,


示例23: music_al_volume

/** * @brief Sets the volume. */int music_al_volume( double vol ){   soundLock();   music_vol = vol;   /* only needed if playing */   if (music_al_isPlaying()) {      alSourcef( music_source, AL_GAIN, vol );      /* Check for errors. */      al_checkErr();   }    soundUnlock();   return 0;}
开发者ID:ekrumme,项目名称:naev,代码行数:22,


示例24: sound_al_volumeUpdate

/** * @brief Internal volume update function. */static void sound_al_volumeUpdate (void){   int i, j;   alGroup_t *g;   double v;   soundLock();   /* Do generic ones. */   for (i=0; i<source_ntotal; i++)      alSourcef( source_total[i], AL_GAIN, svolume*svolume_speed );   /* Do specific groups. */   for (i=0; i<al_ngroups; i++) {      g = &al_groups[i];      v = svolume * g->volume;      if (g->speed)         v *= svolume_speed;      for (j=0; j<g->nsources; j++)         alSourcef( g->sources[j], AL_GAIN, v );   }   soundUnlock();}
开发者ID:naev,项目名称:naev,代码行数:24,


示例25: al_playVoice

/** * @brief Plays a voice. */static int al_playVoice( alVoice *v, alSound *s,      ALfloat px, ALfloat py, ALfloat vx, ALfloat vy, ALint relative ){   /* Set up the source and buffer. */   v->u.al.source = sound_al_getSource();   if (v->u.al.source == 0)      return -1;   v->u.al.buffer = s->u.al.buf;   soundLock();   /* Attach buffer. */   alSourcei( v->u.al.source, AL_BUFFER, v->u.al.buffer );   /* Enable positional sound. */   alSourcei( v->u.al.source, AL_SOURCE_RELATIVE, relative );   /* Update position. */   v->u.al.pos[0] = px;   v->u.al.pos[1] = py;   v->u.al.pos[2] = 0.;   v->u.al.vel[0] = vx;   v->u.al.vel[1] = vy;   v->u.al.vel[2] = 0.;   /* Set up properties. */   alSourcef(  v->u.al.source, AL_GAIN, svolume );   alSourcefv( v->u.al.source, AL_POSITION, v->u.al.pos );   alSourcefv( v->u.al.source, AL_VELOCITY, v->u.al.vel );   /* Start playing. */   alSourcePlay( v->u.al.source );   /* Check for errors. */   al_checkErr();   soundUnlock();   return 0;}
开发者ID:Delll,项目名称:naev,代码行数:43,


示例26: sound_al_setSpeed

/** * @brief Set the playing speed. */void sound_al_setSpeed( double s ){   int i, j;   alGroup_t *g;   soundLock();   sound_speed = s; /* Set the speed. */   /* Do all the groupless. */   for (i=0; i<source_ntotal; i++)      alSourcef( source_total[i], AL_PITCH, s );   /* Do specific groups. */   for (i=0; i<al_ngroups; i++) {      g = &al_groups[i];      if (!g->speed)         continue;      for (j=0; j<g->nsources; j++)         alSourcef( g->sources[j], AL_PITCH, s );   }   /* Check for errors. */   al_checkErr();   soundUnlock();}
开发者ID:naev,项目名称:naev,代码行数:25,


示例27: music_al_volume

/** * @brief Sets the volume. */int music_al_volume( double vol ){   soundLock();   music_vol_lin = vol;   if (vol > 0.) /* Floor of -48 dB (0.00390625 amplitude) */      music_vol = 1 / pow(2, (1 - vol) * 8 );   else      music_vol = 0.;   /* only needed if playing */   if (music_al_isPlaying()) {      alSourcef( music_source, AL_GAIN, music_vol );      /* Check for errors. */      al_checkErr();   }   soundUnlock();   return 0;}
开发者ID:s0be,项目名称:naev,代码行数:26,


示例28: sound_al_loadWav

//.........这里部分代码省略.........   if (sound_al_wavGetLen16( rw, &align )) {      WARN("Unable to get WAVE chunk significant bits.");      goto wav_err;   }   align /= channels;   i += 2;   /* Seek to end. */   SDL_RWseek( rw, chunklen-i, SEEK_CUR );   /* Read new header. */   len = SDL_RWread( rw, magic, 4, 1 );   if (len != 1) {      WARN("Unable to read chunk header.");      goto wav_err;   }   /* Skip fact. */   if (memcmp( magic, "fact", 4)==0) {      /* Get chunk length. */      if (sound_al_wavGetLen32( rw, &chunklen )) {         WARN("Unable to get WAVE chunk data length.");         goto wav_err;      }      /* Seek to end of chunk. */      SDL_RWseek( rw, chunklen, SEEK_CUR );      /* Read new header. */      len = SDL_RWread( rw, magic, 4, 1 );      if (len != 1) {         WARN("Unable to read chunk header.");         goto wav_err;      }   }   /* Should be chunk header now. */   if (memcmp( magic, "data", 4)) {      WARN("Unable to find WAVE 'data' chunk header.");      goto wav_err;   }   /*    * Chunk data header.    */   /* Get chunk length. */   if (sound_al_wavGetLen32( rw, &chunklen )) {      WARN("Unable to get WAVE chunk data length.");      goto wav_err;   }   /* Load the chunk data. */   buf = malloc( chunklen );   i = 0;   while (i < chunklen) {      i += SDL_RWread( rw, &buf[i], 1, chunklen-i );   }   /* Calculate format. */   if (channels == 2) {      if (align == 16)         format = AL_FORMAT_STEREO16;      else if (align == 8)         format = AL_FORMAT_STEREO8;      else {         WARN("Unsupported byte alignment (%d) in WAVE file.", align);         goto chunk_err;      }   }   else if (channels == 1) {      if (align == 16)         format = AL_FORMAT_MONO16;      else if (align == 8)         format = AL_FORMAT_MONO8;      else {         WARN("Unsupported byte alignment (%d) in WAVE file.", align);         goto chunk_err;      }   }   else {      WARN("Unsupported number of channels (%d) in WAVE file.", channels);      goto chunk_err;   }   soundLock();   /* Create new buffer. */   alGenBuffers( 1, &snd->u.al.buf );   /* Put into the buffer. */   alBufferData( snd->u.al.buf, format, buf, chunklen, rate );   soundUnlock();   free(buf);   return 0;chunk_err:   free(buf);wav_err:   return -1;}
开发者ID:Delll,项目名称:naev,代码行数:101,


示例29: stream_loadBuffer

/** * @brief Loads a buffer. * *    @param buffer Buffer to load. */static int stream_loadBuffer( ALuint buffer ){   int ret, size, section, result;   musicVorbisLock();   /* Make sure music is valid. */   if (music_vorbis.rw == NULL) {      musicVorbisUnlock();      return -1;   }   ret  = 0;   size = 0;   while (size < music_bufSize) { /* fille up the entire data buffer */      result = ov_read_filter(            &music_vorbis.stream,   /* stream */            &music_buf[size],       /* data */            music_bufSize - size,   /* amount to read */            VORBIS_ENDIAN,          /* big endian? */            2,                      /* 16 bit */            1,                      /* signed */            &section,               /* current bitstream */            rg_filter,              /* filter function */            &music_vorbis );        /* filter parameter */      /* End of file. */      if (result == 0) {         if (size == 0) {            musicVorbisUnlock();            return -2;         }         ret = 1;         break;      }      /* Hole error. */      else if (result == OV_HOLE) {         musicVorbisUnlock();         WARN("OGG: Vorbis hole detected in music!");         return 0;      }      /* Bad link error. */      else if (result == OV_EBADLINK) {         musicVorbisUnlock();         WARN("OGG: Invalid stream section or corrupt link in music!");         return -1;      }      size += result;   }   musicVorbisUnlock();   /* load the buffer up */   soundLock();   alBufferData( buffer, music_vorbis.format,         music_buf, size, music_vorbis.info->rate );   soundUnlock();   return ret;}
开发者ID:ekrumme,项目名称:naev,代码行数:67,


示例30: music_thread

//.........这里部分代码省略.........      /*       * Main processing loop.       */      switch (cur_state) {         /*          * Basically send a message that thread is up and running.          */         case MUSIC_STATE_STARTUP:            musicLock();            music_state = MUSIC_STATE_IDLE;            SDL_CondBroadcast( music_state_cond );            musicUnlock();            break;         /*          * We died.          */         case MUSIC_STATE_DEAD:            return 0;            break;         /*          * Delays at the end.          */         case MUSIC_STATE_PAUSED:         case MUSIC_STATE_IDLE:            break;         /*          * Resumes the paused song.          */         case MUSIC_STATE_RESUMING:            soundLock();            alSourcePlay( music_source );            alSourcef( music_source, AL_GAIN, music_vol );            /* Check for errors. */            al_checkErr();            soundUnlock();            musicLock();            music_state = MUSIC_STATE_PLAYING;            SDL_CondBroadcast( music_state_cond );            musicUnlock();            break;         /*          * Pause the song.          */         case MUSIC_STATE_PAUSING:            soundLock();            alSourcePause( music_source );            /* Check for errors. */            al_checkErr();            soundUnlock();            musicLock();            music_state = MUSIC_STATE_PAUSED;            SDL_CondBroadcast( music_state_cond );            musicUnlock();            break;         /*          * Stop song setting to IDLE.          */         case MUSIC_STATE_STOPPING:
开发者ID:ekrumme,项目名称:naev,代码行数:67,



注:本文中的soundLock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ sound_GetError函数代码示例
C++ sound函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。