Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Audio
- By Wurstinator Date 2010-01-12 14:25
Hi :)
I would like to suggest a better way to handel sound output of Gosu.
There are some features which, I think, should be improved if it is possible.
First, there are two classes (Gosu::Song, Gosu::Sample) for playing sound files and the only difference between them is, the way the data is loaded. Apart from that, Gosu::Sample has a lot more features.
Things which could be better:
- only one class, with a parameter which defines kind of loading data
- beside volume and speed it also would be nice to have pitch
- still being able to play as many sounds/musics as you want to

I also like the idea that pausing, resuming and stoping is done using a Gosu::SampleInstance. A mistake in the Documentation (http://www.libgosu.org/rdoc/classes/Gosu/SampleInstance.html) gave me a good idea.
If the parameters pan, volume and speed (and maybe pitch :) are possible to be used with a SampleInstance you could do for example a fading effect in the background music.

Last, I'd like a variable which defines, if the sounds are still playing if the window isn't selected because at the moment it stops which may be good for some games/scenes but not for others :)

I never dealt with audio playing yet so I don't know if even any of these suggestions is possible to include but I think it would be a could step for Gosu =)

PS: jlnr, are you german? =o
- By jlnr (dev) Date 2010-01-12 17:19

> First, there are two classes (Gosu::Song, Gosu::Sample) for playing sound files and the only difference between them is, the way the data is loaded.


The bigger difference is that there is only one song playing at any time, and that is actually because it fits both (initially) used APIs a lot: FMOD and SDL_mixer. For tracked music files (IT, S3M, …) or streamed music files, they just don't offer the functionality needed to make them work like a Sample. :(

> A mistake in the Documentation


Which mistake? :)

> Last, I'd like a variable which defines, if the sounds are still playing if the window isn't selected because at the moment it stops which may be good for some games/scenes but not for others :)


Since sound works completely differently on all three platforms, please always mention on which platform it behaves like that :)

> PS: jlnr, are you german? =o


Yes ;)

My internal To Do list for audio looks like this:
• get rid of the "Window" or "Audio&" arguments in all constructors (works except on Windows)
• get rid of FMOD on Windows, because its licensing is complicated enough that you actually have to think about it
• make streamed music files work on OS X again (the Ostnati Bastion game needs this to work on OS X :/)
• find a way to implement "speed" on Linux, which probably means leaving SDL_mixer alone for good

After that all works, I agree that a single class Gosu::Sound would be awesome, but I think it will take a few years to that point ;)
- By lol_o2 Date 2010-01-12 18:02
For songs usable can be also loops. Music after end do not start from beginning, but from marked point.

And it's Ostatni, not Ostnati :)
- By jlnr (dev) Date 2010-01-12 19:44
Well, that all depends on which library Gosu uses, I think. For example, in the current (hopefully soon obsolete) FMOD port on Windows, I would expect looping points to actually work right now.
- By Wurstinator Date 2010-01-12 20:23

> The bigger difference is that there is only one song playing at any time, and that is actually because it fits both (initially) used APIs a lot: FMOD and SDL_mixer. For tracked music files (IT, S3M, …) or streamed music files, they just don't offer > the functionality needed to make them work like a Sample. :(


So the APIs you use miss support for such features? Aren't there other good free sound APIs around the net? :)

> Which mistake? :)


It says:
Attributes
Name  Read/write?
pan   RW
speed   RW
volume   RW
at SampleInstance but I think these should be at Sample ;)

> Since sound works completely differently on all three platforms, please always mention on which platform it behaves like that :)


On Windows (XP, SP 3).

> Yes ;)


Dann sind wir ja schon 2 :)

> My internal To Do list for audio looks like this:
> • get rid of the "Window" or "Audio&" arguments in all constructors (works except on Windows)
> • get rid of FMOD on Windows, because its licensing is complicated enough that you actually have to think about it
> • make streamed music files work on OS X again (the Ostnati Bastion game needs this to work on OS X :/)
> • find a way to implement "speed" on Linux, which probably means leaving SDL_mixer alone for good
>
> After that all works, I agree that a single class Gosu::Sound would be awesome, but I think it will take a few years to that point ;)


Maybe this will help you?
http://www.rpg-studio.de/scriptdb/script_files/181/FmodExAudio.html
It is a code written in RGSS (used in RPG-Maker) which uses Fmod (should be clear through the name :)
It provides functions like fading while playing.

Also, maybe you'd like to take a look at BASS:
http://www.un4seen.com/
- By jlnr (dev) Date 2010-01-13 20:11

> So the APIs you use miss support for such features? Aren't there other good free sound APIs around the net? :)


"other"? FMOD isn't even really free, it's just the best thing to use on Windows … ;)

> at SampleInstance but I think these should be at Sample ;)


No, it's exactly correct and the point of SampleInstance that these are not attributes of Sample :)

> ... which uses Fmod ...
> BASS:


I don't mind FMOD, but if there is one top feature request for Gosu, it might be a sound library that is completely free, as in "sell your game and don't even worry". So if I should ever mess around with the Windows port of Gosu/Audio, I should look for something that is easier in that regard …
- By Wurstinator Date 2010-01-14 22:00

> No, it's exactly correct and the point of SampleInstance that these are not attributes of Sample :)


Oh yes, I tried .volume -= 0.01 last time but the attribute is not readable.
So my new idea for SampleInstance is:
- make the attributes readable
- give Gosu::Sample the same attributes

> I don't mind FMOD, but if there is one top feature request for Gosu, it might be a sound library that is completely free, as in "sell your game and don't even worry". So if I should ever mess around with the Windows port of Gosu/Audio, I should > look for something that is easier in that regard …


I don't think a lot of people would care about a game done in Gosu. You shouldn't take this as an insult but I think for the commercial games languages like C++ are better. So I think you should just concentrate on finishing it and not on problems with law people may have later on.
- By erisdiscord Date 2010-01-14 22:12

> … I think for the commercial games languages like C++ are better.


Gosu is written in C++ with Ruby bindings, so this argument doesn't really hold up.
- By Wurstinator Date 2010-01-14 22:26
It may be written in C++ but most of the code (if you develop a full game) will be written in Ruby and the actual Ruby is not the perfect language for games.
- By erisdiscord Date 2010-01-14 22:58
my point is it's perfectly possible (as far as I'm aware) to write a game in C++ with Gosu. In fact, from the looks of things in the repository, Objective-C might be an option as well.
- By jlnr (dev) Date 2010-01-15 06:31 Edited 2010-01-15 06:37

> I tried .volume -= 0.01 last time but the attribute is not readable.


Are you sure? It should be...

> - give Gosu::Sample the same attributes


Why? What does it mean if you reduce the volume of the sample? Will it be more quiet if you play it afterwards? What about instances that are already playing? One library I worked with (ClanLib) applies the same to images, which have rotation and scaling properties. It's the direct opposite of what I want Gosu to be :)

> I don't think a lot of people would care about a game done in Gosu. You shouldn't take this as an insult but I think for the commercial games languages like C++ are better. So I think you should just concentrate on finishing it and not on problems with law people may have later on.


If there was no commercial project driving Gosu, the library and this board wouldn't be here.
- By Wurstinator Date 2010-01-15 13:24

> my point is it's perfectly possible (as far as I'm aware) to write a game in C++ with Gosu. In fact, from the looks of things in the repository, Objective-C might be an option as well.


Of course my post only makes sense when talking about a game in Ruby ;)

> Are you sure? It should be...


testsampleinstance.rb:18:in update': undefined method volume' for #<Gosu::Samp
leInstance:0xe7f980> (NoMethodError)

I still have 0.7.15 so you may have changed it already?

> Why? What does it mean if you reduce the volume of the sample? Will it be more quiet if you play it afterwards? What about instances that are already playing? One library I worked with (ClanLib) applies the same to images, which have
> rotation and scaling properties. It's the direct opposite of what I want Gosu to be :)


Never mind. I had an idea how I can do it on my own :)

> If there was no commercial project driving Gosu, the library and this board wouldn't be here.


Okay... never saw one ^^
- By erisdiscord Date 2010-01-15 17:11

> If there was no commercial project driving Gosu, the library and this board wouldn't be here.


You've got me curious; what is this commercial project? I've looked but I can't find anything online. :)
- By jlnr (dev) Date 2010-01-16 09:31

> I still have 0.7.15 so you may have changed it already?


I can't remember any change there, I will look into it. Either the documentation or the code is obviously wrong. :)
- By jlnr (dev) Date 2010-01-16 09:32

> You've got me curious; what is this commercial project?


It should be out one of the next years (not on the initially planned release date of 1998 it seems) *cough* ;)
- By Wurstinator Date 2010-01-17 11:03
Sorry for annoying you again ^^'
I got a problem with streaming the music. When I try to play a sound file which is some MBs big it doesn't start playing at 0:00 but about 3 seconds later.
Is there a way to fix it?
- By jlnr (dev) Date 2010-01-17 17:45 Edited 2010-01-17 17:51
I don't think so. It cannot even be a delay due to excessive loading; because when you call play, the file has already been loaded from disk completely. I guess it might just be a bug in FMOD? What format is the file anyway? :)
- By Wurstinator Date 2010-01-17 19:29
Weird... now it works :S
Maybe last time my PC was just running slow or something :/
Up Topic Gosu / Gosu Exchange / Audio

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill