love.audio

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

love.audio

Post by rude »

This thread is for discussing features of the next audio interface, most likely an OpenAL-wrapper. I tried OpenAL (soft) for the first time yesterday, it works perfectly, and I really like the API so far. I hooked up SDL_sound, which also worked eerily well with OpenAL. This should give love.audio support for "all" formats. (Bye-bye SDL_mixer.)

Which features of OpenAL would you like to have?

For starters:

Code: Select all

sound = love.audio.newSound("awesome.wav")
music = love.audio.newMusic("awesome.ogg")

sound:setVolume( volume )
sound:setPitch( pitch )

music:setVolume( volume )
music:setPitch( pitch )

love.audio.play(sound, [num])
love.audio.play(music, [num])

love.audio.pause(sound)
love.audio.pause(music)
love.audio.pause() - All audio

love.audio.resume(sound)
love.audio.resume(music)
love.audio.resume() - All audio

love.audio.stop(sound)
love.audio.stop(music)
love.audio.stop() -- All audio

love.audio.setVolume( volume ) -- Master volume
I'm looking in your direction, LaLaLove Team :D.

EDIT: Suggested:

Fadeout:

Code: Select all

love.audio.stop( sound, [seconds] ) 
love.audio.stop( music, [seconds] ) 
Seeking:

Code: Select all

music:setPosition( seconds )
seconds music:getPosition()
-- OR
music:seek( seconds )
seconds = music:tell()
Panning:

Code: Select all

sound:setPanning ( panning )
music:setPanning( panning )
panning = sound:getPanning()
panning = music:getPanning()
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: love.audio

Post by mike »

Haha! Epic! I was visitating my mother today and was thinking that when I got home I was going to make EXACTLY this thread (sans the OpenAL stuff, of course...).

I want this:

Code: Select all

love.audio.stop(music/sound) -- kills instantly
love.audio.stop(music/sound, seconds) -- fades out
love.audio.fadeOut(music/sound, seconds) -- alternative, but not as sparta
Does OpenAL support this?
Now posting IN STEREO (where available)
User avatar
NÖÖB
Prole
Posts: 41
Joined: Thu Jul 31, 2008 10:57 pm
Location: Norway

Re: love.audio

Post by NÖÖB »

Here are my suggestions:
-If at all possible, I'd like to see position seeking in music such as the .MOD and .XM formats. Like: "Play level1.xm pattern 02". The reason for this is that formats like this can contain several tunes in one file,
thus saving some space.

-Some function that returns where the pointer is currently at in the buffer, for synchronizing graphics to music. Probably easiest done on .XM like formats.

Yeah I like modules..
Last edited by NÖÖB on Wed Apr 14, 2010 4:31 pm, edited 1 time in total.
User avatar
cag
Citizen
Posts: 65
Joined: Sun Jun 29, 2008 5:09 am

Re: love.audio

Post by cag »

(On vacation of sorts)

Hell yeah! Love audio!
I highly doubt there's anywhere to go with the audio except crazy 3d sound positioning, and that might be overkill. Simple panning would be nice, though.

EDIT: I like mods too, but I've tried making soundtracks on a single mod before... and it's just better to keep it in separate mods methinks, from personal experience. The sample data isn't really that bad, and you don't have to think about those crazy limitations like 128 patterns or 32 instruments or whatever when you track.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: love.audio

Post by rude »

mike wrote:I want this:Code: Select alllove.audio.stop(music/sound) -- kills instantlylove.audio.stop(music/sound, seconds) -- fades outlove.audio.fadeOut(music/sound, seconds) -- alternative, but not as spartaDoes OpenAL support this?
Not that I know of, but it shouldn't be hard to do (ourselves).
NÖÖB wrote:Here are my suggestions:-If at all possible, I'd like to see position seeking in music such as the .MOD and .XM formats. Like: "Play level1.xm pattern 02". The reason for this is that formats like this can contain several tunes in one file,thus saving some space.-Some function that returns where the pointer is currently at in the buffer, for synchronizing graphics to music. Probably easiest done on .XM like formats.Yeah I like modules..
Hello NÖÖB ^^. Everyone likes modules! The library SDL_mixer uses screws up some modules (I don't know if it's outdated or what), but SDL_sound seems to be rock solid.

About seeking: I just checked if Sound_Seek works on modules; it does, but it uses milliseconds, not patterns. (Only tested for XM).
cag wrote:I highly doubt there's anywhere to go with the audio except crazy 3d sound positioning, and that might be overkill. Simple panning would be nice, though.
We'll have to think about that ... spatial sounds may be awesome.

OpenAL supports tons of stuff, I have no idea what some of it means, but maybe it can inspire you to request a feature.

Code: Select all

/*
 * LISTENER
 * Listener represents the location and orientation of the
 * 'user' in 3D-space.
 *
 * Properties include: -
 *
 * Gain         AL_GAIN         ALfloat
 * Position     AL_POSITION     ALfloat[3]
 * Velocity     AL_VELOCITY     ALfloat[3]
 * Orientation  AL_ORIENTATION  ALfloat[6] (Forward then Up vectors)
*/

/**
 * SOURCE
 * Sources represent individual sound objects in 3D-space.
 * Sources take the PCM data provided in the specified Buffer,
 * apply Source-specific modifications, and then
 * submit them to be mixed according to spatial arrangement etc.
 * 
 * Properties include: -
 *
 * Gain                              AL_GAIN                 ALfloat
 * Min Gain                          AL_MIN_GAIN             ALfloat
 * Max Gain                          AL_MAX_GAIN             ALfloat
 * Position                          AL_POSITION             ALfloat[3]
 * Velocity                          AL_VELOCITY             ALfloat[3]
 * Direction                         AL_DIRECTION            ALfloat[3]
 * Head Relative Mode                AL_SOURCE_RELATIVE      ALint (AL_TRUE or AL_FALSE)
 * Reference Distance                AL_REFERENCE_DISTANCE   ALfloat
 * Max Distance                      AL_MAX_DISTANCE         ALfloat
 * RollOff Factor                    AL_ROLLOFF_FACTOR       ALfloat
 * Inner Angle                       AL_CONE_INNER_ANGLE     ALint or ALfloat
 * Outer Angle                       AL_CONE_OUTER_ANGLE     ALint or ALfloat
 * Cone Outer Gain                   AL_CONE_OUTER_GAIN      ALint or ALfloat
 * Pitch                             AL_PITCH                ALfloat
 * Looping                           AL_LOOPING              ALint (AL_TRUE or AL_FALSE)
 * MS Offset                         AL_MSEC_OFFSET          ALint or ALfloat
 * Byte Offset                       AL_BYTE_OFFSET          ALint or ALfloat
 * Sample Offset                     AL_SAMPLE_OFFSET        ALint or ALfloat
 * Attached Buffer                   AL_BUFFER               ALint
 * State (Query only)                AL_SOURCE_STATE         ALint
 * Buffers Queued (Query only)       AL_BUFFERS_QUEUED       ALint
 * Buffers Processed (Query only)    AL_BUFFERS_PROCESSED    ALint
 */

Also, should LÖVE include ALUT or not? That would give us stuff like:

Code: Select all


#define ALUT_WAVEFORM_SINE                     0x100
#define ALUT_WAVEFORM_SQUARE                   0x101
#define ALUT_WAVEFORM_SAWTOOTH                 0x102
#define ALUT_WAVEFORM_WHITENOISE               0x103
#define ALUT_WAVEFORM_IMPULSE                  0x104

ALUT_API ALvoid *ALUT_APIENTRY alutLoadMemoryWaveform (ALenum waveshape, ALfloat frequency, ALfloat phase, ALfloat duration, ALenum *format, ALsizei *size, ALfloat *freq);
Now I'm really looking in your direction, LaLaLove Devs. :3
User avatar
NÖÖB
Prole
Posts: 41
Joined: Thu Jul 31, 2008 10:57 pm
Location: Norway

Re: love.audio

Post by NÖÖB »

It'd be really cool if we could send data to the buffer, making sounds on the fly.. hm, or maybe not. Anyways, here's an article explaining it: http://www.gamedev.net/reference/articl ... le1348.asp
Also, looks like OpenALSoft's got a lowpass filter and reverb.. those would be nice.
User avatar
hagish
Citizen
Posts: 85
Joined: Thu May 01, 2008 12:51 pm
Contact:

Re: love.audio

Post by hagish »

Pitch would be very good. In lalalove we currently have problem that the limit of playing multiple sounds at the same time is quite low.
We are also not completely sure if handling the sounds as particle is a good way, so it perhaps it would be nice if one could create a sound
out of a buffer (lua table containing numbers).
It just came to my mind that having a callback function modifying the buffer could be interesting too. But probably this would be a bit too low level and slow in lua.
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: love.audio

Post by rude »

Creating sounds real-time in Lua will probably be way too slow ... but it would be fun to give it a try. ^^
hagish wrote:Pitch would be very good. In lalalove we currently have problem that the limit of playing multiple sounds at the same time is quite low.
It is actually fixed at 8 (!) sounds ... I thought it was much higher ...

The next release will not include the new OpenAL-based love.audio, but we could easily include something like this:

Code: Select all

love.audio.setMode( frequency, channels, buffersize )
love.audio.setChannels( num )
If you want it now, I can arrange a minor release with those changes in a few days (if so, let me know). :3
User avatar
hagish
Citizen
Posts: 85
Joined: Thu May 01, 2008 12:51 pm
Contact:

Re: love.audio

Post by hagish »

We are not in a hurry so its not necessary doing extra work to release this change in two days :) . But thanks for your offer.
What is the next planned regular release date?
User avatar
mike
Administrator
Posts: 364
Joined: Mon Feb 04, 2008 5:24 pm

Re: love.audio

Post by mike »

Planned release date? Does any of this looked planned to you? No, we just spew out new versions when we damn well feel like it.
PS: Let rude determine, but we have A LOT to do before 0.4.0 rolls around.
Now posting IN STEREO (where available)
Post Reply

Who is online

Users browsing this forum: No registered users and 89 guests