📧 Message Board Archive

OkalyD, Eldron...
Both of you have mentioned that you're using wave files instead of MIDI for your d-mod soundtracks.  I'm wondering what sample rate, etc you're using?  For example, "44100hz, 16bit stereo, 172 kb/sec" or "22050hz, 8bit mono, 22 kb/sec"...



Also, what problems, if any, have you encountered in attempting to implement this?
Re: OkalyD, Eldron...
well.. I downsample mine to 22050hz, mono at 16bit.. You still get a rather good sound quality, having it at 4bit and stereo is cool too, stereo mixes the sound in a very nice way, which will make it sound better...



the only problem would be the file sizes..

Re: OkalyD, Eldron...
: well.. I downsample mine to 22050hz, mono at 16bit.. You still get a rather good sound quality, having it at 4bit and stereo is cool too, stereo mixes the sound in a very nice way, which will make it sound better...

: the only problem would be the file sizes..



there is also that damn copyright problem, i used goldwave (godwave.com, i think) that makes em play right. i used 22050 16 bit too. its rather large, but sounds good.

Re: OkalyD, Eldron, Joshriot...


: there is also that damn copyright problem, i used goldwave (godwave.com, i think) that makes em play right. i used 22050 16 bit too. its rather large, but sounds good.



Yeah,I was wondering about that too.  I use "Creative Wave Studio" that came with my soundblaster card.  I asked about the sample rate because I was having problems getting this file to play.  Everytime my script told it to play, Dink would crash and then wouldn't run any more until I restarted my pc.  Finally I just tried loading it into a different soundbank and what do you know, it worked...weird.



Moving on...

In order to get the music to survive a screen change you have to use script_attach(1000); , right?  And if you want to stop it at certain screens you can use if (&player_map == x) along with a sound_set_kill()

My question is, how do you STOP it from playing when the player decides to reload a saved game or restart from the beginnng?  Since the title screen isn't on a player_map (or is it?) you can't use that.  Is it possible to have one script do a kill_this_task() on another script?  I tried assigning the sound to a global variable and then using sound_set_kill(&global) at the end of start.c, but that didn't work either.



Thoughts, insights, answers?
Re: OkalyD, Eldron, Joshriot...
Ok, I'll post up how I have my wavs playing.  I can't remember the quality, but whatever it was I'm going to dumb it down a bit, because they were way to big for even a person with cable to download... But uh, here's what I did...



You need a global, I just called it music.  Then in start.c I put this line:



int &music = playsound(99, 42050,0,0,1);

 sound_set_survive(&music, 1);

 &music = 1;



This means that wav 99 will repeat, and survive screen changes, and the &music = 1; means its my first song.  Then on everyscreen you attach a script, for town i have town.c, just something like that, and put something like this:



void main(void)

{

if (&music != 2)

{

kill_all_sounds();

&music = 0;

wait(1500);

int &music = playsound(95, 42050,0,0,1);

sound_set_survive(&music, 1);

&music = 2;

}

}



It simply sees if song 2 is playing, and if not, kills the current music (along with all sound, if i can find a better way to do this i will), then plays song 2, which is wav 95 etc



Its actually quite simple.  Just whenever you want, play another wav and set &music to whatever.  You'd think it would mess up with an integer &music and a global &music, but it hasn't...



Oh, something i thought of that i might implement...is this.  Get ready, you might wet yourself....or not...



But uh, instead of loading up all my songs, i was just going to select one track, say sound 99, for music.   Load up the first song i needed in start.c  Then whenever i wanted to change, i just put load_sound("whatever.wav", 99); and i'll probebly just have to tell it to restart sound 99.  Or what might happen that would be real cool is when you loaded a new sound it would autimaticaly start playing the new wav...but probebly you'll have to kill it, load the other wav, play it again...but ya just something that i thought of a long time ago and haven't gotten around to changing yet...



But the wavs work great...the only problem is it requires more ram, and people with crap connections will complain...for this reason i'm releasing a midi version along with my wav...i'm not sure if i'm gonna do my midis in a cool looping fashion or anything...maybe i'll just do it crappy because...i mean they're already crappy anyway...heh...



But ya, for all you guys with cables or dsls or anything, definately get the wav version...my friends music kicks a lot of ass.

Re: OkalyD...
That did it.  Thanks!



I loading the files all into the same soundbank as needed, rather than loading them all into their own separate banks is definetly the way to go... should cut down on some of that memory usage too.
Re: OkalyD...
: That did it. Thanks!

: I loading the files all into the same soundbank as needed, rather than loading them all into their own separate banks is definetly the way to go... should cut down on some of that memory usage too.



Ya thats what i was thinking...did you simply change it, or did you have to kill it and replay it again?



Oh and if you find a better way to kill the music than just killing all sounds, let me know...

Re: OkalyD...this is interesting


: Ya thats what i was thinking...did you simply change it, or did you have to kill it and replay it again?

: Oh and if you find a better way to kill the music than just killing all sounds, let me know...



Instead of kill all sounds you can use sound_set_kill, like this...



&music is a global, so is &track, I copied your idea of using &music as a local variable too, but have yet to determine what, if any advantages/diadvantages this has.



//script 1, to start song1 rolling

void main(void)

{

int &music = playsound(2,22050,0,0,1);

sound_set_survive(&music, 1);

&track = &music;

&music = 1;

}

//script 2, to stop it

void main(void)

{

if (&music == 1)

   {

   sound_set_kill(&track);

   }

}

So, I wonder if that is better or worse than killing all sounds?  I suppose, if you had another sound_set_survive running, like maybe dink saying "ow,ow,ow" cuz he was walking on hot sand, then using sound_set_kill would allow you to stop the music, but keep the "ow,ow,ow" going.  Whereas killing all sounds would stop them both.  I haven't tried this yet though.



And here is an interesting note, no pun intended,

I tried adding the line

load_sound("song2.wav", 2);

at the end of script1 in hopes that when song1 went to repeat it would simply start playing song2, but no, it keeps playing song1.  Further,  using playsound(2,22050,0,0,1); in a another script, without having told song1 to stop, actually lets both songs play at the same time!  I guess this is because song1 is still loaded into memory.



Of what value this is, I don't know.  I suppose it could mean that changing songs at screen changes could be done much faster, but having both songs loaded into memory at the same time might cause the game to run slower.  Seems like a six of one, half a dozen of the other situation.



In short, you can have both songs loaded into memory at the same time, on the same bank, it just means that your next playsound command will play the song most recently loaded.  And if you don't ever kill the first song, you'll have both playing at the same time.

Re: OkalyD...this is interesting
: : Ya thats what i was thinking...did you simply change it, or did you have to kill it and replay it again?

: : Oh and if you find a better way to kill the music than just killing all sounds, let me know...

: Instead of kill all sounds you can use sound_set_kill, like this...

: &music is a global, so is &track, I copied your idea of using &music as a local variable too, but have yet to determine what, if any advantages/diadvantages this has.

: //script 1, to start song1 rolling

: void main(void)

: {

: int &music = playsound(2,22050,0,0,1);

: sound_set_survive(&music, 1);

: &track = &music;

: &music = 1;

: }

: //script 2, to stop it

: void main(void)

: {

: if (&music == 1)

:   {

:   sound_set_kill(&track);

:   }

: }

: So, I wonder if that is better or worse than killing all sounds? I suppose, if you had another sound_set_survive running, like maybe dink saying "ow,ow,ow" cuz he was walking on hot sand, then using sound_set_kill would allow you to stop the music, but keep the "ow,ow,ow" going. Whereas killing all sounds would stop them both. I haven't tried this yet though.

: And here is an interesting note, no pun intended,

: I tried adding the line

: load_sound("song2.wav", 2);

: at the end of script1 in hopes that when song1 went to repeat it would simply start playing song2, but no, it keeps playing song1. Further, using playsound(2,22050,0,0,1); in a another script, without having told song1 to stop, actually lets both songs play at the same time! I guess this is because song1 is still loaded into memory.

: Of what value this is, I don't know. I suppose it could mean that changing songs at screen changes could be done much faster, but having both songs loaded into memory at the same time might cause the game to run slower. Seems like a six of one, half a dozen of the other situation.

: In short, you can have both songs loaded into memory at the same time, on the same bank, it just means that your next playsound command will play the song most recently loaded. And if you don't ever kill the first song, you'll have both playing at the same time.





Ok, very interesting on the loading over sounds..hrm..



About your script...if you were to call track in another script, wouldn't it need to be a global like music?



And i think it would be easier to just do:

void main(void)

{

&track = playsound(2,22050,0,0,1);

sound_set_survive(&track, 1);

&music = 1;

}

//script 2, to stop it

void main(void)

{

if (&music == 1)

   {

   sound_set_kill(&track);

   }

}



I'm going to try this out some time...so ya...if you try it first, let me know..just start a new thread tho.
Re: OkalyD, Eldron, Joshriot, Kindanue...
What about setting a script to run a procedure inside the script you want to kill, and killing it from there? I Don't know if this would work though. You could also have a loop to infinity unless a variable is equal to whatever, with a wait statment so it wouldn't tie up all the resourses in the commp. You could then just change the global variable to not run the music in start c or whatever. but this could also make the music stop if you load a nonexistange game for example, then decide not to load a saved game.....
Re: OkalyD, Eldron, Joshriot, Kindanue...
: What about setting a script to run a procedure inside the script you want to kill, and killing it from there? I Don't know if this would work though. You could also have a loop to infinity unless a variable is equal to whatever, with a wait statment so it wouldn't tie up all the resourses in the commp. You could then just change the global variable to not run the music in start c or whatever. but this could also make the music stop if you load a nonexistange game for example, then decide not to load a saved game.....



I'm not sure what to think of most of what you just said..mainly because i don't understand it ;)  But uh, as far as the start.c music goes, i was just showing that you can play music other than just depending on what screen your on.  I mean, the way it is it'll play a certain song on a certain screen, but you could easily override it by checking either what &music is, if its a special song, or &story, something like that.

Re: OkalyD, Eldron, Joshriot, Kindanue...


: : What about setting a script to run a procedure inside the script you want to kill, and killing it from there? I Don't know if this would work though. You could also have a loop to infinity unless a variable is equal to whatever, with a wait statment so it wouldn't tie up all the resourses in the commp. You could then just change the global variable to not run the music in start c or whatever. but this could also make the music stop if you load a nonexistange game for example, then decide not to load a saved game.....

: I'm not sure what to think of most of what you just said..mainly because i don't understand it ;) But uh, as far as the start.c music goes, i was just showing that you can play music other than just depending on what screen your on. I mean, the way it is it'll play a certain song on a certain screen, but you could easily override it by checking either what &music is, if its a special song, or &story, something like that.



I really should log in...