Skip to main content

OpenAL

Go Search
Home
ALchemy
Beta - Audigy [CLOSED]
Beta - Linux
Beta - Windows
Developer
E-MU
MarCom
OpenAL
Open Source
PR
  
Creative Labs: Connect > OpenAL > OpenAL > Audio streaming using openal  

OpenAL

Modify settings and columns
Note : This discussion forum has been CLOSED.

For questions about developing software using OpenAL please subscribe to the 'OpenAL' mailing list at http://opensource.creative.com/mailman/listinfo/openal

For questions about creating a custom OpenAL library, please subscribe to the 'OpenAL-Devel' mailing list at http://opensource.creative.com/mailman/listinfo/openal-devel
  
View: 
Post
Started: 1/6/2009 8:02 AM
Audio streaming using openal
Hi all, my name is Angelo and i am quite new to OpenAl/audio world. I need some suggestions and help for a task. I have to develop a portable software on a pc side, that mainly have to playback a PCM 16bit samples, 8Khz, LSB(Little endian Intel format) mono samples. The stream contain pure audio vocal samples, no high quality is required. Actually, i am working under windows since this is the main request for the project. The stream is generated from a little 80186 based device that i am writing the firmware for it, planning to send packets of 512/1024 bytes, constant bitrate, 1 packet about every 30 msec. So, mi questions would be: - i am using format = AL_FORMAT_MONO16, does it match the incoming stream ? I think it should. - is the streaming timing interval of 30msec and packet size 512 or 1024 correct for this purpose ? - could anyone suggest me some little sample that show how queue/unqueue the buffers and play them in the correct way ? infinite thanks, Angelo
Posted: 1/6/2009 9:54 AM



From:
Posted: Tuesday, January 06, 2009 8:02 AM
Subject: Audio streaming using openal

Hi all,

my name is Angelo and i am quite new to OpenAl/audio world.
I need some suggestions and help for a task.
I have to develop a portable software on a pc side, that mainly
have to playback a PCM 16bit samples, 8Khz, LSB(Little endian
Intel format) mono samples. The stream contain pure audio
vocal samples, no high quality is required.
Actually, i am working under windows since this is the main
request for the project.

The stream is generated from a little 80186 based device that i
am writing the firmware for it, planning to send packets of
512/1024 bytes, constant bitrate, 1 packet about every 30
msec.

So, mi questions would be:
- i am using format = AL_FORMAT_MONO16, does it match the
incoming stream ? I think it should.
- is the streaming timing interval of 30msec and packet size
512 or 1024 correct for this purpose ?
- could anyone suggest me some little sample that show how
queue/unqueue the buffers and play them in the correct way ?

infinite thanks,
Angelo
Hi, Angelo.
A packet size of 1024 bytes of 16-bit mono data would yield
512 samples. For 8khz, 512 samples is roughly 63ms. This
should be adequate for a send inverval of 30ms, as long as
you don't have much packet loss. A packet size of 512 bytes
would be half that, giving 256 samples, for a length of 31ms,
which would be cutting it close.

I'm not too familiar with the networking side of things, but the
queueing/unqueueing could work like this:

ALint processed;
ALint state;
alGetSourcei(source, AL_SOURCE_STATE, &state);
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
while(alGetError() != AL_NO_ERROR && processed > 0) {
    ALubyte *data;
    ALuint buf;
    int length;

    data = get_packet_data(&length);
    if(!data) break;

    alSourceUnqueueBuffers(source, 1, &buf);
    if(alGetError() == AL_NO_ERROR) {
        alBufferData(buf, AL_FORMAT_MONO16, data, length,
                     8000);
        alSourceQueueBuffers(source, 1, &buf);
    }
    processed--;
}

if(state != AL_PLAYING)
    alSourcePlay(source);

Hope that helps. :)
Posted: 1/7/2009 1:45 AM
Many thanks, i am trying but still have no success, hearing a kind of chainsaw. I forget to say that i am using 2 thread, one producer, that read bytes from the network and store them in the buffers, and one consumer that just do alGetSourcei (source, AL_SOURCE_STATE, &val); if(val != AL_PLAYING) alSourcePlay(source); In your sample, you do everything in the same thread. You think i have advantages using 2 threads or i should reduce allto i thread ?
Posted: 1/7/2009 11:19 PM



From:
Posted: Wednesday, January 07, 2009 1:45 AM
Subject: Audio streaming using openal

Many thanks, i am trying but still have no success, hearing a kind of chainsaw. I forget to say that i am using 2 thread, one producer, that read bytes from the network and store them in the buffers, and one consumer that just do alGetSourcei (source, AL_SOURCE_STATE, &val); if(val != AL_PLAYING) alSourcePlay(source); In your sample, you do everything in the same thread. You think i have advantages using 2 threads or i should reduce allto i thread ?

I don't think you would really gain much by having two seperate
threads, depending on the network requirements. At most I
think you could have one thread for reading from the network
and fill into a memory buffer, then have the main thread read
off from that buffer in discrete chunks (always reading the
same amount to help prevent oddities) into OpenAL buffers
that are queued onto the source.
Posted: 3/18/2009 8:03 AM



From:
Posted: Tuesday, January 06, 2009 8:02 AM
Subject: Audio streaming using openal

Hi all, my name is Angelo and i am quite new to OpenAl/audio world. I need some suggestions and help for a task. I have to develop a portable software on a pc side, that mainly have to playback a PCM 16bit samples, 8Khz, LSB(Little endian Intel format) mono samples. The stream contain pure audio vocal samples, no high quality is required. Actually, i am working under windows since this is the main request for the project. The stream is generated from a little 80186 based device that i am writing the firmware for it, planning to send packets of 512/1024 bytes, constant bitrate, 1 packet about every 30 msec. So, mi questions would be: - i am using format = AL_FORMAT_MONO16, does it match the incoming stream ? I think it should. - is the streaming timing interval of 30msec and packet size 512 or 1024 correct for this purpose ? - could anyone suggest me some little sample that show how queue/unqueue the buffers and play them in the correct way ? infinite thanks, Angelo