Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by M_D. 04/26/24 20:22
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (M_D, AndrewAMD, Quad, Ayumi), 806 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
What's with the "Media_" functions? #260838
04/14/09 03:05
04/14/09 03:05
Joined: Feb 2004
Posts: 718
Wisconsin
Irish_Farmer Offline OP
User
Irish_Farmer  Offline OP
User

Joined: Feb 2004
Posts: 718
Wisconsin
edit: As luck would have it, I figured out the solution to the problem. The manual notes that .mid can't be altered, but it lead to me finding the master_vol variable which will affect midi volume.....nvmnd. frown [/edit]


So, I've had this problem ever since A6, and I've just downloaded lite-c (with A7 - free cuz I'm poor) and the problem is still there. I'm pretty sure this is user error, because this would be a rather noticeable bug, so maybe someone can show me where I'm going wrong.

The aim of my code is simple: play a midi file, and then fade that midi file out until it is completely quiet. The problem is, media_tune() or even the midi_vol variable aren't doing anything for me. I've also tried just using the generica "media_handle" handle to see if I can manipulate that and I can't. The song plays at full volume unphased, unless I use media_stop() to abruptly end it. In fact, I can't even start the song at a lower volume. What's the deal?! If I didn't know any better, I would say the functions are broken.

I've been trying to get back into programmiing, but there's nothing more frustrating then when I'm testing out the early features of my project and the simplest things aren't working...despite that I'm following the documentation word-for-word.

Thanks in advance for any help.

Code:

[code]
var volume = 100;

function main()
{
video_mode = 8;
video_screen = 1;
var hMedia = 0;
hMedia = media_loop("Dungeon01.mid", NULL, 100);
while (volume > 0)
{
volume -= 1;
media_tune(hMedia, volume, 0, 0);
wait (1);
}

}

Last edited by Irish_Farmer; 04/14/09 03:12.

"The task force finds that...the unborn child is a whole human being from the moment of fertilization, that all abortions terminate the life of a human being, and that the unborn child is a separate human patient under the care of modern medicine."
Re: What's with the "Media_" functions? [Re: Irish_Farmer] #260841
04/14/09 03:26
04/14/09 03:26
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
There is no problem with the code. Its only one line which is wrong: wait(1).

The engine frame rate is too fast that you cant notice the fade off. Its actually happening. Suppose ur engine running at 512fps. That means for the fade off (which happens over 100 frames) is being done in 100/512 seconds. Thats way to fast to notice it.

Instead i would suggest u use "seconds" to define your wait between the transition. here is something:

Code:
var volume = 100;

function main()
{
video_mode = 2;
video_screen = 2;
var hMedia = 0;
hMedia = media_loop("battle.mid", NULL, 100);

while (volume > 0)
{
	volume -= 1;
	media_tune(hMedia, volume, 0, 0);
	wait (-0.02);
}


u can play around with "0.02" to any value u want. here 0.02 is the seconds to wait between each 1 volume down.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: What's with the "Media_" functions? [Re: delinkx] #260848
04/14/09 04:53
04/14/09 04:53
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
What the manual says is not wat u want to do. Its the midi_vol that do not allow the volume adjustment. And midi_vol variable affects the mixer(system) volume control. If u using master_vol that also affects the mixer and put off all sounds if set to 0. So this wont be appropriate for a game unless u want to mute off all sounds.

Note: The code above is tested and it works. In this way it affects only tat sound referred to by the media handle.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: What's with the "Media_" functions? [Re: delinkx] #260938
04/14/09 18:41
04/14/09 18:41
Joined: Feb 2004
Posts: 718
Wisconsin
Irish_Farmer Offline OP
User
Irish_Farmer  Offline OP
User

Joined: Feb 2004
Posts: 718
Wisconsin
The problem I was having wasn't that the midi file was fading out too fast; instead the file wasn't fading out at all. As a point of fact, it doesn't matter what volume parameter I pass to media_loop() to begin with, because the midi file will always play at the same volume.

This may not be a universal problem, perhaps only certain midi files (or certain computers). The manual says that if the audio mixer has no synthesizer channel, then it won't effect volume - well my computer doesn't have a synthesizer channel so there you go. I don't want people without this channel in their mixer to have a different sound experience, than those that do.

The master_vol variable will have to work, because its the only thing that effects the volume of these midi files, without any caveats. Because of the simplistic audio needs of my game, there won't be any noticeable problems caused by the use of the master_vol variable.

Another alternative solution would be to convert all of my .mid files into .mp3, because media_tune WILL change the volume of these files under all circumstances. But that would significantly increase the size of the finished game's folder with no payoff in improved sound or anything like that.

Thanks for the input.

Last edited by Irish_Farmer; 04/14/09 18:45.

"The task force finds that...the unborn child is a whole human being from the moment of fertilization, that all abortions terminate the life of a human being, and that the unborn child is a separate human patient under the care of modern medicine."

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1