Bruce
Active member
Hello everyone,
***** Notice: DC has a better and high level advanced scripts than mine, so go with his if you are able to learn it******
First of all, I really don't like mono sound... I know DC has come up with advanced coding tricks for panning mono samples to create stereo sound.
I have seen his sample, unfortunately, I have not seen the scripts, and at my current level, I am sure I am not ready for it yet regardless.
Recently I decided to see if I can come up with something more simple but better than mono sound.... This trick seems to work for me, so I would like to share it with everyone.
Although it is working for me, I am not sure if these scripts would cause any problem, so I need your help and advice for improvement.
The coding below is nothing new. You guessed it right! All the code came from this ChronCrash forum!
Sample video:
My goals are:
1. Contribute something to the ChronCrash forum
2. Someone can help me improve the scripts
3. and to learn more of course!
I need your Advice, so please any advice or suggestions are more than welcome, thank you
First, create constant variables to make our lives easier...
constants.c
LoadSoundEffects.c (preload the sound samples in the updated.c or wherever you think it is best) and unload them if you have to
PlaySoundLR.c
Total of left and right channel are 100%.
Basically, this script is to get the target position and plays the sample with left and right channels (in percentage) at that position.
Flash.txt
Char.txt
When you attack the enemy with attack 1, it will play the sample Slash01 at the player's position and as well the Beat01 from Flash (when the target gets hit) at the target's position.
It is still in mono sound, but it tricks our ears like stereo sound.
The disadvantage I see so far is that the sample sound is lower than normal. Meaning that you have to increase the sample volume to very high in the option menu.
Any questions, advice, or concerns, please don't hesitate to comment as I am here to learn, thank you
***** Notice: DC has a better and high level advanced scripts than mine, so go with his if you are able to learn it******
First of all, I really don't like mono sound... I know DC has come up with advanced coding tricks for panning mono samples to create stereo sound.
I have seen his sample, unfortunately, I have not seen the scripts, and at my current level, I am sure I am not ready for it yet regardless.
Recently I decided to see if I can come up with something more simple but better than mono sound.... This trick seems to work for me, so I would like to share it with everyone.
Although it is working for me, I am not sure if these scripts would cause any problem, so I need your help and advice for improvement.
The coding below is nothing new. You guessed it right! All the code came from this ChronCrash forum!
Sample video:
My goals are:
1. Contribute something to the ChronCrash forum
2. Someone can help me improve the scripts
3. and to learn more of course!
I need your Advice, so please any advice or suggestions are more than welcome, thank you
First, create constant variables to make our lives easier...
constants.c
Code:
// ===== LOAD /UNLOAD these SOUNDS in updated.c =======
//Sound FX (SoundFX_List)
#define BEATUP01 1
#define BEATUP02 2
#define SLASH01 3
#endif
LoadSoundEffects.c (preload the sound samples in the updated.c or wherever you think it is best) and unload them if you have to
Code:
#include "data/scripts/common/constants.h"
void LoadSoundEffects()
{
void soundFX_List = getglobalvar("SoundFX_List");
if(soundFX_List == NULL())
{
soundFX_List = array(3);
set(soundFX_List, 0, loadsample("data/sounds/SoundFX/BeatUp01.wav"));
set(soundFX_List, BEATUP01, loadsample("data/sounds/BeatUp01.wav"));
set(soundFX_List, BEATUP01, loadsample("data/sounds/BeatUp02.wav"));
set(soundFX_List, SLASH01, loadsample("data/sounds/Slash01.wav"));
setglobalvar("SoundFX_List", soundFX_List);
}
}
void UnLoadALLSoundEffects()
{
int i;
void soundFX_List = getglobalvar("SoundFX_List");
if(ActionList)
{
for(i=0; i<size(soundFX_List); i++)
{
set(soundFX_List, i, NULL());
}
free(soundFX_List);
setglobalvar("SoundFX_List", NULL());
}
}
PlaySoundLR.c
Code:
void PlaySound_LR(void ListName, int SoundName, int Speed)
{
void soundList = getglobalvar(ListName);
if(soundList != NULL())
{
int SoundReferenceID = get(soundList, SoundName);
if(SoundReferenceID){
void self = getlocalvar("self");
int PlayerDir = getentityproperty(self, "direction");
int EdgeXPos = openborvariant("xpos"); //Get screen left edge's position // from Bloodbane
int ScreenRes = openborvariant("hResolution"); // Get screen width/horizontal // from Bloodbane
//calculate the percentage of the left and right channels based on the target position.
float XPos = getentityproperty(self, "x");
int X = XPos - EdgeXPos;
float Left = (ScreenRes - X) / ScreenRes * 100;
float Right = X/ScreenRes * 100;
playsample(SoundReferenceID, 1, Left, Right, Speed, 0);
}
}
}
Basically, this script is to get the target position and plays the sample with left and right channels (in percentage) at that position.
Flash.txt
Code:
name Flash
toflip 1
type none
alpha 1
subject_to_gravity 0
animationscript data/scripts/sound/Sound_All.c
anim idle
loop 0
delay 3
offset 484 285
@cmd PlaySound_LR "SoundFX_List" BEATUP01 100 #Defined Var, Speed)
frame data/chars/misc/flash/hitspark101.gif
frame data/chars/misc/flash/hitspark102.gif
frame data/chars/misc/flash/hitspark103.gif
frame data/chars/misc/flash/hitspark104.gif
frame data/chars/misc/flash/hitspark105.gif
frame data/chars/misc/flash/hitspark106.gif
frame data/chars/misc/flash/hitspark107.gif
frame data/chars/misc/flash/empty.gif
Char.txt
Code:
anim attack1
hitflash Flash
hitfx data/sounds/Silence.wav # must be SILENCED to prevent OpenBor from playing default sample
fastattack 1
offset 570 840
bbox 493 450 163 388
delay 2
@cmd PlaySound_LR "SoundFX_List" SLASH01 100 #Defined Var, Speed)
frame data/chars/Dante/attack1_01.png
frame data/chars/Dante/attack1_02.png
It is still in mono sound, but it tricks our ears like stereo sound.
The disadvantage I see so far is that the sample sound is lower than normal. Meaning that you have to increase the sample volume to very high in the option menu.
Any questions, advice, or concerns, please don't hesitate to comment as I am here to learn, thank you
Last edited: