I added ambient sound to my public bath room for a break, so I'll make a note of how to do that before I forget.
Chapter 1 - Sound design
First you should consider what ambient sounds can be heard and at what volume from what location.
In my case I decided to put two ambient sounds.
One is the sound of stream from hot spring.
The second is the sound of a koto playing and a noise coming from a distant room.
Sound of stream locates near and the right of camera position.
Sound of music locates far and the left of camera position.
Chapter 2 - Creating Sound file
As technical information, sound file must be vorbis format (Ogg Vorbis) and monaural sound. I used app called "Audacity" both in making mono sound to which multiple sound sources are combined, and in exporting Ogg Vorbis. The reason why the sound source should not be stereo is that you do not always hear sound in constant position in the game. In fact the camera position moves and rotates, and that results in sound mixing being changed as if you were the mixer yourself, and that's why stereo sound doesn't have point here.
I recorded a part of ambient sound on this web site that my friend told me about.
https://mynoise.net/
I merged sound of wind chime and shishi-odoshi into the stream sound as the "near" sound, while bustle and rumble sound into the koto sound that I got from other source as the "far".
Chapter 3 - Coding
This is the main part of this topic.
There are 4 files in a room addon you need to edit to put ambient sound in it.
- AcRoom
- AvRoom
- Scene file
- Sound file
Lets see one by one. I use my room addon "DriverRoom1" as the reference here.
1. AcRoom (Addons\VX.DrvRoom1.BlankRoom\Scripts\Luder\DriverRoom1\AcRoom.bs)
In the .ComponentArray those entries are inserted:
AppImportSound . {
.NodeName "DrvRoom1_Ambience1";
.ParentPath "/Room" + :room + "/sound_ambience1/sound_ambience1_offset";
.SoundFile "Shared/Effect/DrvRoom1_Ambience1";
.MixerFlags "SC3D";
.Category "Ambient";
.Volume F32(-10);
};
AppImportSound . {
.NodeName "DrvRoom1_Ambience2";
.ParentPath "/Room" + :room + "/sound_ambience2/sound_ambience2_offset";
.SoundFile "Shared/Effect/DrvRoom1_Ambience2";
.MixerFlags "SC3D";
.Category "Ambient";
.Volume F32(-10);
};
Probably you don't have to have the same name in the sound file as the node name, but I did, not to make mistake. Also you can edit the volume, it only works in a minus direction I guess but not tested yet.
2. AvRoom (Addons\VX.DrvRoom1.BlankRoom\Scripts\Luder\DriverRoom1\AvRoom.bs)
AvSituation :ROOM . {
.WithoutFurniture True;
.Def [ AvPose . {
};
];
.Do [
AvPlay . {
.SoundName "DrvRoom1_Ambience1";
};
AvPlay . {
.SoundName "DrvRoom1_Ambience2";
};
];
};
Simply insert the code below the .Do
3. Scene file (Addons\VX.DrvRoom1.BlankRoom\Scenes\Luder\Room\DriverRoom1\DriverRoom1.bs)
This is the most difficult part, so please keep up! But no worries, all you need is basically to insert code in existing addon.
TTransform :local_Base . {
TNode.SNode STransform :local_SBase;
TNode.Parent TTransform :local_Scene;
Object.Name "Base";
};
TTransform :local_sound_group . {
TNode.SNode STransform :local_Ssound_group;
TNode.Parent TTransform :local_Base;
Object.Name "sound_group";
};
TTransform :local_sound_ambience1 . {
TNode.SNode STransform :local_Ssound_ambience1;
TNode.Parent TTransform :local_sound_group;
Object.Name "sound_ambience1";
};
TTransform :local_sound_ambience1_offset . {
TNode.SNode STransform :local_Ssound_ambience1_offset;
TNode.Parent TTransform :local_sound_ambience1;
Object.Name "sound_ambience1_offset";
};
STransform :local_Ssound_ambience1_offset Object.Name "Ssound_ambience1_offset";
STransform :local_Ssound_ambience1 . {
SSimpleTransform.Translation Vector3f( -13.500, 0, -5.00 );
Object.Name "Ssound_ambience1";
};
TTransform :local_sound_ambience2 . {
TNode.SNode STransform :local_Ssound_ambience2;
TNode.Parent TTransform :local_sound_group;
Object.Name "sound_ambience2";
};
TTransform :local_sound_ambience2_offset . {
TNode.SNode STransform :local_Ssound_ambience2_offset;
TNode.Parent TTransform :local_sound_ambience2;
Object.Name "sound_ambience2_offset";
};
STransform :local_Ssound_ambience2_offset Object.Name "Ssound_ambience2_offset";
STransform :local_Ssound_ambience2 . {
SSimpleTransform.Translation Vector3f( 4, 0.4, -0.5 );
Object.Name "Ssound_ambience2";
};
STransform :local_Ssound_group Object.Name "Ssound_group";
STransform :local_SBase Object.Name "SBase";
"Local_Base" comes first, this is parented to "local_Scene", the root of room scene file. You can name it Base/Ground/Papa/anything, but anyway I call it "Base"
The structure is kinda like below:
Scene---Base---Sound_Group---Sound_ambience1---Sound_ambience1_offset
---Sound_ambience2---Sound_ambience2_offset
Probably you can ignore the Sound_ambience_offset, I don't know how they work. Perhaps someone kind will enlighten us. Most important thing here is to set the position of sounds in STransform :local_Ssound_ambience1/2. Here you must specify the coordinates at which to place the sounds. The easiest way to get them is to use h5 object in game.
Now you got the coordinates and wrote them in the scene file, let's go to the final step.
4. Sound file (\Addons\VX.DrvRoom1.BlankRoom\Sounds\Shared\Effect\)
You already made 2 Ogg sound files in the chapter2, so all you have to do is just put them in \Sounds\Shared\Effect\
The name of sound files must be identical to those of AcRoom.bs
In my case they are:
DrvRoom1_Ambience1.ogg
DrvRoom1_Ambience2.ogg
Here is the outcome. Enjoy the bath!
- 1
- 1
- 2
- 1
3 Comments
Recommended Comments