Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tier 2 sound playing problem

Author
Message
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 25th Sep 2012 02:49
I'm studying AppGameKit at the moment and have using it for a good while to create little apps and games These games so far have required no sounds so when I went to create a sound orientated game I hit into the problem of not being able to actually play any sound. After many hours of pondering I thought it might be something to do with something in my code that I am not able to see, so I created a simple sound app:- You hit the key it plays the sound But still no sound Heres my code for my tester app:-



And just as it may help you help me i'm using visual studio c++ 2010.

Thank you.

life is short but so am i
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 25th Sep 2012 02:57
I have never used the VS Tier 2 version, but I believe:



Should be:



Otherwise you are actually assigning bpressed to 0 with each conditional check, and therefore playing the sound from the beginning infinitely which would result in no sound.
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 25th Sep 2012 03:17
Should of mentioned that i've tried that but thank you anyways.

life is short but so am i
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 25th Sep 2012 03:59
Where have you placed the sound file? It should be in the same folder as the .exe produced which is typically in a folder called "Final".

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 25th Sep 2012 10:26
PlaySound works fine.
check that you have bass.wav in the same folder as your VS project file.
also check the format of bass.wav. use other different sounds to test
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 25th Sep 2012 16:42
xCept is correct, it should be 'if (bpressed == 0)'. The way you have it you are resetting the value to zero, not comparing it and as a result the if statement will always fail and the sound will never play. (I've been programming in C and C++ and other languages for more than 30 years, trust me on this one.)

Also make sure that the name of the actual file is exactly as you have it spelled in your code, case included. (This is more for execution on platforms other than Windows.)

I know PlaySound works in Tier 2. I use it a lot in my game and it works in Windows, iOS 5.1/6.0 and Android 3.2/4.1.

As bjadams suggests, it may be the format of the file as well. That issue is mentioned in other posts.

Cheers,
Ancient Lady
AGK Community Tester
erebusman
13
Years of Service
User Offline
Joined: 23rd Jul 2011
Location: Sacramento, CA
Posted: 25th Sep 2012 16:59 Edited at: 25th Sep 2012 16:59
I have to agree with the others on the formatting in C++

Here's a tiny clip from my app:


You'll note I pass more parameters because I'm looping the sound and controlling its volume (check the instructions for what those all mean)

And the sound has to be in my my documents/agk/template/ folder for it to work.

But I have about 25 sounds that all work well this way!
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 25th Sep 2012 18:38
That's a long-existent "gottya" of C. Millions of hours have been wasted poring over code that has = instead of ==.

C and Pascal were developed at almost the same time (1968/9), but Wirth avoided this trap with two operators:

= (equates to)
:= (assignment)

Anyway, what do I care? I'm taking a break from programming and sitting on a balcony in Greece looking at the sun beginning to set over some islands in the Ionian Sea, with a glass of red wine to hand!

If glass = empty then TopitUp;

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 25th Sep 2012 20:02

If you were a C/C++ programmer, you would stay quite sober.


This gets C/C++ programmers nice and tipsy.

Enjoy Greece!

Cheers,
Ancient Lady
AGK Community Tester
Dar13
16
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 26th Sep 2012 03:45
A good way to avoid that particular error is to put the constant value first in the statement, ie this:
instead of
. That way you get a compiler error if you accidentally use '=' where you should've used '=='.

JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 26th Sep 2012 17:30
Quote: "Enjoy Greece!"


That's a lot easier than programming in any language! No better way to spend my 70th birthday sitting a sunny beach (done), having a fresh tuna salad and ice-cold beer for lunch (done) and having moussaka and a jug of vino for supper (to do).

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
7RS
12
Years of Service
User Offline
Joined: 10th May 2012
Location:
Posted: 26th Sep 2012 21:40
I think the best way and also faster code generated for ARM is



==0 is superfluous, a negation is the best way.
z i l c h vortex
17
Years of Service
User Offline
Joined: 20th Feb 2007
Location: united kingdom
Posted: 4th Oct 2012 17:04
Still not working! Sorry for being a pain guys, can't seem to quite put my finger on the problem. It must be this wav file but i'm not sure I'll include it in the attachment would someone check if it's the right type of file please if it isn't how would i be able to change it to an uncompressed file?

life is short but so am i

Attachments

Login to view attachments
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 4th Oct 2012 18:58
Your sound plays just fine in my Tier 1. It's a half second drum beat and then 4 1/2 seconds of silence?

Here it is, run through Audacity, saved as just the drum beat.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-23 23:59:54
Your offset time is: 2024-11-23 23:59:54