Game Development Community

Audio is a loud static noise

by Ricky Hopper · in iTorque 2D · 01/18/2010 (1:35 am) · 13 replies

I'm trying to implement audio in my game, and following the tutorials in the documentation. However, all I'm getting is a loud static noise. My audio files are all wav files, and I don't know what's going on. Here's some of the code I'm using (from my audio.cs file):

new AudioDescription(BGM)
{
	volume = 1.0;
	isLooping= true;
	is3D = false;
	type = $GuiAudioType;
};

new AudioProfile(levelBG) {
	filename = "~/data/audio/lvlBG.wav";
	description = "BGM";
	preload = true;
};

new AudioProfile(menuBG) {
	filename = "~/data/audio/menuBG.wav";
	description = "BGM";
	preload = true;
};

function playBGM(%sound, %volume)
{
	alxSetChannelVolume($GuiAudioType, %volume);
	
	if ($bgm) {
		alxStop($bgm);
	}
	
	switch$ (%sound) {
		case "menuBG":
			$bgm = alxPlay(menuBG);
			
		case "lvlBG":
			$bgm = alxPlay(levelBG);
	}
}

and how I call it in my game (mainMenu.cs):

function menuGraph::onLevelLoaded(%this)
{
	//other menu loading code

	playBGM("menuBG", 1.0);
}

Anyone see any glaring problems in my code? Any help is appreciated.

#1
01/18/2010 (6:36 am)
$GuiAudioType : does this exist?

And is it setup correctly?

Also, i have never used that function - i simply call alxPlay() on a audioprofile.
#2
01/18/2010 (9:34 am)
...Apparently it does not. However, I just looked at common/gameScripts/audio.cs and found some audio descriptions that were already there and used those instead, removing any calls to $GuiAudioType, and I still get the static noise.

How would I go about defining $GuiAudioType, were I to use it?
#3
01/18/2010 (11:00 am)
$GuiAudioType you can just do $GuiAudioType = 1; before you make your audio description. The type allows you to control the volume of all audio Descriptions with the same type.

I am also having issues with the sound on my computer. But on my iPhone it sounds fine. Is it the same for you Rick?
#4
01/18/2010 (3:49 pm)
Actually, yes, that's the same thing that's happening with me now. Music works fine on the device, does static on the computer.
#5
05/04/2010 (4:33 am)
Same for me...

Since iTGB 1.3. I have this static sound in ALL my iTGB projects (Behaviour Shooter, old projects that worked fine in iTGB 1.2 on the same machine, new projects, etc...).

All the other applications (iTunes, Audacity, VLC etc.) play these sound files correctly.

#6
05/04/2010 (6:01 am)
I am getting the same thing. HOW do you we go about fixing this?!!!!


#7
05/04/2010 (1:52 pm)
I believe this is a bug on the Mac, I remember seeing a post about it a couple of months ago but I can't find it now.

I have the same problem on the Mac, but the PC version works ok. I work around this by doing most of my development on the PC, and then I copy my files over to the Mac and test it on the device periodically. It's a bit of a pain, but I also like to use Torsion, which makes development so much easier, and that is only available on the PC (no Mac version). So I would probably do most of my development on the PC anyway.
#8
05/04/2010 (2:01 pm)
What I did for this was just accepted that sound was screwed up on the computer. For audio testing, I deployed to the device, where it worked fine.
#9
05/04/2010 (7:32 pm)
So are you suggesting tho distorted on my mac, that it would work fine on the iPhone?


#10
05/04/2010 (10:58 pm)
Yes, it should work ok on the iPhone simulator and on the actual device. I was concerned about this in the beginning also, as I thought it was just me, but it is actually a known bug and you'll just have to work around it.
#11
05/05/2010 (1:39 am)
:(
#12
05/05/2010 (8:56 pm)
oh well its actually a huuuuge relief. I thought I was going to have to delay the release of my app until they fixed the bug.


thank god.
#13
10/15/2010 (11:19 pm)
try this solution:
http://www.torquepowered.com/community/forums/viewthread/121593