One sound to rule them all. One sound to bind them... and in the program.... mess it all up.

View: New views
3 Messages — Rating Filter:   Alert me  

One sound to rule them all. One sound to bind them... and in the program.... mess it all up.

by Maverix :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

First of all, OpenAL is awesome, needs to be supported more, and I just love it.
Now to my topic:

I have this sound named "laser.wav" and I have a class called Cube. In cube's initialization, I load the sound "laser.wav" only for that particular cube. There's 40 cubes, and so "laser.wav" is loaded 40 times into 40 different buffers. However, when I play one cube's laser sound, another cube's laser sound won't play until the first one was finished.

Any help?

Re: One sound to rule them all. One sound to bind them... and in the program.... mess it all up.

by aconstantin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I suspect that the reason the other ones won't play is that you cue all the buffers onto the same source ?

If you want the sounds to overlap, you should have multiple sources.

Alex.

Maverix wrote:
First of all, OpenAL is awesome, needs to be supported more, and I just love it.
Now to my topic:

I have this sound named "laser.wav" and I have a class called Cube. In cube's initialization, I load the sound "laser.wav" only for that particular cube. There's 40 cubes, and so "laser.wav" is loaded 40 times into 40 different buffers. However, when I play one cube's laser sound, another cube's laser sound won't play until the first one was finished.

Any help?
---using---
- VC# 2005
- Tao Framework 2.1.0

Re: One sound to rule them all. One sound to bind them... and in the program.... mess it all up.

by Maverix :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, that's the thing. I do. Here's a snippet of my code:


                if( gns_t )delete gns_t; // the object with the sound data specifics in it

                gns_t = 0;
                gns_t = new GLENNSOUND( file_name, type );

                alutLoadWAVFile( (ALbyte*)gns_t->GetFileName(),  //laser.wav
                        &GLENN::GetApp()->m_Format,
                        &GLENN::GetApp()->m_Data,
                        &GLENN::GetApp()->m_Size,
                        &GLENN::GetApp()->m_Freq,
                        &GLENN::GetApp()->m_ALBool);

//When it's created, it's assigned a certain ID. NUMBUFFS = 40.
                alBufferData(GLENN::GetApp()->buffer[ NUMBUFFS-( gns_t->GetCreatedID() ) ],
                        GLENN::GetApp()->m_Format,
                        GLENN::GetApp()->m_Data,
                        GLENN::GetApp()->m_Size,
                        GLENN::GetApp()->m_Freq);


                alutUnloadWAV(GLENN::GetApp()->m_Format,
                GLENN::GetApp()->m_Data,
                GLENN::GetApp()->m_Size,
                GLENN::GetApp()->m_Freq);

                ALfloat spos[] = {0,0,0};
                ALfloat svel[] = {0,0,0};

//NUMSOURCE = 40 as well. So the new sounds will be placed in there own sources AND buffers
 
                alSourcef(GLENN::GetApp()->source[ NUMSOURCE-( gns_t->GetCreatedID() ) ],AL_PITCH,1.0f);
                alSourcef(GLENN::GetApp()->source[ NUMSOURCE-( gns_t->GetCreatedID() )  ],AL_GAIN,1.0f);
                alSourcefv(GLENN::GetApp()->source[ NUMSOURCE-( gns_t->GetCreatedID() )  ],AL_POSITION, spos);
                alSourcefv(GLENN::GetApp()->source[ NUMSOURCE-( gns_t->GetCreatedID() )  ],AL_VELOCITY, svel);
                alSourcei(GLENN::GetApp()->source[ NUMSOURCE-( gns_t->GetCreatedID() )  ],AL_BUFFER, GLENN::GetApp()->buffer[ NUMBUFFS-( gns_t->GetCreatedID() ) ] );
                alSourcei(GLENN::GetApp()->source[ NUMSOURCE-( gns_t->GetCreatedID() )  ],AL_LOOPING, AL_FALSE);

                // Give this sound object a called back ID ( sources[ x ] ) to play from
                gns_t->SetID(GLENN::GetApp()->source[ NUMSOURCE-( gns_t->GetCreatedID() )  ] );


So as you can see, I'm not sure if I've done anything wrong.