+
+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;
+}
+