Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Wrong sample?
- - By lol_o2 Date 2010-10-20 12:34
I wanted one sample in my game, but it doesn't work like it should. After playing it, it just loops and doesn't want to stop. What's wrong with it? (sample attached to topic)
Attachment: mgunr.wav (17k)
Parent - - By pythong85 Date 2010-10-20 18:04
well you know, it would be more helpful if you would add the piece of code where you are calling the sample, so that we can see what you did there...
Parent - - By lol_o2 Date 2010-10-20 18:16
Did you try this sample? Code it's not needed, because it's just doesn't work good with simple .play (at least for me).
Parent - - By banister Date 2010-10-20 18:34
PROVIDE SOME EXAMPLE CODE THAT REPRODUCES YOUR PROBLEM THANKYOU
Parent - - By lol_o2 Date 2010-10-20 19:01
If I wrote, that you could try this sample, I didn't meant to play in a player, but in Gosu. Code below is simplest possible to show the problem. I just don't know WHAT IS WITH THIS SAMPLE THAT GOSU DOESN'T PLAY IT CORRECTLY.
____________
require 'gosu'
include Gosu

class GameWindow < Gosu::Window
  def initialize
    super(640, 480, false)
    self.caption = "Test Game"
    Sample.new(self,'mgunr.wav').play
  end

  def update
  end

  def draw
  end
end

GameWindow.new.show
Parent - By jlnr (dev) Date 2010-10-20 21:14
I think you don't do that in your real game, but: Sample.new(...).play is a bit dangerous because the Sample may be garbage-collected while playing. Not sure what (and on which platform) happens then :)
Parent - By pythong85 Date 2010-10-20 22:35
This works for me:

begin
  require 'rubygems'
rescue LoadError
end

require 'gosu'

class GameWindow < Gosu::Window
  def initialize
    super(640, 480, false)
    self.caption = "Gosu Tutorial Game"
    s = Gosu::Sample.new(self,"mgunr.wav")
    s.play
  end

  def update
  end

  def draw
  end
end

window = GameWindow.new
window.show
Parent - By jlnr (dev) Date 2010-10-20 21:11
There are some file formats that support looping, and WAV can contain lots of weird stuff, maybe that feature too. Did you try to just re-export it with Audacity?

Some other tools like sfxr also need an Audacity re-export before they work well.
Parent - - By RunnerPack Date 2010-10-20 22:50 Edited 2010-10-20 22:57
It loops because there is a "sampler chunk" (smpl) defined at the end of the file. See: http://www.sonicspot.com/guide/wavefiles.html

If you examine it in a hex-editor, it also contains the string "Serious Sam" (ripped from the game, perhaps?).

Like jlnr said, just re-export from a sound editor (or just delete the "smpl" chunk in a hex-editor).
Parent - By lol_o2 Date 2010-10-21 12:15
I re-exported it and it's working. Thanks for help.
Up Topic Gosu / Gosu Exchange / Wrong sample?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill