Source Code
Up What's New Background Source Code Links Notes

 

VisualBasic Source Code

The Files

On this page you will find the VB6 source code to my partially completed program, as well as some related files. To begin with, here is a ZIP file containing the source code:

bulletVBsource.zip (33KB)

Note: It seems that somewhere along the line, this copy of the source code got out of sync with the compiled executable below. The executable will play a DAT through your sound card. The source code doesn't. I haven't looked at the source in quite some time and don't have VB installed on my computer any more, so I'm not inclined to figure it out. I think the source has the appropriate sound routines, I probably just commented them out while testing other things. As I stated elsewhere, the sound routines need replacing, anyway. Feel free to write better ones. If you do, let me know and I'll post your improved version.

To compile and run this, you will also need a wrapper DLL that translates the VB function calls to the ASPI functions in Win32. Adaptec wrote all of the ASPI functions using C calling conventions (all the examples in the ASPI SDK are in C). What this means is that VB is passing all arguments on the stack in one order and the ASPI functions are expecting them in the reverse order. I had a friend create the following wrapper DLL for me, as I don't know enough C to create it myself.

bulletASPIwrap.dll (135KB)

Note: This wrapper DLL was created for an earlier version of the ASPI SDK (dated January 2, 1997). The later SDK (dated July 1, 1998) added three more functions. ASPIwrap.dll does not include these three functions. However, ASPIwrap.dll does still work with the later SDK.

You should also get the ASPI SDK and related files from Adaptec (this link is broken, so here it is locally).

bulletASPISDK.exe (1.5MB)

Adaptec has released a new version of their ASPI layer software for Win32 platforms. This is not the SDK, just the end-user ASPI interface. However, in the Zip file is a Word document that describes the ASPI programming interface. I have included the Zip file and a separate copy of the Word document, that I have converted to a PDF.

bulletaspi_v470.zip (410KB)
bulletASPI32.pdf (186KB)

Here is a little program from Adaptec that tells you whether ASPI is correctly installed on Win95/98/NT.

bulletASPIchk.exe (112KB)

If you just want to run something to see your audio-capable DAT drive play a tape, here is a ZIP that contains my partially completed program, already compiled. (Needless to say, if your computer catches fire and turns into a molten pool after running this, I don't want to know about it.) This ZIP contains a VB6 installation package that will install the VB runtime files, my executable and the ASPIwrap.dll file. To install this, just run SETUP.

bulletSetup.zip (1.5MB)

Program Notes

The only buttons that do anything are the BOT (beginning of tape), EOT (end of tape), PLAY and EJECT. The displays are not updated and the group of buttons on the right side do nothing of consequence (these were to allow direct seeking to a particular time or program). The "save to a wave file" function is not working on the menu, but if I remember, the functionality is in the program (I wrote the save functions before the play, so it's in there somewhere).

Note that reading (not playing) the tape is 2.1 times faster than a DAT audio deck will play the tape. In other words, if you stop the read process after exactly 1 minute, you will have 2.1 minutes of audio. This is due to the fact that a data DAT drive moves the tape faster than an audio DAT deck. This also applies if you are only saving audio to a wave file and not playing (when playing, you are only reading what you need at the time and making the tape drive wait between reads).

To detect an audio-capable drive, I do a Mode Sense, save the current density, do a Mode Select 80H and see if it takes, then restore the old density. In case you're wondering, the tape density setting of 80H is what distinguishes an audio tape from a data tape.

Additional information

There are many things wrong with the program as it stands.

bulletMany functions are not complete.
bulletThere is no error checking.
bulletThe only documentation for the program is in the comments.
bulletI am assuming that the DAT was recorded at 48KHz, as I didn't want to bother with the other sample rates yet.
bulletI had not implemented any functions to write audio data to a tape when I stopped coding.
bulletThe function to play a DAT through the Windows WAVEOUT device (your sound card) assumes that it can handle 48KHz Wave data. If your card only goes up to 44.1KHz, the audio will sound slower than normal.
bulletSpeaking of the play function, I based it on an example from the Microsoft KnowledgeBase. The play function hooks into the Windows message stream. This works, but not very well. This function definitely needs to be re-written. BTW: don't try playing a DAT from within the VB programming environment. The message-hooking code screws things up and VB will probably crash on you.

There is a problem with ASPI itself, in regards to this program. There is no way to stop a tape command that is in progress. What this means is that if you issue a command to seek to the end of the tape (or a particular program number or time), you can't then issue a command to stop the tape. You have to wait until the original command has completed. Where this really hurts is that with ASPI, you can't implement a CUE/REVIEW function.

Here is an excerpt of an email I sent to someone about this and the reply:

>The ASPI FAQ says that the SC_ABORT_SRB and SC_RESET_DEV commands don't
>do anything, but "In the future, these may start working". I tried the Abort
>and Reset commands and indeed, they don't do anything. Their suggestion of
>using the SC_GETSET_TIMEOUTS command won't do what I need.
>
>What I am trying to do is issue a Locate command to an audio DAT drive and
>to be able to abort the Locate at any time. Think of it like the "Fast
>Forward" and "Stop" buttons on a tape deck. I'm trying to implement the
>same functionality.
>
>Do you have any suggestions? Do you know if/when these commands will be
>made to work? I have ASPI 4.57, which I believe is the latest one.

Unfortunately, you're not going to have any luck at all doing this.
About the only way it would work is if you can do an "immediate" command
to the device and then later send a different CDB to cancel or poll for
completion. NT's SCSI subsystem is not really set up to allow
asynchronous event notification, aborts, or bus device resets.
Similarly, doing a reset to the device is not a great way to stop an in
progress command because it could reset the tape.

I noted in DATlib that the programmer had to patch the Sun Solaris SCSI driver to handle this problem (see section 4.3 in his doc file). It may be possible to make this work by calling the Win32 SCSI functions directly, bypassing ASPI. I don't know for sure, I'm just guessing.

Up ] What's New ] Background ] [ Source Code ] Links ] Notes ]

Copyright 2000 by Joseph Gray
All rights reserved