Post new topic    
Liquid Metal Slime
Send private message
A question about Music/SFX polyphony... and music questions 
 PostTue Oct 08, 2013 7:35 am
Send private message Reply with quote
I have what might be a strange question. I would like to know the amount of polyphony that can be present in a game at any given time. Or in other words the amount of SFX that can be playing simultaneously.

The main reason for this is because I have created a simple sample player game that plays a sound effect every time you click a key on the keyboard. When I play many keys at once I can hear the SFX layer together to form more complex sounds. I notice I can layer quite a few sounds at once but after so many SFX are present some new sounds fail to play until other SFX have ended. It is hard for me to recognize exactly how many sounds are playing simultaneously before the polyphony reaches it's limit.

Could anyone let me know the polyphony? It would help me to determine my limitations for what I have in mind for a SFX related game idea.

Another thing I would like to ask is, is there any plot scripting functions that would allow me to alter the pitch, volume (I see volume can be altered for music but don't see anything regarding independent SFX volume management), and other attributes of SFX? Pitch would be especially useful since it would allow me create a whole virtual synthesizer program with only a few SFX used as basic waveforms!

If this type of feature does not already exist, is there any possible way around this? Or is there any chance something like this could be seen in future releases?
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Metal King Slime
Send private message
 
 PostTue Oct 08, 2013 1:36 pm
Send private message Reply with quote
It depends on the audio backend.

music_sdl (which is the default on all operating systems) has a limit of 8 sounds playing at once. However this limit is completely arbitrary and is trivial to increase (the limit it not due to the SDL_mixer library that music_sdl uses). I can do that if you want. There's no good reason for that limit, although SDL_mixer is really inefficient with memory.

music_native and music_native2 have no limit, and they are also much more efficient.

Also, you can only play one copy of each sound at a time (though you can get around this limit by importing it multiple times), which is a limit I'd like to remove, adding an extra argument to "play sound".

Modifying the volume of sound effects is an obvious and high priority feature. I don't know when we'll get to it (likely not in the next release but I hope the one after that), but it shouldn't be too much work.

Modifying pitch, panning, and even reverb and 3D position are features which I would like to add, however they can't be added until we stop using the SDL_mixer library/music_sdl backend which can't support these. Currently we're stuck with music_sdl because it's the only backend which plays MIDI properly, and even it crashes a lot when playing MIDI files (by far the worst engine bug...). I'm really keen to ditch SDL_mixer, but I think it'll be a lot of work.

One possibility would be to add advanced sound functions which are only available to games using music_native or music_native2 and which don't use any MIDI or BAM music. That would be easy to implement; less work than adding volume control.

You mentioned music in the title of the thread but didn't ask any questions. SDL_mixer doesn't support playing more than one piece of music at once, but any decent audio library does; I would like to support music cross-fading in future. We don't even have music fading at the moment!
Liquid Metal Slime
Send private message
 
 PostTue Oct 08, 2013 9:02 pm
Send private message Reply with quote
Thanks, I think that answers everything I wanted to know. I'm not sure why I put "music" in the title now that I think about it. All those features would be great to have. No matter though, I'll do with what limitations I have right now.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Metal Slime
Send private message
 
 PostTue Oct 22, 2013 12:38 am
Send private message Reply with quote
TMC wrote:

One possibility would be to add advanced sound functions which are only available to games using music_native or music_native2 and which don't use any MIDI or BAM music. That would be easy to implement; less work than adding volume control.

You mentioned music in the title of the thread but didn't ask any questions. SDL_mixer doesn't support playing more than one piece of music at once, but any decent audio library does; I would like to support music cross-fading in future. We don't even have music fading at the moment!


So how easy would it be to get to play multiple songs at once? I don't mind using a different backend... I also don't need MIDI/BAM...

Could I "fake" implement this using really long sound effects right now?
Metal King Slime
Send private message
 
 PostTue Oct 22, 2013 7:34 pm
Send private message Reply with quote
Multiple songs playing at once would require cleaning up the interface between the engine and the music backend, which has multiple unnecessary indirection layers that do nothing; extending the interface; implementing it in music_native/native2 (requiring modifying the audwrap wrapper too); exposing the functionality to script commands. Really in total it would be quite a bit of work.

I don't know what the new script/music backend interface would look like. An optional argument to playsong to not halt existing music, and arguments to [set]musicvolume and stopsong to specify the song number to operate on, I suppose.

There is a 500KB limit on the size of .ogg files used as sound effects. It's a bit of a silly limit, but we added it because SDL_mixer decodes .ogg (and .mp3) sound effects in memory before starting to play them; on slow machines and long songs (multiple minutes) this can cause the engine to freeze for several seconds. But if you're not using SDL_mixer anyway, I don't feel bad in telling you that this limit is enforced only in the file browser when import sound effects, so is easy to work around or disable.
Liquid Metal Slime
Send private message
 
 PostThu Oct 24, 2013 12:49 am
Send private message Reply with quote
This one's a long-shot, but I'm wondering if there could ever be a way to connect a game to Pandora or some sort of Internet radio provider similar to what Beat Hazard does. Ever since James figured out how to hack a dictionary and import the entire English language into VocabMosaic, I've been wondering if other external elements were possible to import, like Internet radio. It would make casual games that require the player's musical whims to add to the flavor more possible to design, or give designers of tiny area games the chance to keep music variable even if the map never changes.

Probably too far of a long-shot, but worth asking if it's possible and reasonable.
Place Obligatory Signature Here
Metal King Slime
Send private message
 
 PostThu Oct 24, 2013 7:36 pm
Send private message Reply with quote
Well I think it's a neat idea of the sort I want to encourage, but this one's certainly outside the scope of the engine; a fork would be called for for that.
Liquid Metal Slime
Send private message
 
 PostFri Nov 01, 2013 5:51 am
Send private message Reply with quote
TMC wrote:
It depends on the audio backend.

music_sdl (which is the default on all operating systems) has a limit of 8 sounds playing at once. However this limit is completely arbitrary and is trivial to increase (the limit it not due to the SDL_mixer library that music_sdl uses). I can do that if you want. There's no good reason for that limit, although SDL_mixer is really inefficient with memory.

music_native and music_native2 have no limit, and they are also much more efficient.


Coming back to this topic. Could you explain what exactly an audio backend is? I searched but could not find any info to better my understanding. I ask primarily because I would like to use music_native or music_native2 instead of music_sdl. Does this require some sort of change in system preferences? A change in software? A change in hardware?

My idea is this. I'd like to build a simple game that randomly spawns NPC's (life). The NPC's will slowly but surely interact with each other causing them to multiply, transform, die, etc... Each NPC on the screen will produce a sound effect at a certain rate, some NPC's will inhibit sound effects, higher levels of evolved NPC species will make more complexed sounds... You get the picture. The end result will be what I believe to be an awesome composition which captures the beauty of life, death, evolution, simplicities, complexities and much more. I think the best part of all is the composition would be random and non repeatable while still maintaining a certain degree of programmed direction.

Anyways just an idea. My computer can't really take on such an endeavor with and 8 sound limit. Hope it's an easy change to make.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Metal King Slime
Send private message
 
 PostFri Nov 01, 2013 11:36 am
Send private message Reply with quote
See http://rpg.hamsterrepublic.com/ohrrpgce/Backends, which I've just expanded.

To use another backend you either have to download a nightly built with an alternative backend from here, or compile the engine yourself.

It sounds like your idea could also benefit from being able to play the same sound effect multiple times at once. And also 3D positioning or at least 2D panning of sound source points. ...Just thinking out loud.
Liquid Metal Slime
Send private message
 
 PostSat Nov 02, 2013 3:21 pm
Send private message Reply with quote
TMC wrote:
See http://rpg.hamsterrepublic.com/ohrrpgce/Backends, which I've just expanded.

To use another backend you either have to download a nightly built with an alternative backend from here, or compile the engine yourself.

It sounds like your idea could also benefit from being able to play the same sound effect multiple times at once. And also 3D positioning or at least 2D panning of sound source points. ...Just thinking out loud.


Awesome, I'll look in to this more after my midterms wrap up. Setting up a 3D sound environment would be awesome. Any suggestions towards developing something like that would be greatly appreciated.

I've been contemplating different ways I could have multiples of the same sound playing at once. The only thing I've come up with so far is importing multiple of the same sound as you said earlier, then using a code that will check if "sound 1, copy 1" is playing then attempt to play the next sound copy in line... and so on.

As far as 3D sound goes, the best idea I can think of is to import many variations of "sound 1" which are to vary in volume and degree of panning based off of where the NPC emitting the sound is in relation to the Hero or something of that nature. Though this seems like a really time consuming and messy way of implementing a 3D environment. Do you think there's a simpler way?

NOTE: I'm not big on coding. I have a decent grasp on it but definitely prefer simpler approaches if possible.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Metal King Slime
Send private message
 
 PostSun Nov 03, 2013 7:23 am
Send private message Reply with quote
Well I meant that those are features which I'm keen to add to the engine at some point, but there are dozens of other features with the same status, so... It kills me that this stuff is easy to add, but there's so much else to do and I'm really busy at the moment, and yet here I am annoying people by telling them what I or James could be doing.

The scheme you described for playing multiple sound effects at once is what I would do, it doesn't seem too bad. There isn't a better way to fake panning and sound effect volume than what you described.

Panning should not be too hard to implement in the engine, like sound effect volumes, as even SDL_mixer supports it. It would be nice if you could set the position of a sound source on the map and have the engine automatically handle the volume and panning, basically exactly what you want. I'm even considering adding another editing mode to the map editor to place sound sources. (I think I discussed this with Pepsi, who suggested making it zone-based instead.) At some point. Also, it's actually possible to process audio so that you can hear the forward-backward position of the sound too, using sophisticated libraries like OpenAL support that. Creating an OpenAL-based audio backend would be a pretty cool project!
Liquid Metal Slime
Send private message
 
 PostMon Nov 04, 2013 3:59 am
Send private message Reply with quote
These would be some awesome features to see implemented in the future. Until then I'll play with the information I've got. Thanks a lot.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Display posts from previous: