[Bluej-discuss] Fix to simplesound project, chapter 11
Michael Kölling
M.Kolling at kent.ac.uk
Mon Oct 29 13:10:06 GMT 2007
Sorry for the late reply - I think this was left unanswered so far...
Yes, you are absolutely right. The first version (in our code) is
system dependant, and will work correctly on some systems and not on
others. The second version is correct. (My students discovered that
last year as well...)
Thanks for the fix - I'll make sure that it goes into the next
edition of the book.
Michael
On 16 Oct 2007, at 16:34, Seth Bergmann wrote:
> When you play a sound clip in the simplesound project, does it
> always show
> a duration of '1 seconds', regardless of the actual length of the
> sound
> clip?
>
> I have a fix for this:
>
> In the loadSound (File file) method of the SoundEngine class
> replace the
> following lines:
>
> currentSoundDuration = (int) (currentSoundClip.getBufferSize() /
> (currentSoundClip.getFormat().getFrameSize() *
> currentSoundClip.getFormat().getFrameRate()));
>
> with the following line:
>
> currentSoundDuration = (int) (currentSoundClip.getMicrosecondLength
> () / 1000000) ;
>
>
>
>
> Seth D. Bergmann Associate Professor
> Computer Science Department bergmann at cs.rowan.edu
> Rowan University 856-256-4500 ext. 3197
> Glassboro, NJ 08028 Fax 856-256-4741
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss
More information about the bluej-discuss
mailing list