Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Ruby Gosu unknown file format for playing song?
- - By Omegas7 Date 2012-04-14 20:14
class GameWindow < Gosu::Window
  def initialize
    self.caption = $system.title
    @music =, "Resources/Despondent.mp3")


And throws this error:

>ruby Game.rb
C:/Ruby192/lib/ruby/gems/1.9.1/gems/gosu-0.7.43-x86-mingw32/lib/gosu/patches.rb:36:in initialize': File contains data in an unknown format. (RuntimeError)
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/gosu-0.7.43-x86-mingw32/lib/gosu/patches.rb:36:in
  from Game.rb:18:in new'
  from Game.rb:18:in
  from Game.rb:31:in new'
  from Game.rb:31:in

>Exit code: 1

It is a .mp3 file, and I believe the path is correct (I have my images in that Resources folder too, and they load fine).

I am running through SciTe script editor.
Parent - - By Maverick Date 2012-04-14 21:15 Edited 2012-04-14 22:50
Gosu can play only .wav or .ogg.

MP3's decryption has a copy-write to pay for and since Gosu is a free-to-use library, using MP3's didn't end up being a feature.

However, to get around this, download and use Audacity. You can convert your .mp3 file to either .wav or .ogg. :)
Parent - - By Omegas7 Date 2012-04-14 22:51
I see. Is the quality kept the same or is it affected by the conversion?
Parent - By Maverick Date 2012-04-14 23:38
More or less, yes. You can alter the quality under preferences. The higher the conversion quality for .ogg, the bigger the file. The smaller the quality, the smaller the file (but most people may not notice the differences!)
Parent - By pete_mw Date 2012-04-15 10:14
OggVorbis is usually regarded as a better format for audio than MP3, but converting between them will result in some loss of quality because they both chuck out some data to keep file sizes down.
Parent - By RavensKrag Date 2012-04-20 07:38
OGG uses compression, just like MP3.  The difference in quality (compared to say, FLAC) comes from which portion of the spectrum the compression chooses to favor.  IIRC, OGG tends to favor pitches in the range of human voices, while MP3 is equally compressed throughout.

I could be totally wrong though.  I remember reading an article online about it a while back, but I can't seem to find it right now.
Parent - - By Omegas7 Date 2013-01-16 03:17
By the way, how come other free libraries like cocos2d-iphone can run .mp3 files anyway?
Parent - By jlnr (dev) Date 2013-01-16 03:48
Gosu can play MP3 on iOS (just like Cocos2D) because it uses the iOS system APIs. (Using OGG on the iPhone is a very bad idea, because OGG decoding is not hardware-accelerated.)

I honestly don't understand the exact licensing scheme for MP3. If I could get each operating system's APIs to decode MP3 files for me, I would support it for development purposes alone. (Just like Gosu supports loading from PSD files and it makes prototyping nicer - probably - I haven't tried it a lot yet)
Up Topic Gosu / Gosu Exchange / Ruby Gosu unknown file format for playing song?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill