Speaker output

Jan 11, 2011 at 7:59pm
Is there a library for speaker output? I want to generate custom sound without using a .wav file. I'm hoping to (eventually) experiment with sound generation emulating the human voice.
Jan 11, 2011 at 8:53pm
Any audio library worth its salt has an option for streaming audio output. It usually works via a callback mechanism where you give it audio data (in the form of "samples") every so often.

Usually you obtain this audio data from a wav, mp3, or similar file. However if you want to generate your own audio, just feed it audio data you produce.

The data you give it is just normal, uncompressed PCM. Typically 16-bit signed, but there are a number of different formats you can use.
Jan 12, 2011 at 12:31am
Which libraries would you recommend?
Jan 12, 2011 at 3:51am
I depends on what else you'll be doing.

Options off the top of my head are:

- OpenAL
- FMod
- DirectX / DirectSound
- WinAPI's waveOut family
Jan 12, 2011 at 3:52am
Doesn't SFML come with a wrapper for OpenAL?

-Albatross
Jan 12, 2011 at 3:55am
Maybe. Honestly I haven't looked much at SFML's audio streaming capabilities.

It certainly would be the easiest to use of the above mentioned libs.
Jan 12, 2011 at 2:46pm
I'll go with ease of use to start.

http://www.sfml-dev.org/download.php

I'm assuming the Windows - MinGW download will suit my needs.
Jan 12, 2011 at 3:43pm
Yeah but I don't know how to stream your own audio with it. I couldn't immediately tell from the docs.

You might have to ask on those on the SFML forums about it.


EDIT:

This post seems to have a simple example:

http://www.sfml-dev.org/forum/viewtopic.php?t=3929

It looks like you just derive a class from SoundStream and implement the OnGetData function. You provide the audio data through the passed 'chunk' structure.

You then play the SoundStream through a sf::Sound (Sound::SetBuffer, then Sound::Play)
Last edited on Jan 12, 2011 at 4:05pm
Topic archived. No new replies allowed.