Jump to content
  • Advertisement
Sign in to follow this  

Generating raw audio?

This topic is 2856 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

I'm trying to load a raw audio sample but I haven't found any examples online.

Here is SDL_Mixer, but I get no sound.

int GenRaw(){
Uint8* lraw;
Uint32 len = 88000;
lraw = new Uint8[len];
for (int i = 0; i < len; ++i){
lraw = RandInt(0, 255);

mGenRaw = Mix_QuickLoad_RAW(lraw, len );

if( mGenRaw==NULL ){
std::cout << "GenRaw() ERROR: Mix_GetError():"
<< Mix_GetError() << std::endl;
delete[] lraw;
return -1;
else {
delete[] lraw;
return 0;

void PlayLoop(){
int channel;
channel = Mix_PlayChannel( -1, mGenRaw, -1 );
if( channel != 0 ){
std::cout << "PlayLoop() ERROR: Unable to play Mix_GetError(): "
<< Mix_GetError() << std::endl;

My load wave file function works and plays fine though mSound
int LoadWave(const std::string& awavfile){
mSound = NULL;

mSound = Mix_LoadWAV( awavfile.c_str() );

if( mSound==NULL ){
std::cout << "Unable to load WAV file: "
<< awavfile << std::endl << std::endl;
return -1;
return 0;

The sound specification is
static const int mAudioRate = 22050;
static const Uint16 mAudioFormat = AUDIO_S16SYS;
static const int mAudioChannels = 2;
static const int mAudioBuffers = 4096;
Mix_Chunk* mSound;
Mix_Chunk* mGenRaw;

No errors are detected by the above code. I have checked the address of mGenRaw and it is NULL before the load, and has a normal looking 0034B68 type address. Dunno :o

[Edited by - PrestoChung on December 24, 2010 4:37:34 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!