// // Claim // // Claim and 2D and 3D voices using the given providers // void Claim(HDIGDRIVER *h2D, U32 max2D, HPROVIDER *h3D, U32 max3D) { LOG_DIAG(("Output::Claim:")); // Do we have a 2D digital audio service if (h2D) { // Allocate the 2D voices U32 v = 0; for (; v < max2D && totalVoices < MAX_VOICES; v++) { // Allocate a new voice handle if (HSAMPLE vHandle = AIL_allocate_sample_handle(*h2D)) { // Allocate a new 2D voice voices[totalVoices++] = new Voice(vHandle); } else { // No more voices to allocate break; } } LOG_DIAG((" - Allocated %d 2D voices", v)); } else { LOG_DIAG((" - No 2D digital audio services")); } // Do we have a 3D digital audio service if (h3D) { // Allocate the 3D voices U32 v = 0; for (; v < max3D && totalVoices < MAX_VOICES; v++) { // Allocate a new voice handle H3DSAMPLE vHandle = AIL_allocate_3D_sample_handle(*h3D); if (vHandle) { // Allocate a new 3D voice voices[totalVoices++] = new Voice(vHandle); } else { // No more voices to allocate break; } } LOG_DIAG((" - Allocated %d 3D voices", v)); } else { LOG_DIAG((" - No 3D digital audio services")); } }
void vrpn_Sound_Server_Miles::loadSound(char* filename, vrpn_SoundID id) /*loads a .wav file into memory. gives back id to reference the sound currently (7/28/99) this does not reuse space previously vacated in samples by unloading sounds*/ { if (provider != 0) { fprintf(stdout,"Loading sound: #%d %s\n", id, filename); ChangeSoundIdBox(0,id); //load into handle unsigned long *s; long type; H3DSAMPLE handle; void *sample_address; void *d; AILSOUNDINFO info; LastSoundId = id; //load the .wav file into memory s = (unsigned long *)AIL_file_read(filename, FILE_READ_WITH_SIZE); if (s==0) return; type=AIL_file_type(s+1,s[0]); switch (type) { case AILFILETYPE_PCM_WAV: sample_address = s+1; break; case AILFILETYPE_ADPCM_WAV: AIL_WAV_info(s+1,&info); AIL_decompress_ADPCM(&info,&d,0); AIL_mem_free_lock(s); sample_address = d; break; default: AIL_mem_free_lock(s); return; } //initialize handle handle = AIL_allocate_3D_sample_handle(provider); //tell handle where the .wav file is in memory AIL_set_3D_sample_file(handle, sample_address); //set defaults AIL_set_3D_sample_volume(handle, 100); //default volume is 100 on 0...127 inclusive AIL_set_3D_position(handle,0,0,0); AIL_set_3D_orientation(handle, 0,0,-1,0,1,0); AIL_set_3D_velocity(handle,0,0,-1,0); AIL_set_3D_sample_distances(handle, 200, 20); //load handle into samples addSample(handle, id); /*Sample level environment preferences (ie, EAX_ENVIRONMENT_BATHROOM) could be added in here as a passed-in parameter*/ } else fprintf(stderr,"No provider has been set prior to LoadSound\n"); }