librelist archives

« back to archive

Of buggy timers and truncated audio samples (Raisins)

Of buggy timers and truncated audio samples (Raisins)

From:
Pierre-Yves Gérardy
Date:
2009-12-20 @ 11:58
Hi all,

I'm trying to build a clone of http://brainworkshop.sourceforge.net/ , a
dual n-back game written in Python (the kind of games supposed to boost
one's fluid intelligence, according to a PNAS paper).

I'm running into two issues:

When a timer is given a parameter smaller than 1, the action occurs
immediately. I guess the float is truncated to 0.

I'm also trying to play short .wav files, but they are almost always being
truncated.

Here's a simplified version of the game flow: http://pastie.org/750605

Cheers,
Pygy

Re: [shoes] Of buggy timers and truncated audio samples (Raisins)

From:
Satoshi Asakawa
Date:
2009-12-21 @ 16:51
Hi Pygy,

> When a timer is given a parameter smaller than 1,
> the action occurs immediately. I guess the float
> is truncated to 0.
I confirmed with the following snippet. I guess you are right.

Shoes.app do
  @msg = []
  stack do
    10.times{|i| @msg[i] = para '.'}
  end

  timer 3.0 do
    [0, 0.1, 0.5, 0.9, 1.0, 1.3, 1.8, 2.0, 2.9, 3.0].each.with_index do |t,
i|
      timer(t){@msg[i].text = t.to_s}
    end
  end
end

first: 0 - 0.9 were displayed at once
then : 1.0 - 1.8 were displayed at once
then : 1.0 and 2.0 were displayed at once
then : 3.0 was displayed

Umm... I'm not sure this behavior is the expected Shoes spec or not...
Anyway, need to hack the code. ;-)

ashbb

ps. I used my local build 0.r1279 on Windows XP.
    It includes Ruby 1.9.1p376

Re: Of buggy timers and truncated audio samples (Raisins)

From:
Pierre-Yves Gérardy
Date:
2009-12-20 @ 12:02
I forgot someting important... I use OS X 10.6 on a 32bit processor.

Are there recent Mac builds with video support? I couldn't find any but I
may not have been looking at the right place. Alternatively, is there any
other cross-platform method for playing sound files from Ruby?

Re: [shoes] Re: Of buggy timers and truncated audio samples (Raisins)

From:
Satoshi Asakawa
Date:
2009-12-21 @ 16:55
> is there any other cross-platform method
> for playing sound files from Ruby?
How about Bloopsaphone? ;-)

ashbb

Re: [shoes] Re: Of buggy timers and truncated audio samples (Raisins)

From:
Pierre-Yves Gérardy
Date:
2009-12-21 @ 17:07
>
> > is there any other cross-platform method
> > for playing sound files from Ruby?
> How about Bloopsaphone? ;-)
>

If I manage to make it talk, it may be ok, but the Bloopsaphone can only
tchook, bing, zap and sing...

While you're at it, you could also check the behaviour of the "every" block,
it may also round it's parameter.