+ if (playing) {
+ sgVec3 final_pos;
+ sgAddVec3( final_pos, source_pos, offset_pos );
+
+ alSourcefv( source, AL_POSITION, final_pos );
+ }
+}
+
+void
+SGSoundSample::set_orientation( ALfloat *dir, ALfloat inner_angle,
+ ALfloat outer_angle,
+ ALfloat outer_gain)
+{
+ inner = inner_angle;
+ outer = outer_angle;
+ outergain = outer_gain;
+ if (playing) {
+ alSourcefv( source, AL_DIRECTION, dir);
+ alSourcef( source, AL_CONE_INNER_ANGLE, inner );
+ alSourcef( source, AL_CONE_OUTER_ANGLE, outer );
+ alSourcef( source, AL_CONE_OUTER_GAIN, outergain );
+ }
+}
+
+void
+SGSoundSample::set_source_vel( ALfloat *vel ) {
+ source_vel[0] = vel[0];
+ source_vel[1] = vel[1];
+ source_vel[2] = vel[2];
+ if (playing) {
+ alSourcefv( source, AL_VELOCITY, source_vel );
+ }
+}
+
+void
+SGSoundSample::set_reference_dist( ALfloat dist ) {
+ reference_dist = dist;
+ if (playing) {
+ alSourcef( source, AL_REFERENCE_DISTANCE, reference_dist );
+ }
+}
+
+
+void
+SGSoundSample::set_max_dist( ALfloat dist ) {
+ max_dist = dist;
+ if (playing) {
+ alSourcef( source, AL_MAX_DISTANCE, max_dist );
+ }
+}
+
+ALvoid *
+SGSoundSample::load_file(const char *path, const char *file)
+{
+ ALvoid* data = 0;
+
+ SGPath samplepath( path );
+ if ( strlen(file) ) {
+ samplepath.append( file );
+ }
+
+#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
+ ALfloat freqf;
+ data = alutLoadMemoryFromFile(samplepath.c_str(), &format, &size, &freqf );
+ if (data == NULL) {
+ throw sg_exception("Failed to load wav file.");
+ }
+ freq = (ALsizei)freqf;
+#else
+# if defined (__APPLE__)
+ alutLoadWAVFile( (ALbyte *)samplepath.c_str(),
+ &format, &data, &size, &freq );
+# else
+ alutLoadWAVFile( (ALbyte *)samplepath.c_str(),
+ &format, &data, &size, &freq, &loop );
+# endif
+ if ( print_openal_error("constructor (alutLoadWAVFile)") ) {
+ throw sg_exception("Failed to load wav file.");
+ }
+#endif
+
+ return data;