(speed 0.500000)
)
(spawnpoint (name "main") (x 96) (y 160))
- (ambient_sound (x 128) (y 800) (distance_factor "0.1") (distance_bias "200.0") (sample "rain"))
- (infoblock (x 128) (y 800)
+ (ambient_sound (x 128) (y 900) (distance_factor 0.01)
+ (distance_bias 200.0) (sample "rain"))
+ (ambient_sound (x 512) (y 900) (distance_factor 0.05)
+ (distance_bias 100.0) (sample "waterfall") (volume 0.2))
+ (ambient_sound (x 800) (y 900) (distance_factor 0.1)
+ (distance_bias 50.0) (sample "lava"))
+ (infoblock (x 128) (y 864)
(message (_ "-Info
-#An ambient sound source
-#should be audible here"))
+#An ambient sound
+#source playing the
+#rain effect should
+#be audible here.
+#Find Waterfall and
+#Lava sources with
+#smaller geometry
+#further right.
+"))
+ )
+ (infoblock (x 512) (y 864)
+ (message (_ "-Info
+#Waterfall
+#Volume 0.2
+"))
+ )
+ (infoblock (x 800) (y 864)
+ (message (_ "-Info
+#Lava
+"))
)
)
)
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-05-07 18:58+0200\n"
+"POT-Creation-Date: 2005-05-08 15:26+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "Sector Test"
msgstr ""
-#: basest/levels/test/verticalforest.stl:5
-msgid "Inside The Tree"
-msgstr ""
-
-#: basest/levels/test/ambient_sound.stl:4
-msgid "Ambient Sound Test"
-msgstr ""
-
-#: basest/levels/test/ambient_sound.stl:138
-msgid ""
-"-Info\n"
-"#An ambient sound source\n"
-"#should be audible here"
-msgstr ""
-
#: basest/levels/test/bonusblock.stl:4
msgid "Bonus Block Test"
msgstr ""
"#This rocks"
msgstr ""
+#: basest/levels/test/yeti.stl:4
+msgid "Yeti Test"
+msgstr ""
+
#: basest/levels/test/script.stl:4
msgid "Scripting Test"
msgstr ""
-#: basest/levels/test/yeti.stl:4
-msgid "Yeti Test"
+#: basest/levels/test/verticalforest.stl:5
+msgid "Inside The Tree"
+msgstr ""
+
+#: basest/levels/test/ambient_sound.stl:4
+msgid "Ambient Sound Test"
+msgstr ""
+
+#: basest/levels/test/ambient_sound.stl:143
+msgid ""
+"-Info\n"
+"#An ambient sound \n"
+"#source playing the\n"
+"#rain effect should \n"
+"#be audible here.\n"
+"#Find Waterfall and \n"
+"#Lava sources with\n"
+"#smaller geometry \n"
+"#further right.\n"
+msgstr ""
+
+#: basest/levels/test/ambient_sound.stl:155
+msgid ""
+"-Info\n"
+"#Waterfall\n"
+"#Volume 0.2\n"
+msgstr ""
+
+#: basest/levels/test/ambient_sound.stl:161
+msgid ""
+"-Info\n"
+"#Lava\n"
msgstr ""
position.y=0;
distance_factor=0;
distance_bias=0;
+ maximumvolume=1;
sample="";
if (!(lisp.get("x", position.x)&&lisp.get("y", position.y))) {
lisp.get("distance_factor",distance_factor);
lisp.get("distance_bias" ,distance_bias );
lisp.get("sample" ,sample );
+ lisp.get("volume" ,maximumvolume );
+
+ distance_bias*=distance_bias;
+ distance_factor*=distance_factor;
if (distance_factor == 0)
silence_distance = 10e99;
else
- silence_distance = distance_factor*10e2;
+ silence_distance = 1/distance_factor;
+
+ lisp.get("silence_distance",silence_distance);
+
+ playing=-1; // not playing at the beginning
+ latency=0;
- playing=0;
- startPlaying();
}
+AmbientSound::~AmbientSound() {
+ stop_playing();
+}
void
AmbientSound::hit(Player& )
}
void
-AmbientSound::startPlaying()
+AmbientSound::stop_playing() {
+ if (playing>=0) {
+ Mix_HaltChannel(playing);
+ playing=-1;
+ }
+}
+
+void
+AmbientSound::start_playing()
{
playing=sound_manager->play_sound(sample,-1);
Mix_Volume(playing,0);
}
void
-AmbientSound::action(float)
+AmbientSound::action(float deltat)
{
- float dx=Sector::current()->player->get_pos().x-position.x;
- float dy=Sector::current()->player->get_pos().y-position.y;
- float distance=sqrt(dx*dx+dy*dy);
-
- distance-=distance_bias;
-
- if (distance<0)
- distance=0;
-
- targetvolume=1/(1+distance*distance_factor);
- float rise=targetvolume/currentvolume;
- currentvolume*=pow(rise,.05);
- currentvolume += 1e-30;
- // std::cout << currentvolume << " " << targetvolume << std::endl;
- Mix_Volume(playing,(int)(currentvolume*MIX_MAX_VOLUME));
+ if (latency--<=0) {
+
+ float dx=Sector::current()->player->get_pos().x-position.x;
+ float dy=Sector::current()->player->get_pos().y-position.y;
+ float sqrdistance=dx*dx+dy*dy;
+
+ sqrdistance-=distance_bias;
+
+ if (sqrdistance<0)
+ sqrdistance=0;
+
+ targetvolume=1/(1+sqrdistance*distance_factor);
+ float rise=targetvolume/currentvolume;
+ currentvolume*=pow(rise,deltat*10);
+ currentvolume += 1e-30;
+
+ if (playing>=0) {
+ Mix_Volume(playing,(int)(currentvolume*maximumvolume*MIX_MAX_VOLUME));
+ if (sqrdistance>=silence_distance && currentvolume<0.05)
+ stop_playing();
+ latency=0;
+ } else {
+ if (sqrdistance<silence_distance) {
+ start_playing();
+ latency=0;
+ }
+ else
+ latency=(int)(10*((sqrdistance-silence_distance)/silence_distance));
+ }
+ }
+ if (latency>0.001/distance_factor)
+ latency=(int)(0.001/distance_factor);
}
void
* (distance_bias) to the source, then fading proportional to
* inverse square distance
*
- * This is experimental and clicks a little. It is not possible to
- * get the clicks out without sample-granular volume adjustment.
- *
+ * - parameters for point source:
+ * x, y position
+ * distance_factor high = steep fallofff
+ * distance_bias high = big "100% disc"
+ * silence_distance defaults reasonably.
+ *
* basti_
*/
{
public:
AmbientSound(const lisp::Lisp& lisp);
-
+ ~AmbientSound();
protected:
virtual void hit(Player& player);
virtual void action(float time);
virtual void draw(DrawingContext&);
- virtual void startPlaying();
+ virtual void start_playing();
+ virtual void stop_playing();
private:
Vector position;
std::string sample;
int playing;
+ int latency;
float distance_factor; /// distance scaling
float distance_bias; /// 100% volume disc radius
float silence_distance; /// not implemented yet
+ float maximumvolume; /// maximum volume
float targetvolume; /// how loud we want to be
float currentvolume; /// how loud we are
/**
- * WARNING: This file is automatically generated from './build/i686-pc-linux-gnu/optimize/miniswig.tmp' - do not change
+ * WARNING: This file is automatically generated from './build/i686-pc-linux-gnu/debug/miniswig.tmp' - do not change
*/
#include <config.h>
/**
- * WARNING: This file is automatically generated from './build/i686-pc-linux-gnu/optimize/miniswig.tmp' - do not change
+ * WARNING: This file is automatically generated from './build/i686-pc-linux-gnu/debug/miniswig.tmp' - do not change
*/
#ifndef __supertux_WRAPPER_H__
#define __supertux_WRAPPER_H__