TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Background Ambiance (Finally! a working solution!)

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Finished Scripts
View previous topic :: View next topic  
Author Message
stormdragon2976



Joined: 19 Nov 2010
Posts: 73
Location: /dev/null

PostPosted: Mon Mar 26, 2012 1:09 pm    Post subject: Background Ambiance (Finally! a working solution!) Reply with quote

Here is the sound system I am using for the Alter Aeon trigger pack. the hardest thing to get working was the background music which I should have probably just called background soud because there's not any music in it lol. With this sound system you can have multiple sounds for a skill or spell. If you, for example, link an action to the casting of fireball and/or someone throwing a fireball at you to play fireball then anything named fireball will match. You can, therefore, have fireball.ogg, fireball1.ogg, fireball2.ogg, etc. The sound system looks for sounds in a subdirectory from where the trigger file is called. The directory should be called sounds. So, the path to fireball.ogg would be:
./sounds/fireball.ogg
In Alter Aeon you can enable a setting that will constantly update you with the current terrain type, your gold, current game time, etc. This is what I use for controling ambiances. I'm sure there would be ways to do this in other muds too, maybe by checking the room title for workds like forest or mountain, because I'm pretty sure the part that detects terrain type will have to e changed to work with your specific mud. But, for the code I have, in the sounds directory there should be a subdirectory called ambiance. Inside the ambiance directory, a directory called terrains will hold just the plain basic background noise, maybe a loop of crickets or something for forest, and a loop of frogs for marshlands, etc. For best results terrain sounds should only be 3 or 4 seconds long. Then, other folders, so far I have wilderness and town, can hold sounds that you might hear in those places. In wilderness, for example, I have several different bird calls and in town I have things like dogs barking and cats fighting.
One last bit of introduction before I post the actual code. I used sox for all of this because, as far as I can tell, it gives the most control. I was able to make it pan sounds, so the ambiance, dog bark, bird, etc will come from different directions. Also, you can adjust the volume of the soundpack, including the background sounds. Just remember to add in a beep or something for the volume change sound,new-volume.ogg. In this code volume down is bound to F7 and volume up is F8

#ACTION {^kxwt_terrain %1}
{
#if {"$bgmusic" == "true"}
{
#if {$oldTerrain != %1}
{
#script {bgmFileLength} {if [ -e "sounds/ambiance/terrains/%1.ogg" ] ; then soxi sounds/ambiance/terrains/%1.ogg | grep Duration | cut -f 1 -d "=" | cut -f 4 -d ":";else echo "0";fi};
#if {${bgmFileLength[1]} != 0}
{
bgmPlay %1;
#ticker {bgMusic} {bgmPlay %1} {${bgmFileLength[1]} - 0.05}
};
#else
{
#unticker {bgMusic}
}
};
#if {%1 >= 3 && %1 <= 6}
{
#ticker {ambiance} {#math {ambNumber} {1d2};#loop {1} {$ambNumber} {ambianceIndex} {ambPlay wilderness};#unvariable {ambNumber}} {2d10}
};
#elseif {%1 == 2 || %1 == 28}
{
#ticker {ambiance} {#math {ambNumber} {1d2};#loop {1} {$ambNumber} {ambianceIndex} {ambPlay town};#unvariable {ambNumber}} {2d10}
};
#else
{
#unticker {ambiance}
};
#variable {oldTerrain} {%1}
}
}
{9}

#ALIAS {play %1}
{
#if {!&{volume} || $volume == 0}
{
#system {$soundCommand "$(shuf -n 1 -e sounds/%1*ogg)" &> /dev/null &}
};
#else
{
#system {$soundCommand "$(shuf -n 1 -e sounds/%1*ogg)" gain $volume &> /dev/null &}
}
}
{9}

#ALIAS {ambPlay %1}
{
#script {ambFile} {shuf -n 1 -e $(ls sounds/ambiance/%1/*)};
#math {lChannel} {1d5};
#math {rChannel} {1d5};
#if {!&{volume} || $volume == 0}
{
#system {play -q ${ambFile[1]} remix v0.${lChannel} v0.${rChannel} &> /dev/null &}
};
#else
{
#system {play -q ${ambFile[1]} gain $volume remix v0.${lChannel} v0.${rChannel} &> /dev/null &}
}
}
{9}

#ALIAS {bgmPlay %1}
{
#if {!&{volume} || $volume == 0}
{
#system {$soundCommand "sounds/ambiance/terrains/%1.ogg" &> /dev/null &}
};
#else
{
#system {$soundCommand "sounds/ambiance/terrains/%1.ogg" gain $volume &> /dev/null &}
}
}
{9}

#ALIAS {bgmusic}
{
#variable {bgmusic} {true};
#showme {Background music is now on.}
}
{9}

#ALIAS {nobgmusic}
{
#unvariable {bgmusic};
#unticker {ambiance};
#unticker {bgMusic};
#showme {Background music is now off.}
}
{9}

#MACRO {\e[18~}
{
#if {$volume <= -40}
{
#variable {volume} {-40}
};
#else
{
#math {volume} {$volume - 2}
};
play new-volume
}

#MACRO {\e[19~}
{
#if {$volume >= 0}
{
#variable {volume} {0}
};
#else
{
#math {volume} {$volume + 2}
};
play new-volume
}

I hope I remembered every part of the code lol there's a lot of it. I hope someone else finds this useful too. If you have questions, and use Twitter or Identica, send me a mension on those, sometimes I forget to check for messages here for a few days.
_________________
Storm
Follow me at https://social.stormdragon.tk
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Finished Scripts All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group