v3 Music-related Query
Displaying 1-18 of 18 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Interference22

Howdy. I'm happily working away at a set of functions for an RPG in v3, what with my last little project mysteriously managing to delete itself.

Anyway, I'm getting along with not too much trouble - well, as little as you can expect at a point where there isn't any documentation for it out yet - but I have of course hit a minor problem. Wouldn't be here if I hadn't, eh?

Anyway, the code in question that is causing me some degree of concern is the following:

(Apologies in advance for any instances of code that could probably be a lot better. I'm on the lower end of intermediate.)


void FadeOut_m()
{
int loop;

loop = 100;

while (loop > 0)
{
SetLucent(loop);
rectfill(0,0,screenx, screeny,rgb(1,1,1),screen);
ShowPage();
loop == loop-1;

if (GetSongVolume(currentmusic) > 0)
SetSongVolume(currentmusic, (GetSongVolume(currentmusic)-1));

Wait(2);
}
SetLucent(0);
FadeMusic();
}



"currentmusic" stores the music currently being played at all times.
"screenx" and "screeny" are just aliases for the height and width of the screen. They were in v2 but not v3. It would be nice to see them back, as either one is shorter to type than "ImageHeight(screen)."

Its supposed to fade to black, fading the music with it. If it isn't completely quiet by the end of the while loop, the FadeMusic() function I scripted does it immediately afterwards. This is because the user can alter the music volume in-game, so the function isn't sure what volume the music is actually at when it runs. As you can guess, it doesn't quite work.

The visual fade happens, but the audio one doesn't. So:

1. What the heck am I doing wrong?
2. Are the built-in functions I'm using fully functional?
3. Am I using aformentioned functions correctly?
4. Have I just missed something painfully obvious?

V3 is great, by the way. Very, very exciting stuff going on.

Posted on 2004-03-12 10:17:29 (last edited on 2004-03-12 10:20:48)

RageCage

ok well first off, your
loop == loop-1
shouldent even work. it need to be
loop = loop-1
or
loop-=1

although I'm in kinda hurry so I'll post again later if someone else hasnet already seen your problem

Posted on 2004-03-12 13:44:58

mcgrue

I'll assume you're using the latest version of v3, complete with fmod?

I'm not quite sure what's wrong offhand. If you come to #vergehelp on espernet, I (or someone else) will to help you.

Posted on 2004-03-12 16:27:26

vecna

Although I've personally tested SetSongVolume, I haven't actually tested GetSongVolume and it's possible it is not working. It's also possible something else entirely is wrong. ^_^

Two things:

First, I've since added volume functions to the "simple" music api, so that you can do audio fades without needing to use the advanced API. That'll be in a new EXE released soon, a week or so. (you would only need to use the advanced API for music crossfading, position manipulation, or caching)

Secondly, are you testing this with module/midi files, or mp3/ogg files? The two have totally separate interfaces in FMOD, a fact which VC hides from you, so its possible that the music commands can be working for one and broken for the other.

Posted on 2004-03-12 23:06:04

Interference22

Well, nice to see I won't have to code this soon. I'm using the v3 with fmod. The file I'm trying to fade is a module: an XM to be precise although I have tried the same function with a MOD too and it also doesn't work.

I also made the FadeMusic() function I was using log the volume. The music is supposed to be at a volume of 100 but once FadeMusic starts logging the volume, it hits four then one and then zero. Yargh.

Posted on 2004-03-15 10:38:31

RageCage

ok well after some trial and error and some fancy math, I figured out that while the getsongvolume() is on a scale of 0-99, the setsongvolume is on a scale of 0-666. thus your problem. of corse I tested this with mp3 so I dunno if it is still true for .xm or .mod

heres a nice little working fade function, its a lot different from yours but it should work.

(note: I dont know how to display code in here very well quite yet so I put a (lessthan) instead of the left pointy carrot of a symbol) [edit: I put one in for you -Grue]

void musicfade(int duration, int song){
timer=0;
while(timer<=duration){
setsongvolume(song, (duration-timer)*666/duration);
}

}

Posted on 2004-03-15 17:21:57 (last edited on 2004-03-15 18:29:42)

rpgking

Seeing "666" in that code makes it look evil.

Posted on 2004-03-16 04:57:22

Interference22

Wah. I don't believe it. 666? I trust that's going to get fixed.

Posted on 2004-03-16 09:28:55

mcgrue

The rock and the roll is the music of the devil, doncha know?

Posted on 2004-03-16 16:45:49

RageCage

how do you put that symbol in?

Posted on 2004-03-16 19:37:47

mcgrue

&lt; is the html entity for <

FYI:
& starts an html entity.
; finishes it.
The inside usually is an abbreviation for it.

lt in this case stands for "less than".

Posted on 2004-03-16 20:55:27

RageCage

<Thanks>

Posted on 2004-03-16 21:24:40

Troupe

<l337 5k111z>

Posted on 2004-03-18 17:34:17

Interference22

Ok, enough.

Posted on 2004-03-19 09:44:44

Overkill

"screenx" and "screeny" are just aliases for the height and width of the screen. They were in v2 but not v3. It would be nice to see them back, as either one is shorter to type than "ImageHeight(screen)."

Code



#define screenx imagewidth(screen)
#define screeny imageheight(screen)



I'm pretty sure that if you type the following, it will let you. I haven't tested this, though.

Posted on 2004-03-20 02:55:37 (last edited on 2004-03-20 02:56:21)

mcgrue

Or, if you're a hater of #defines:


int ScreenX() {
return imagewidth(screen);
}


int ScreenX() {
return imageheight(screen);
}




Encapsulation is good.

Posted on 2004-03-20 05:50:42

Interference22

I already #define'ed them. That's sort of what I meant by "alias." Vague, aren't I?

It just would have been nice to not have to define 'em. Laziness, really, but it saves the time it takes to realise they're not there when you're porting v2 code over to v3.

Posted on 2004-03-23 14:41:37

vecna

song volume bug fixed in next build

Posted on 2004-04-21 23:40:44


Displaying 1-18 of 18 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.