Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
156 user(s) are online (111 user(s) are browsing Forums)

Members: 2
Guests: 154

jarokuczi, orgin, more...

Headlines

 
  Register To Post  

SDL_Mixer and OpenAL sound bug problems.
Home away from home
Home away from home


See User information
For a while i noticed some strange bug, which happenes when i try to port soething SDL + SDL_Mixer related. For example, that piece of code:

Quote:

int audio_rate = 44100;
Uint16 audio_format = AUDIO_S16;
int audio_channels = 2;
int audio_buffers = 4096;


In the game give me noise and annoing sound. And over that noise i can sometime heard original (but noised too) sounds and music.

If i change AUDIO_S16 on AUDIO_S8 : everything works fine. Sound ok, and all is ok. So the question: why it happenes , and where is problem, and because of what is happenes: because of bad SDL, or because of bad SDL_Mixer or because of other ported libs ?

And the second question, its about sound in OpenAL. Today i tryed to port some nasty RPG game, and that game have that piece of code:

Quote:

vorbisInfo = ov_info(&oggStream, -1);
vorbisComment = ov_comment(&oggStream, -1);

if(vorbisInfo->channels == 1)
{
format = AL_FORMAT_MONO16;
}
else
{
format = AL_FORMAT_STEREO16;
}

loopInterval = -1;


And, after compiling, i have the same Noise sound as sometime happenes with the plain SDL_Mixer. I tryed to change it on all possible 4 sound openal formats, but still, noise always here (sometime big, sometime not).

Have someone any idea why it happenes, and maybe its because of old SDL_Mixer or old Vorbis or kind ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: SDL_Mixer and OpenAL sound bug problems.
Quite a regular
Quite a regular


See User information
@kas1e

AUDIO_S16MSB

Go to top
Re: SDL_Mixer and OpenAL sound bug problems.
Home away from home
Home away from home


See User information
@MickJT

For openal ? For SDL_Mixer i already can fix it (still, strange why it not works as original ?)

But for OpenAL (imho) i can choise only beetween 4 openal formats. Or AUDIO_S16MSB for openal will be ok too ?

edit: tryed to put to openal that AUDIO_S16MSB, and it does not works, have:
Quote:

OpenAL error was raised: 40962
Invalid parameter at ::stream() alBufferData


The question still open: why OpenAL have noise crap, and how to fix it ? Maybe i need some new version of SDL_Mixer or what ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: SDL_Mixer and OpenAL sound bug problems.
Quite a regular
Quite a regular


See User information
@kas1e

Hmm OK. Have a chat to IamSONIC, he might be able to help you out.

I might see about compiling a new SDL_mixer too... but I want to compile a clib2 version of SDL myself, so I can get a clib2 SDL_image, ttf, mixer, etc and stick them on OS4Depot.

Edit: I'm doing a clib2 compile of SDL now, then i'll compile SDL_image, and if i'm able to, SDL_mixer for both newlib and clib2. They'll be static libs (but that's all they ever were on OS4Depot)... Someone else can do shared libs :)

Go to top
Re: SDL_Mixer and OpenAL sound bug problems.
Home away from home
Home away from home


See User information
@MickJT

I found in the network very little example, which just play over OpenALL ogg file in command line. There is a source:

#include <AL/al.h>
#include <AL/alut.h>
#include <vorbis/vorbisfile.h>
#include <cstdio>
#include <iostream>
#include <vector>


#define BUFFER_SIZE     32768       // 32 KB buffers


using namespace std;


// This function loads a .ogg file into a memory buffer and returns
// the format and frequency.
void LoadOGG(char *fileNamevector<char> &bufferALenum &formatALsizei &freq)
    {
    
int endian 0;                         // 0 for Little-Endian, 1 for Big-Endian
    
int bitStream;
    
long bytes;
    
char array[BUFFER_SIZE];                // Local fixed size array
    
FILE *f;

    
// Open for binary reading
    
fopen(fileName"rb");

    if (
== NULL)
        {
        
cerr << "Cannot open " << fileName << " for reading..." << endl;
        exit(-
1);
        }
    
// end if

    
vorbis_info *pInfo;
    
OggVorbis_File oggFile;

    
// Try opening the given file
    
if (ov_open(f, &oggFileNULL0) != 0)
        {
        
cerr << "Error opening " << fileName << " for decoding..." << endl;
        exit(-
1);
        }
    
// end if

    // Get some information about the OGG file
    
pInfo ov_info(&oggFile, -1);

    
// Check the number of channels... always use 16-bit samples
    
if (pInfo->channels == 1)
        
format AL_FORMAT_MONO16;
    else
        
format AL_FORMAT_STEREO16;
    
// end if

    // The frequency of the sampling rate
    
freq pInfo->rate;

    
// Keep reading until all is read
    
do
        {
        
// Read up to a buffer's worth of decoded sound data
        
bytes ov_read(&oggFile, array, BUFFER_SIZEendian21, &bitStream);

        if (
bytes 0)
            {
            
ov_clear(&oggFile);
            
cerr << "Error decoding " << fileName << "..." << endl;
            exit(-
1);
            }
        
// end if

        // Append to end of buffer
        
buffer.insert(buffer.end(), array, array + bytes);
        }
    while (
bytes 0);

    
// Clean up!
    
ov_clear(&oggFile);
    }
// end of LoadOGG


int main(int argcchar *argv[])
    {
    
ALint state;                            // The state of the sound source
    
ALuint bufferID;                        // The OpenAL sound buffer ID
    
ALuint sourceID;                        // The OpenAL sound source
    
ALenum format;                          // The sound data format
    
ALsizei freq;                           // The frequency of the sound data
    
vector<charbufferData;                // The sound buffer data from file

    // Make sure there is a file name
    
if (argc 2)
        {
        
cerr << "Syntax: " << argv[0] << " OGGFile" << endl;
        return -
1;
        }
    
// end if

    // Initialize the OpenAL library
    
alutInit(&argcargv);

    
// Create sound buffer and source
    
alGenBuffers(1, &bufferID);
    
alGenSources(1, &sourceID);

    
// Set the source and listener to the same location
    
alListener3f(AL_POSITION0.0f0.0f0.0f);
    
alSource3f(sourceIDAL_POSITION0.0f0.0f0.0f);

    
// Load the OGG file into memory
    
LoadOGG(argv[1], bufferDataformatfreq);

    
// Upload sound data to buffer
    
alBufferData(bufferIDformat, &bufferData[0], static_cast<ALsizei>(bufferData.size()), freq);

    
// Attach sound buffer to source
    
alSourcei(sourceIDAL_BUFFERbufferID);

    
// Finally, play the sound!!!
    
alSourcePlay(sourceID);

    
// This is a busy wait loop but should be good enough for example purpose
    
do
        {
        
// Query the state of the souce
        
alGetSourcei(sourceIDAL_SOURCE_STATE, &state);
        }
    while (
state != AL_STOPPED);

    
// Clean up sound buffer and source
    
alDeleteBuffers(1, &bufferID);
    
alDeleteSources(1, &sourceID);

    
// Clean up the OpenAL library
    
alutExit();

    return 
0;
    }
// end of main


My compiling line for it:

Quote:

gcc SimpleOGG.cpp -lSDL_Mixer -lvorbisfile -lvorbis -logg -lSDLmain -lopenal -lalut -lpthread -lstdc++ -o SimpleOGG


Then, just do in shell:
Quote:

AmigaShell:> SimpleOGG file.ogg


And you will heard that annoing noise (well, i have). Try it please with all your latest ported libs. Will it the same noise, or will it ok. If will be noise, then, we need to check out OpenAL. If not, then some of my libs outdated or compiling line are wrong ..

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: SDL_Mixer and OpenAL sound bug problems.
Home away from home
Home away from home


See User information
@kas1e

Blender uses OpenAl for the game engine and as far as I know it works fine.

I don't have time to compare the code at the moment though.

BTW I don't think openal depends on SDL? Why do you need SDLMain in your linklibs?

Go to top
Re: SDL_Mixer and OpenAL sound bug problems.
Home away from home
Home away from home


See User information
@broadblues

Because many times coders use Vorbis + OpenAL. For us (aos4 users) Vorbis mean also SDL and all other stuff (as far as i understand for now) ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: SDL_Mixer and OpenAL sound bug problems.
Amigans Defender
Amigans Defender


See User information
@broadblues

i think is the SDL_mixer lib that needs SDL

i'm really tired...
Go to top
Re: SDL_Mixer and OpenAL sound bug problems.
Home away from home
Home away from home


See User information
@afxgroup
Yep, you are right. Vorbis for us mean SDL_Mixer, which mean SDL, etc.

@all
I found where is bug, it was in the ov_read() fucntion , which also want to know Endian. So for now all works fine, and problem was because of endianes, not because of Libs.

If someone in interest, all of this was because of porting of nice opensource RPG game called DccNiTghtmare. With help of author we changed sources a bit, for make all of this works on aos4 (and now it works for me in window mode also, thanks to new features of SDL, if someone in interest can upload screenshot somethere), but the main problems which avoid me to release it right now: madness slow framerate. With everything related to video in FALSE , with only 640x480 in window mode (but on 32bit WB), without music, it give only 4 fps _maximum_ on my peg2 / 1ghz with radeon9250.

As author say, radeon9250 pretty slow for such thinks, but, it of course possible to optimize it, but he do not have radeon9250, and he do not know what can cause such bottleneck. If some one can help me , to speed up that game (for example to make it at least working on 15-20 fps), then it will be pretty nice, because game pretty modern and interesing (you can check vids on site of game).

I also tested win32 version of that game on my win32 (dual core pentium 1.8 with some nvidia gfx card which was modern 2 years ago), and even on that computer it give me 30fps only (1024x768)

All in all, next release will be with aos4 support, even if it madness slow. Its just a start, and maybe later i will speedup it, and new hardware on horizont too )

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: SDL_Mixer and OpenAL sound bug problems.
Just can't stay away
Just can't stay away


See User information
@kas1e

To get the correct value for the endian variable you could use some simple code like this:

Quote:

uint16_t tmp = 0x0100;
int endian = *(uint8_t *)&tmp;


This will set the variable endian to 1 for a bigendian CPU and 0 for littleendian CPU.

Go to top
Re: SDL_Mixer and OpenAL sound bug problems.
Home away from home
Home away from home


See User information
@salass00

Yep, thanks. But all in all, now i know that when you use OpenAL + ogg/vorbis combo, then, need watch for endianes.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project