
                           Multitrack Recording GUS           By Dave Mercier
                           ~~~~~~~~~~~~~~~~~~~~~~~~
                         Version 0.1 Alpha (many bugs)       
                                  
                                  Overview
                                  ~~~~~~~~
        Multitrack Recording GUS is a program that will let you record and 
        play back multiple digital tracks on your Gravis Ultrasound.
        You can play back up to 14 tracks in this version, but how many you
        can play back before data is skipped, will depend on what frequency
        you are recording/playing at, and how fast your computer is.
        Actually, 14 tracks isn't a physical limit, it's just a practical
        limit I have imposed on this version. 32 tracks could be done at a
        lower frequency, but I didn't have room for them in normal text mode.

        Here are some of the features of this program:

                - Ability to record a track while listening to others

                - Ability to set balance and volume for each track

                - Ability to Mute a track from playing

                - Ability to delete tracks

                - A description can be attached to each track

                - Ability to record from Line-in, Mic-in, or both

                - Ability to record/playback at any supported frequency


        What this program is useful for, is the home musician who just wants
        to record some songs. You can only record one channel at a time. So
        you have to record your drums, then your bass, then your guitar, etc,
        all seperately. This is how most home studio musicians work with 
        their 4-tracks anyways. What this program offers, is a way to record
        more than 4 tracks.

        As for sound quality, it will greatly depend on your setup, and how
        you record. The same principles go for digital recording go here, as
        they do for others. Make sure you have the best level when you are
        recording, not too low, not too high. Just expirement. Keep in mind
        that this is 8 bit recording, so don't expect CD quality.

        Keep in mind that this release is just an alpha type release. The
        sound quality may suffer drastically due to 'pops and clicks' and
        the odd spurt of white noise. The only reason I am releasing the
        program like this, is because I have to go back to school today, and
        I will be hard pressed to find a minute to work on this for the next
        three months. But I will try as hard as I can to get a decent working 
        version out. There is no software like this available for the GUS, so
        I thought I would let you all play with it until something better 
        comes out.

        If I get the time, and I can get the new 16 bit card, or the 
        Ultrasound MAX in my hands, then I will do a 16 bit recording
        version. I will call this the 'PRO' version or something.


                   How to configure your equipment for Recording
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                   PLEASE READ THIS! THIS IS IMPORTANT!

        To achieve simultaneous recording and playback, we have to avoid the
        output -> input loopback problem. We avoid this by playing back all
        tracks on the right channel, while recording on the left channel.
        
        Connect your source for recording into the LEFT input channel of 
        either the MIC-IN, or LINE-IN. Then monitor what you are playing back
        with the right channel of the output. The balance settings only take
        effect when you are 'playing' back the tracks. When recording, all
        tracks will be heard on the right channel.

        Since this application is doing both recording and playback at the 
        same time, set your DMA channels up for this. This means the recording 
        DMA, and the playback DMA must be on different channels. I would 
        also strongly advise using 16 bit DMA channels if possible. This
        program is constantly pushing data through the DMA channels so it
        needs as much bandwidth as possible.

        If you get a EMM386.EXE error, just follow the instructions and add
        the D=128 to EMM386.EXE. I have not tried this with any other memory
        managers or machines, so I can't speculate.

        This program writes all recorded information to the Hard Drive.
        If you have digitally recorded before, you will know that Hard Drive
        space can be used very rapidly with a program like this. Consider 
        recording 8 tracks of 5 minutes each at 22050hz. This would require
        5 * 60 * 22050 * 8 = 53 Megabytes of Hard drive space! The amount
        of free Hard Drive space you will need will depend on what kind of
        recording you are doing. If you only used 3 tracks, of 1 minute each,
        at 8000hz, you would only require 1.5 Megabytes of Hard drive space.

        I would also suggest you only run this program under DOS. This 
        program is timing sensitive. If a multitasking OS takes away too 
        many CPU cycles, the playback or recording will become seriously
        messed up. I have run this program under OS/2, since I use this
        for development. I have noticed that some times this program will
        work great, then the next day, it will act completely whacko. So
        keep it to DOS unless you want surprises.


                            Explanation of Keys
                            ~~~~~~~~~~~~~~~~~~~

        Sorry for the awkward layout of the keys, I'll fix this when I get
        time.

        Here is what the keys do.

        T:      This will toggle the mute and play status of a track. If the
                track said 'PLAY', it will be toggled to 'MUTE' and vice 
                versa. MUTE the track when you do not want to hear it in the
                combined output of all tracks. Otherwise, keep it on PLAY.
                It should also be noted that when recording, it is best to 
                have a minimal amount of tracks playing back. One track 
                would be the preference. The more tracks played, the higher
                the chance of losing samples when recording.

        B:      This will adjust the balance of a track. A balance of '0' 
                means all the way left, while a balance of '15' is all the
                way right. A balance of '7' is the middle.

        V:      This will adjust the volume of a track. A volume of 0 is
                silence, while a volume of 4095 is full volume. Keep in mind
                that you probably can't hear anything below 2000, since this
                volume setting is logarithmic.

        E:      This will let you attach a description to a track. You may
                want to do this so that you remember which track is 'Drums'
                and which track is 'guitar', etc.

        F:      This will let you adjust the frequency to record and play back
                at. Higher frequencies need more Hard Drive space, but will
                give you higher quality. Lower frequencies give less quality,
                but save Hard Drive space. Allthough you can set it anywhere
                from 4000 - 44100, keep in mind the Ultrasound only has 256
                discrete recording rates. Selecting an unsupported rate may
                cause timing problems when recording and playing back. Keep
                safe and stick to a known frequency such as 44100, 22050, or
                11025.

        D:      This will delete a track, and any information associated with
                it.

        N:      This toggles the status of the LINE-IN. It must be toggled to
                ACTIVE if you wan't to record from the LINE-IN. If you don't
                make either the LINE-IN or the MIC-IN active, you will just
                be recording silence.

        M:      This toggles the status of the MIC-IN. It must be toggled to
                ACTIVE if you wan't to record from the MIC-IN. It is possible
                to have both MIC and LINE-IN active if you want to use both
                at the same time.

        R:      This will start recording of a track. You will hear any tracks
                that say 'PLAY' while you are recording the new track. Press
                any key to stop the recording process.

        P:      This will play back all track that say 'PLAY' with the correct
                balance settings.

        L:      This will save the work file you are currently working on, and
                load up another work file that already exists.

        C:      This will save the work file you are currently working on, and
                create a new work file to work on.

        S:      This will save your work file in case of a crash or something.

        Q:      This will save your work file, and exit to DOS.

        K:      This will delete your work file, and then give you the option
                of exiting the program, or creating another work file. Quiting
                the program is the only way to permanently get rid of a work
                file. Sorry if this is kludgy, I haven't had time to think it
                out better =).

        Z:      This is a hidden key that will simply redraw the screen, in
                case some unseen mishap happens to screw it up =).


                                Other Things
                                ~~~~~~~~~~~~

        This program will use as much of your Ultrasound's RAM as possible.
        You will get better results with more RAM on your card. With 256k,
        all memory will be used when playing back 2 tracks. After that,
        the size of the buffers are diminished. Smaller buffers will likely
        introduce more clicks and pops. With 1MB, you can play back 8 tracks
        before the buffers diminish in size. 

        Here's a few hints on using this program. You will get best results
        with a fast, defragmented hard drive. You will also get better 
        results if you have a lot of space left on your drive. I've never
        tried this program with disk compression, but I would avoid using
        something like stacker or doublespace. Since this application 
        relies on the speed of moving data to and from the hard drive, the
        compression overhead may cause loss of data or 'skips' in the sound.

        This version doesn't play the last bit of information in a track. 
        (Sorry, didn't have time to fix this up). So when you record, always
        wait a few seconds before you start the sound, and wait a few
        seconds after you finish playing whatever you are recording. If you
        don't the last bit of sound may be cut off when you play it.


                                What's Next?
                                ~~~~~~~~~~~~

        The only Agenda I have for this program right now, is to rewrite
        the playback and recording functions. The routines I am using now
        are basically just routines I 'hacked' out to see if this program
        would really work. They need a complete overhaul. I am using polled
        I/O to check when to record the next buffer, etc. This should really
        be done with interupts. Problem is I've never programmed with 
        interupts before, so I'm still trying to figure out where to start.

        The playback from this program should be perfect, the problem is
        with the recording. Any crap you hear in the output was introduced
        by my bad recording routines. What happens, is you lose samples every
        time a new recording buffer is started. On the other hand, when 
        playing back, no samples are lost. This creates a 'race' condition.
        The playback routines will eventually 'pass' the recording routines,
        and then screw up because the new data is being DMA'd at the wrong 
        time.

        After I get the audio routines perfected (I've spent about 80% of my 
        time on the interface =(), I will probably add a GUI. This will 
        probably take a long time because I will be in school trying to 
        figure out how to implement a GUI, for the next 9 months.


                   Bug Reports, Suggestions, and Comments
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        I would appreciate any of these. Actually it would be nice if 
        somebody could think of a name for this software, because the name
        I have now for it really stinks. I just couldn't think of a good name.

        Here's how you can contact me:

        Internet Address:
        D3140058@bcit.bc.ca
        *Note, this account had no internet access at the moment, since I
        just got this account yesterday. Maybe by the time you send mail 
        to me, it will be working properly. (sorry if it isn't).

        A1140338@bcit.bc.ca
        *This is my old account, which does work properly. Note that this
        will probably expire soon (maybe in a week).

        If both these accounts are messed up (I wouldn't doubt it), you can
        contact me through an Authorized Gravis node and ask me a question
        in the Gravis.Chat area. I also peruse adlib.fido sometimes, but
        I won't be reading it much now that I am in school.

        Leave a message to Dave Mercier if you do it the last way.

        If all else fails, you could write me at:
        Dave Mercier
        105-3955 Smith Ave.
        Burnaby B.C.
        V5G 2T8
        Canada

        I'd appreciate any feedback.

        By the way, this version of MRGUS is Public Domain. Future versions
        may be Shareware of Commercial, if it ever gets good enough. I
        wouldn't make this version shareware because of all the pops and
        clicks in the sound, and other assorted garbage. I do hold the rights
        to the source code however.


                                  Credits
                                  ~~~~~~~
        Thanks to Tom Klok for an excellent idea on how to bypass the GUS's
        output/input loopback problem. This program had been attempted a few 
        months earlier, but was scrapped after I thought it was unfeasible 
        because of the loopback problem. Also thanks to Advanced Gravis for 
        the support of their product through the BBS and free SDK's.
