GLBasic forum

Main forum => GLBasic - en => Topic started by: djtoon on 2011-Nov-14

Title: 3d audio
Post by: djtoon on 2011-Nov-14
hi im trying to make a 3d audio game where the player needs to hear a direction of a sound
it seems to pan and volume arent that specific any one have ideas?
Title: Re: 3d audio
Post by: mentalthink on 2011-Nov-14
HI Djtoon, what you want to do it´s something like this

http://www.youtube.com/watch?v=IUDTlvagjJA

I think in the description, explains or links to some web on tell how do it, I rebember it´s make something like play the same sound trhu the 2 ears but whit different phases (previous retouch in every sound).

Close your eyes, and listen the audio, it´s absolutelly brutal, very impressive!!!.

Title: Re: 3d audio
Post by: Zapp on 2011-Nov-17
I have a similar question, was wondering if it is possible to speed up the currently playing music? Think of Streetfighter when you are low on health the music slightly increases in tempo the closer one player is to being knocked out.
Title: Re: 3d audio
Post by: Kitty Hello on 2011-Nov-17
load another music file.
Title: Re: 3d audio
Post by: erico on 2011-Nov-17
You guys remember chaos engine on the amiga?

So, Master Joseph would have some 2 or 3 music loops per stage.
Music would shift to another loop depending on the part of the stage. Shadow of the beat 3 did similar thing.

I 'would like' to do the same. But I would need to start the new loop perfectly at the end of the last loop, is this possible?

I understand in streetfighter, the second music loop just gets over the first, no matter when, so it must be easier this way.
Any extra thoughts?
Title: Re: 3d audio
Post by: Slydog on 2011-Nov-17
We can't have two music sources playing at once, correct? (via 'PLAYMUSIC')
The following may work if you played your music using regular sound effects. (via 'PLAYSOUND')

You could start both music / sound loops at the same time.
The one you want heard currently, set the volume to full, the other to mute.
When you want the music loop to switch (ie: time running out), over say 1/4 of a second, fade the playing song to mute while ramping of the muted song.

Seems like a waste of resources though!

[Edit] Never mind, you can't change the volume of a currently playing sound effect, only the current music via the MUSICVOLUME() command.  So you would either need the ability to play two music loops at once (and be able to dynamically change each volume independently), or change the volume of a sound effect dynamically.
Title: Re: 3d audio
Post by: Zapp on 2011-Nov-17
Yeah, I just want the ability to be able increase the speed at which the current track is played once the timer runs out, I could just have a musical track that speeds up slowly pre-recorded, but what I want is for the player to be able to do particular actions to increase their time limit, so the time of the level is dynamic.

Doesn't seem to be a current way to do this in GLB though, so i might scrap that idea until more sound support is added.
Title: Re: 3d audio
Post by: erico on 2011-Nov-17
There is always a way to do something, not that I know about what you need enough to recommend something... ;)

On some other thread, a friend was adding support to a music/sound lib or something like that.
If your case target is not mobiles, you can check that.

I guess, but am not sure, I could start a new music loop just at the end of last loop, knowing their durations and so on.
Another thing, if this dosen´t work, is to insert a drums roll between one music and another, or something like that, to mix them up.

I´m still a couple weeks to start music part on my game, I will be able to help more when that time comes. :good:
Title: Re: 3d audio
Post by: MrTAToad on 2011-Nov-18
If the program is just for Windows, then you could always use BASS/FMOD...
Title: Re: 3d audio
Post by: fuzzy70 on 2011-Nov-18
While tempo shifting is possible with samples it's not very efficient if more than one are playing, as in a song. The best & most common way is using either midi or mods as they can speed up or slow down when ever you want them to.

While mods where the main source back in the Amiga days they do exist on the pc & like MrTAToad said BASS/FMOD can play them back & thats what I used in Blitz. Midi is limited to the playback of sounds thats on the device unless you find a player that supports soundfonts so you can change the sounds to your own, I think BASS/FMOD does but not 100% sure on that.

How you interface them with GLB & what devices are supported sadly I have no idea as not got into sound/music yet in GLB.

Lee
Title: Re: 3d audio
Post by: erico on 2011-Nov-18
hey mentalthink! the barbershop kicks!
I have it here as a wav full quality, did not see your recommended video up there.

It really rocks on headphone, some people can´t stand it hehe, wonderful to see people reaction on that...
Title: Re: 3d audio
Post by: Zapp on 2011-Nov-18
Well I'm building for Iphone, so perhaps that limits what i can do with the tempo changing music for the time being. I'm not experienced enough to delve into anything outside of GLB yet.
Title: Re: 3d audio
Post by: fuzzy70 on 2011-Nov-18
Sadly sound is one of those things that seems to get little attention in programming languages, they seem to think that just playing a wave file or midi file is good enough, hence why things like FMOD etc exist.

I think GLB's problem is mainly down to the fact it supports so many different platforms that sound is a lot more complex to integrate & work on all of them compared to the graphics side of things. Only thing that springs to mind is OPENAL, but again I have no idea what platforms that targets & if it covers the range GLB does.

Macs use AIFF & pc's WAV etc etc, basically audio is a pain in the arse  :O

Lee
Title: Re: 3d audio
Post by: Hatonastick on 2011-Nov-18
http://connect.creativelabs.com/openal/OpenAL%20Wiki/Platforms.aspx (http://connect.creativelabs.com/openal/OpenAL%20Wiki/Platforms.aspx)

Nowhere near enough unfortunately.  I love GLB, but its sound system could do with a few more options.  Problem is it's limited to whatever the SDL sound libraries (is SDL_MIXER being used?) do.  At least I think that is what Kitty is using.
Title: Re: 3d audio
Post by: fuzzy70 on 2011-Nov-18
Well if SDL_MIXER is being used then panning, distance etc is in SDL

http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_frame.html (http://www.libsdl.org/projects/SDL_mixer/docs/SDL_mixer_frame.html)

Quote4.6 Effects

These functions are for special effects processing. Not all effects are all that special. All effects are post processing routines that are either built-in to SDL_mixer or created by you. Effects can be applied to individual channels, or to the final mixed stream which contains all the channels including music.

Registration 4.6.1 Mix_RegisterEffect        Hook a processor to a channel
4.6.2 Mix_UnregisterEffect        Unhook a processor from a channel
4.6.3 Mix_UnregisterAllEffects        Unhook all processors from a channel
4.6.4 Mix_SetPostMix        Hook in a postmix processor

Built-in Processors 4.6.5 Mix_SetPanning        Stereo panning
4.6.6 Mix_SetDistance        Distance attenuation (volume)
4.6.7 Mix_SetPosition        Panning(angular) and distance
4.6.8 Mix_SetReverseStereo        Swap stereo left and right


The built-in processors: Mix_SetPanning, Mix_SetPosition, Mix_SetDistance, and
Mix_SetReverseStereo, all look for an environment variable, MIX_EFFECTSMAXSPEED to be defined. If the environment variable is defined these processors may use more memory or reduce the quality of the effects, all for better speed.
Title: Re: 3d audio
Post by: Hatonastick on 2011-Nov-18
Heh I should have checked.  Well, that answers my question then. :)
Title: Re: 3d audio
Post by: Zapp on 2011-Nov-18
Poor Kitty, getting hammered with support requests from us, well at least our money is being put to good use hehe.
Title: Re: 3d audio
Post by: fuzzy70 on 2011-Nov-18
I'd rather develop & support a game then a complete programming environment  :D

Kitty  :good:  :booze:


Lee
Title: Re: 3d audio
Post by: Wampus on 2011-Nov-18
Has anyone had the time and inclination to try using SDL_mixer in GLBasic yet? After checking I see that it should support Android, iOS and WebOS as well as many other platforms. That is encouraging. Wow, I'm an idiot. I realise now GLBasic already uses SDL for many platforms.



Note: The SunVox tracker (http://www.glbasic.com/forum/index.php?topic=6910.0) works for desktops, iOS and WebOS. Not Android yet.