Sign in to follow this  

SDL_mixer, corrent wav format??

This topic is 3338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, im using SDL_mixer to load up simple wav files, but i have a problem. I set it all up and it played all my sounds that i got straight off the internet. So i know it works, however i got my friend to make some better sounds in pro-tools, they were all wav files, i tried to load them the exact same way as i did the previous files and it just doesn't work :,(! my first guess was silly typos so i checked all them out, all the file names match up so theres no problem there. The second option i explored was format, so i downloaded dppoweramp, to convert the wavs into another type of wav, i checked the format of my sounds that worked: stereo 16 bit 44.1KHZ uncompressed (which is all apparently standard CD format) and i converted my new wav files to the same format and they still don't work! my old ones still work, so nothing makes logical sense, even when i just rename my old ones and new ones to switch them round the old ones work, the new ones dont, they are what seem to be the same format, same method of loading them up, is there anything that i could have missed? here is the code i am using to play my files, it isnt actually my code it is a piece of code written by my university that i have to use (but im sure i can get away with tweaking it a little)
AudioManager::AudioManager()
{
	// Initialise Mixer
	Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 256);

	// Get some channels
	Mix_AllocateChannels(35);
	Mix_GroupChannels(0, 34 , 1);
}

AudioManager::~AudioManager()
{
	// Free mixer resources
	Mix_HaltGroup(1);

	for(CMAPIT it = soundmap.begin() ; it != soundmap.end() ; ++it)
		Mix_FreeChunk(it->second);

	Mix_CloseAudio();
}

bool AudioManager::addSound(char* filename, string name)
{
	CMAPIT it = soundmap.find(name);;
	Mix_Chunk* chunk = NULL;

	// See if 'name' already exists
	if(it != soundmap.end()) {return false;std::cout<<"\nfailure to load sound: "<< filename<<std::endl;}
		
	// Attempt to load wav file
	chunk = Mix_LoadWAV(filename);
	if (chunk == NULL) return false;

	Mix_VolumeChunk(chunk, MIX_MAX_VOLUME);
	soundmap[name] = chunk;

	
	return true;
}

void AudioManager::playSound(string name)
{
	CMAPIT it = soundmap.find(name);
	if(it != soundmap.end())
		Mix_PlayChannel(-1, it->second, 0);
}
void AudioManager::playSound(string name, int repeats)
{
	CMAPIT it = soundmap.find(name);
	if(it != soundmap.end())
		Mix_PlayChannel(-1, it->second, repeats);
}
void AudioManager::stopSound(string name)
{
	CMAPIT it = soundmap.find(name);
	if(it != soundmap.end())
		Mix_HaltChannel(-1);
}





if i break point it at // Attempt to load wav file chunk = Mix_LoadWAV(filename) chunk ends up being a bad pointer every time i use one of the new files! Has anyone come across this before or have a tip or trick for me? Thanks, Chris

Share this post


Link to post
Share on other sites

This topic is 3338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this