Sign in to follow this  

Generating raw audio?

This topic is 2548 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[i] = 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;
}
else{
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

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