void vrpn_Sound_Server_Miles::playSound(vrpn_SoundID id, vrpn_int32 repeat, vrpn_SoundDef soundDef) { if (provider != 0) { fprintf(stderr,"Playing sound: %d\n",id); // update last sound played record LastSoundId = id; changeSoundStatus(id, soundDef); AIL_set_3D_sample_loop_count(getSample(id), repeat); //if not playing, play //if playing already modify parameters in p for pose, //vel, etc but ignore loop count switch(AIL_3D_sample_status(getSample(id))) { case SMP_DONE: case SMP_STOPPED: { AIL_start_3D_sample(getSample(id)); break; } case SMP_PLAYING: { //it's already playing. //new repeat info is ignored. new pose and velocity info was set above break; } default: { /*It shouldn't occur that one of the above cases isn't triggered. If error messages back to the client are ever implemented, one should be keyed here*/ break; } } } else fprintf(stderr,"No provider has been set prior to playSound\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); }