[futurebasic] Re: [FB] Sound Manager code

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2001 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Fri, 31 Aug 2001 11:04:10 +0200
Richard Goodman wrote:
> 
> Robert W. Hommel once provided a useful set of functions for interacting
> with the Sound Manager. I have a copy of his "Sound Tutor" dated 1993.
> These functions still work with FB^2 and System 8.6, but I can't seem to
> get the code to function with FB^3. I am especially interested in functions
> that allow one to use a snd resource as a musical instrument and functions
> that allow one to play a melody from a string. I have three questions:
> 
> 1. Does anyone know if Hommel's code has been translated into FB^3/PPC code
> (and if so, where can I find it)?
> 
> 2. Robert Hommel, are you still among the FB crowd?
> 
> 3. Does anyone know of FB^3 code that allows one to exploit the Sound
> Manager (other than using the built in square wave as an instrument, which
> I've already programmed into Sebastian.--it's not very musical.)
> 
> Any help will be much appreciated.
> 
Richard,

I don't know if you got a reply from Robert Hommel, but I have found
at fborg a little prog by him about the Sound Manager which is dated
1995. So, I'm not sure we are talking here about the same file.
The piece of code crashes my computer even when run in FBII on my
G4/400 MacOS 9.04.
I have tried anyway to convert the code to FB^3 changing a few
things to suit my way of coding. I have also modified the code in my
poor attempt to fix the bugs.
So far, I can run the program in FB^3, the background sound is
played and the loops are performed correctly, I can also change the
background sound and I can hear the fading effect.
But, when I try the menu option to play an asynchronous sound, the
sound is played but immediately afterwards my computer freezes. I
have tried various things to no avail, now I'm a bit fed up to
restart the computer, perhaps someone will find the reason for that failure.
My files are at:
<http://euro.futurebasic.com/download/LoopSnd(revised).sea.hqx>
Note that I have attached the file "Sound Header.Incl" which is not
used by the program, it is just my own trial to convert the Sound
Manager header file from Apple that I made a while back. Some of the
calls are already defined by FB^3, but you can find there probably a
few things that are missing in the FB^3 header files (constants,
records and also calls). Of course it has not been tested in real projects.

Along the way, I have found a strange thing, that I failed to
explain to myself. I probably need an explanation à la Robert Purves
once again. It is about the SndSoundManagerVersion Toolbox call
which was in 68K assembly in the original file. I finally came up
with the following to get a correct(?) result:

TOOLBOX FN SndSoundManagerVersion() = LONG `0x203C, 0x000C, 0x0008, 0xA800

BEGIN RECORD NumVersion
  DIM majorRev       AS UNSIGNED CHAR
  DIM minorAndBugRev AS UNSIGNED CHAR
  DIM stage          AS UNSIGNED CHAR
  DIM nonRelRev      AS UNSIGNED CHAR
END RECORD

LOCAL MODE
LOCAL FN GetSMVersion$
  DIM @ vers      AS LONG
  DIM   version   AS NumVersion
  DIM   SMVersion AS STR15

  vers      = FN SndSoundManagerVersion
  version   = vers
  SMVersion = STR$(VAL&(HEX$( version.majorRev ))) ¬
            + STR$(VAL&(HEX$( version.minorAndBugRev ))) ¬
            + STR$(VAL&(HEX$( version.stage ))) 
END FN = SMVersion

// test
PRINT FN GetSMVersion$

I don't understand exactly why I have to store first the result of
the call in a long int variable (that must be in RAM) then to copy
the result in another variable.

I have tried this too:

LOCAL MODE
LOCAL FN GetSMVersion$
DIM @ version   AS LONG
DIM   SMVersion AS STR15

version   = FN SndSoundManagerVersion
SMVersion = STR$(VAL&(HEX$( version.0`` ))) ¬
          + STR$(VAL&(HEX$( version.1`` ))) ¬
          + STR$(VAL&(HEX$( version.2`` ))) 
END FN = SMVersion

Which gives different results whether version is in RAM or in a register.

What is going on here?

-- 

Cheers

Alain

-----------------------------------------------------
FB^3 in Europe:  http://euro.futurebasic.com/
FB II Pouch:     http://www.pixmix.com/FB/outils.html
-----------------------------------------------------