Playing sounds problem

Posted By: 4gottenname

Playing sounds problem - 06/28/09 19:59

I ran in to an annoying litle problem again and been searching for an anwser for hours. This time I can't figure out how to play sounds. Can't even get the beep(); to work...
Been studying the menu example from AUM 69. I get the WMB unsuported error but the music works fine. I want to make a similar sound options thing as in the AUM menu example - a master voulume, a diffrent volume for wav files, an other for music (midi?) and one for voices.
Is there any tutorial on the net or in a AUM that I've missed that teaches you everything you need about playing sounds? (in Lite-C!) Or would anyone like to explain it for me here and perhaps give me a small code to try?
Posted By: GameScore

Re: Playing sounds problem - 06/28/09 20:04

you should use wav. format

and if you want to play a sound for a damage or something like that u have to write some like this
snd_play(ping,100,0);
this must be in the function who is called wehn un need this sound
othr was when u use to run a sound from the start of your game
you can write in your main

snd_loop(ping,100,0);
and a sound starts and never ends till you write
snd_stop(ping);

you should read in the manual for more to know
Posted By: Cowabanga

Re: Playing sounds problem - 06/28/09 20:16

To play a sound, use:
"snd_play".
"snd_loop".

To play a 3D sound from an entity, use:
"ent_playsound".

To play music, use:
"media_play".
"media_loop".

Don't forget the handles!! wink
Posted By: 4gottenname

Re: Playing sounds problem - 06/28/09 20:31

I have defined SOUND* testwav = "mouseover.wav"; and call a function with snd_play(testwav,100,0); in it when mousing over a button but i hear no sound. Maybe my wav file has wrong format or something but as I said earlier I can't get the beep sound either. An other problem is that when I test run my script the screen is black and my panel with button dont show (when I've added a snd_play(testwav,100,0); or similar line). I've read the manual and I must be missing something important...
Posted By: EvilSOB

Re: Playing sounds problem - 06/28/09 21:30

Theres not much to go wrong with beep. As long as you are using just
beep(); with the brackets, and no numbers in the brackets.
This triggers the windows "default beep", so it should always work.

Can you post the first 10 lines of an acklog.txt?
Or at least check for these three lines with the first 10 lines.
MM mixer opened
DSOUND device opened
DI interface opened

Posted By: 4gottenname

Re: Playing sounds problem - 06/28/09 22:09

Took me a while to find the diag option thing...

MM mixer opened
DSOUND device opened
DI interface opened
Start Window opened
(c)Conitec . Dieburg . San Diego . www.3dgamestudio.com
Atari Lite-C - Free Edition V1.70.1 - Feb 5 2009
Development version

Mouse found
SB Live! Wave Device opened
NVIDIA GeForce 7600 GS pure T&L device 1ff9 detected
D3D device NVIDIA GeForce 7600 GS 1ff9 selected.
Posted By: MrGuest

Re: Playing sounds problem - 06/28/09 22:18

just try

Code:
void main(){
  wait(1);
  beep();
}


if this works i'm guessing you've not set mouse_mode, so there's no recognition of the mouse being over the panel
Posted By: 4gottenname

Re: Playing sounds problem - 06/28/09 22:29

It dosn't work, I hear no beep.
And I have mouse mode 1 in my other script. Seems to be this SOUND* testwav = "mouseover.wav"; line that makes the screen go black, if it's commented my panel shows. Gona try with some other wav files..

Posted By: EvilSOB

Re: Playing sounds problem - 06/28/09 23:48

Question, go to windows 'Control Panel'/'Sounds and Audio Devices'/'Sounds' Tab/Page.
Then look in the "events" list to see if there is a WAV attached to the "Default Beep" event.

This is the sound 3DGS will play when it hits a beep(); function.
If it is empty, put anything in it (for now), and then test MrGuest's code again.

How did it go?
Posted By: 4gottenname

Re: Playing sounds problem - 06/29/09 09:31

Ahh, thanx EvilSOB! That solved my beep problem laugh
Default beep was empty! I had it on windows default so kinda strange.
Now I can finaly test if my functions actually are called but I don't think it will solve the other music/wav playing problems.

EDIT: Suddenly got the wav working when copy and pasting from AUM 69 menu code, that changed the name from testwav = "mouseover.wav"; to mouseover_wav = "mouseover.wav";
What was wrong with testwav?? confused

EDIT2: And what format should I use for the music files, since mp3 not suported? Need to find a converter...
Posted By: 4gottenname

Re: Playing sounds problem - 06/29/09 16:25

Still need a litle bit of help.
I got a panel with 4 sliders that should control the volumes for master, sfx, music and voices. They sort of work but not exactly the way I want them to wink

hslider(381, 125, 281, volumeslider, 0, 100, master_vol);
hslider(381, 163, 281, volumeslider, 0, 100, sfx_volume);
hslider(381, 201, 281, volumeslider, 0, 100, music_volume);
hslider(381, 238, 281, volumeslider, 0, 100, voices_volume);

master_vol is predefined and works perfectly. When dragging it all the playing sound volumes gets lower or higher. Is it possible to get this effect with the 3 others, made up ones?
I have a button next to every slider that plays a sound sample when klicked. I have to klick and play the sound again after i dragged the slider to hear the changes. I want them to change while I'm dragging.
And someone please tell me what file format to use for longer music, wav gets too big :P (need to be suported)
Posted By: EvilSOB

Re: Playing sounds problem - 06/29/09 21:54

Im no biggie on sounds yet, hell, I havent even gone beyond "beep()" yet... BUT

(for EDIT1)I dont think its actually working CORRECTLY, you just got lucky.
Whenever 3DGS loads a SOUND file, it also creates a hidden SOUND structure based
on the sounds filename, with a "_" replacing the "." (ie "beep.wav" becomes beep_wav)
So your new name is just a lucky "match" to that hidden name.
More testing is required. Maybe post the code lines that actually DO the snd_play / snd_loop?

(for EDIT2) I assume you are using snd_play or snd_loop to run the sounds.
Firstly, snd_anything can ONLY play WAV or OGG files. So I suggest to hit the manual,
and read up on MEDIA_play and MEDIA_loop. They CAN handle mp3 files.
You just need to use them a LITTLE differently. (No SOUND objects)

Assuming you use media_something to play your music, you can use this panel code to control your volumes.
hslider(381, 125, 281, volumeslider, 0, 100, master_vol); <<still MASTER volume
hslider(381, 163, 281, volumeslider, 0, 100, sound_vol); <<still SFX volume
hslider(381, 201, 281, volumeslider, 0, 100, midi_vol); <<still MUSIC volume
hslider(381, 238, 281, volumeslider, 0, 100, voices_volume); <<no idea.....
Posted By: 4gottenname

Re: Playing sounds problem - 06/30/09 13:11

In one of my previous post i said
"I have defined SOUND* testwav = "mouseover.wav"; and call a function with snd_play(testwav,100,0); in it".
Later when I changed both the testwav names to mouseover it started working. The strange thing was that the SOUND* testwav = "mouseover.wav"; line caused my panel to not show so I never even got to klick the button that should have played the wav...
But now it works and I'm happy.

Yesterday I tried media_play with a mp3 and got a "mp3 unsuported format" so thougt I couldn't use them with free version. same with an other format. Tried again today after reading your post and it works fine so either the mp3 was bad or I must have screwd it up and used snd_play or something after all.
I do read the manual before I post, I just don't get it all wink They so need to add more explanations and examples.

This is the problem with sound_vol: "It does not affect the volume of still playing sounds that were started before" and I asumed the same was for midi_vol but that one actually work.
Any ideas on how to make the sfx and voices volume change while playing the sounds? Can't be impossible... Not that important for my project (they only set the volume value for the sounds later on in the game) but it bothers me. I bet others have needed something like this before.
Plan B would be to make the sound stop when slider gets dragged and automaticaly play again when slider stands still / left mouse button released...
© 2024 lite-C Forums