void vrpn_Sound_Server_Miles::changeSoundStatus(vrpn_SoundID id, vrpn_SoundDef soundDef) { vrpn_float32 uX = 0, uY = 1, uZ = 0; // up vector if (provider != 0) { // need to negate the Z values to get this into left handed before shipping to Miles.. soundDef.pose.orientation[2] *= -1.0; soundDef.pose.orientation[3] *= -1.0; soundDef.pose.position[2] *= -1.0; //get pose info from quaternion in soundDef, put it into the above vectors AIL_set_3D_position(getSample(id),soundDef.pose.position[0] , soundDef.pose.position[1], soundDef.pose.position[2]); // normalize soundDef.pose.orientation[0] /= soundDef.pose.orientation[3]; soundDef.pose.orientation[1] /= soundDef.pose.orientation[3]; soundDef.pose.orientation[2] /= soundDef.pose.orientation[3]; soundDef.pose.orientation[3] /= soundDef.pose.orientation[3]; AIL_set_3D_orientation(getSample(id), soundDef.pose.orientation[0], soundDef.pose.orientation[1], soundDef.pose.orientation[2], uX, uY, uZ); AIL_set_3D_velocity(getSample(id), soundDef.velocity[0], soundDef.velocity[1], soundDef.velocity[2], soundDef.velocity[3]); /*set the volume to the new level.*/ AIL_set_3D_sample_volume(getSample(id), soundDef.volume); AIL_set_3D_sample_distances(getSample(id), soundDef.max_front_dist, soundDef.min_front_dist); } else fprintf(stderr,"No provider has been set prior to changeSoundStatus\n"); }
void vrpn_Sound_Server_Miles::changeSoundStatus(vrpn_SoundID id, vrpn_SoundDef soundDef) { vrpn_float32 uX = 0, uY = 1, uZ = 0; // up vector if (provider != 0) { //get pose info from quaternion in soundDef, put it into the above vectors AIL_set_3D_position(getSample(id),soundDef.pose.position[0] , soundDef.pose.position[1], soundDef.pose.position[2]); // normalize soundDef.pose.orientation[0] /= soundDef.pose.orientation[3]; soundDef.pose.orientation[1] /= soundDef.pose.orientation[3]; soundDef.pose.orientation[2] /= soundDef.pose.orientation[3]; soundDef.pose.orientation[3] /= soundDef.pose.orientation[3]; AIL_set_3D_orientation(getSample(id), soundDef.pose.orientation[0], soundDef.pose.orientation[1], soundDef.pose.orientation[2], uX, uY, uZ); AIL_set_3D_velocity(getSample(id), soundDef.velocity[0], soundDef.velocity[1], soundDef.velocity[2], soundDef.velocity[3]); /*set the volume to the new level.*/ AIL_set_3D_sample_volume(getSample(id), soundDef.volume); // Since the RSX software sets max front/back to 128.0 * min front/back, // we will divide max front/back by 128 and set this to min // before giving it to miles // We will change GetCurrentDistances to multiply by 128.0 before displaying // value to the user.. This mess may need to be cleaned up if the Miles people // come to their senses... soundDef.min_back_dist = soundDef.max_back_dist / 128.0; soundDef.min_front_dist = soundDef.max_front_dist / 128.0; AIL_set_3D_sample_distances(getSample(id), soundDef.max_front_dist, soundDef.min_front_dist, soundDef.max_back_dist, soundDef.min_back_dist); } else fprintf(stderr,"No provider has been set prior to changeSoundStatus\n"); }
// // Play3D // // Play a record as a 3D sample (TRUE if actually started) // Bool Play3D ( Effect *e, Record *r, S32 vol, U32 owner, F32 priority, S32 loop, F32 x, F32 y, F32 z, F32 min, F32 max ) { ASSERT(e); ASSERT(r); // Request a 3D voice Voice *voice = Request(priority, TRUE, e->GetVoiceIndex()); if (!voice) { return (FALSE); } ASSERT(voice->flag3D); // Request the cache data Cache::Item *item = Cache::Request(r); if (!item) { // Unable to load data return (FALSE); } // Stop any sounds from this owner if (owner != NO_OWNER) { Output::StopByOwner(owner); } // The current time U32 time = AIL_ms_count(); // Are we under the minimum repeat time if ((time - r->lastUse) < MIN_REPEATTIME) { return (FALSE); } // Save info about this use r->lastUse = time; // Initialise the sound effect data if (!AIL_set_3D_sample_file(voice->handle3D, item->data)) { LOG_WARN(("Invalid 3D data '%s' (Require MS Mono Uncompressed PCM WAV)", r->Name())); r->valid = FALSE; return (FALSE); } // Setup the voice voice->effect = e; voice->record = r; voice->owner = owner; voice->priority = priority; // Set the volume AIL_set_3D_sample_volume(voice->handle3D, vol); // Set the loop count for this voice AIL_set_3D_sample_loop_count(voice->handle3D, loop); // Set the 3D world position AIL_set_3D_position(voice->handle3D, x, y, z); // Set the distances for this sample AIL_set_3D_sample_distances(voice->handle3D, max, min); // Always face the listener AIL_set_3D_orientation(voice->handle3D, -x, -y, -z, 0.0F, 1.0F, 0.0F); // Start the sample playing AIL_start_3D_sample(voice->handle3D); return (TRUE); }
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"); }