Skip to content

Add audio mode to initiator for DAT tape drives#321

Open
erichelgeson wants to merge 1 commit intomainfrom
initiator-audio
Open

Add audio mode to initiator for DAT tape drives#321
erichelgeson wants to merge 1 commit intomainfrom
initiator-audio

Conversation

@erichelgeson
Copy link
Contributor

Adds sequential device (tape drive) support to initiator mode, enabling audio DAT tape reading on DDS drives. Includes SCSI tape commands (rewind, locate, read position, mode select/sense), audio frame metadata tracking, and interpolation error detection.

Based on #157

Adds sequential device (tape drive) support to initiator mode,
enabling audio DAT tape reading on DDS drives. Includes SCSI
tape commands (rewind, locate, read position, mode select/sense),
audio frame metadata tracking, and interpolation error detection.

Based on #157
uint32_t interpolation_both;
uint32_t good_frames;
uint32_t all_frames;
uint8_t null_frames;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null frames max set via config is 300 - over the 255 max of a uint8_t


uint32_t position;
scsiReadPosition(&position, g_initiator_state.target_id);
logmsg("Starting position: ", (int)position);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure but we log the start position then immediately rewind - is that intended?

@archivistocrat
Copy link

archivistocrat commented Feb 9, 2026

My compaq branded sdt9000 has come alive and going at it in audio mode seemingly as it would normally be expected. I gave up on a 120 min tape taking too long, so using a 60 min tape instead.

If going by the reporting on serial, looking at the count of frames and timecode, the drive is reading and writing slower than real time playback. edit - I had debug enabled, will try another test without it to check. edit again - it was still slower than real time.

Weirdly In the initial test with a 120min tape, when manually stopped after 62 minutes and ejected, I noted the tape had barely transported even a quarter through the reel...

The resulting output on sd card is now a .img file

60 min tape reached reported null frames before 54 mins and continued through to the end of tape

Platform: BlueSCSI (Pico2/W)
FW Version: 2026.02.09-dev Feb 9 2026 17:01:48
Flash chip size: 4096 kB
I2C Supported
Reclock Pico 2/2W based boards to standardized speed
Initial Clock set to 150MHz
Reclocking the MCU to 155MHz
Setting the SDIO clock to 26MHz
After reclocking, system reports clock set to 155MHz

=== SD Card Info ===
SD card detected, exFAT volume size: 30430 MB
SD Name: SU32G, MID: 0x03, OID: 0x53 0x44
[665ms]
[665ms] === Global Config ===
[665ms] Reading configuration from bluescsi.ini
[667ms] DBG -- SelectionDelay = 255
[667ms] DBG -- EnableUnitAttention = No
[667ms] DBG -- EnableSCSI2 = Yes
[667ms] DBG -- EnableSelLatch = No
[667ms] DBG -- MapLunsToIDs = No
[667ms] DBG -- EnableParity = Yes
[668ms]
[668ms] === Finding images ===
[751ms] === Finding images in / ===
[762ms]
[762ms] == Platform supports ROM drive up to 2848 kB
[762ms] DBG ---- ROM drive image not detected
[763ms]
[763ms] === Configured SCSI Devices ===
[834ms]
[890ms] SCSI Initiator Mode
[1143ms] InitiatorID set to ID 0
[1736ms] Clock set to: 155MHz
[1736ms] Initialization complete!
[1736ms] Disabling status LED
[1743ms] INFO: Pico Voltage: 3.357V.
[1745ms] Scanning SCSI ID 1
[2745ms] DBG -- BUS_BUSY
[2745ms] DBG ---- SELECTION
[2745ms] DBG ------ SELECTING 1 with initiator ID 0
[2745ms] DBG ---- COMMAND: TestUnitReady
[2745ms] DBG ------ OUT: 0x00 0x00 0x00 0x00 0x00 0x00
[2748ms] DBG ---- STATUS
[2748ms] DBG ------ IN: 0x00
[2748ms] DBG ---- MESSAGE_IN
[2748ms] DBG ------ IN: 0x00
[2749ms] DBG -- BUS_FREE
[2750ms] DBG -- BUS_BUSY
[2750ms] DBG ---- SELECTION
[2750ms] DBG ------ SELECTING 1 with initiator ID 0
[2750ms] DBG ---- COMMAND: StartStopUnit
[2750ms] DBG ------ OUT: 0x1B 0x00 0x00 0x00 0x01 0x00
[10214ms] DBG ---- STATUS
[10214ms] DBG ------ IN: 0x00
[10214ms] DBG ---- MESSAGE_IN
[10214ms] DBG ------ IN: 0x00
[10215ms] DBG -- BUS_FREE
[10216ms] Audio mode enabled, frame size: 5822
[10216ms] DBG read capacity: OK
[10216ms] DBG -- BUS_BUSY
[10216ms] DBG ---- SELECTION
[10216ms] DBG ------ SELECTING 1 with initiator ID 0
[10216ms] DBG ---- COMMAND: Inquiry
[10216ms] DBG ------ OUT: 0x12 0x00 0x00 0x00 0x24 0x00
[10218ms] DBG ---- DATA_IN
[10218ms] DBG ---- Total IN: 36 OUT: 0 CHECKSUM: 33289
[10218ms] DBG ---- STATUS
[10218ms] DBG ------ IN: 0x00
[10218ms] DBG ---- MESSAGE_IN
[10218ms] DBG ------ IN: 0x00
[10219ms] DBG -- BUS_FREE
[10220ms] DBG inquiry: OK
[10220ms] SCSI ID 1 capacity 1000000 sectors x 5822 bytes
[10220ms] Drive total size is 5552 MiB
[10220ms] DBG -- BUS_BUSY
[10220ms] DBG ---- SELECTION
[10220ms] DBG ------ SELECTING 1 with initiator ID 0
[10221ms] DBG ---- COMMAND: Read10
[10221ms] DBG ------ OUT: 0x28 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00
[10221ms] DBG ---- STATUS
[10221ms] DBG ------ IN: 0x02
[10221ms] DBG ---- MESSAGE_IN
[10221ms] DBG ------ IN: 0x00
[10222ms] DBG -- BUS_FREE
[10223ms] DBG Target does not support READ10 command
[10223ms] SCSI Version 2
[10223ms] [SCSI1]
[10223ms] Vendor = "SONY "
[10223ms] Product = "SDT-9000 "
[10223ms] Version = "12.2"
[10223ms] Type = Not Supported, trying direct access
[10223ms] Unhandled scsi device type: 0x01. Handling it as Direct Access Device.
[10340ms] Preallocating image file
[10715ms] Starting to copy drive data to RM10_imaged(1)-003.img
[10715ms] DBG -- BUS_BUSY
[10715ms] DBG ---- SELECTION
[10715ms] DBG ------ SELECTING 1 with initiator ID 0
[10715ms] DBG ---- COMMAND: ModeSelect6
[10715ms] DBG ------ OUT: 0x15 0x00 0x00 0x00 0x0C 0x00
[10716ms] DBG ---- DATA_OUT
[10717ms] DBG ---- Total IN: 0 OUT: 12 CHECKSUM: 4099
[10717ms] DBG ---- STATUS
[10717ms] DBG ------ IN: 0x00
[10717ms] DBG ---- MESSAGE_IN
[10717ms] DBG ------ IN: 0x00
[10718ms] DBG -- BUS_FREE
[10719ms] Tape mode set to AUDIO
[10719ms] DBG -- BUS_BUSY
[10719ms] DBG ---- SELECTION
[10719ms] DBG ------ SELECTING 1 with initiator ID 0
[10719ms] DBG ---- COMMAND: ModeSense
[10719ms] DBG ------ OUT: 0x1A 0x00 0x00 0x00 0x0C 0x00
[10720ms] DBG ---- DATA_IN
[10721ms] DBG ---- Total IN: 12 OUT: 0 CHECKSUM: 21923
[10721ms] DBG ---- STATUS
[10721ms] DBG ------ IN: 0x00
[10721ms] DBG ---- MESSAGE_IN
[10721ms] DBG ------ IN: 0x00
[10722ms] DBG -- BUS_FREE
[10723ms] Drive is in AUDIO mode
[10723ms] DBG -- BUS_BUSY
[10723ms] DBG ---- SELECTION
[10723ms] DBG ------ SELECTING 1 with initiator ID 0
[10723ms] DBG ---- COMMAND: PreFetch/ReadPosition
[10723ms] DBG ------ OUT: 0x34 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
[10724ms] DBG ---- DATA_IN
[10725ms] DBG ---- Total IN: 20 OUT: 0 CHECKSUM: 33563
[10725ms] DBG ---- STATUS
[10725ms] DBG ------ IN: 0x00
[10725ms] DBG ---- MESSAGE_IN
[10725ms] DBG ------ IN: 0x00
[10726ms] DBG -- BUS_FREE
[10727ms] Starting position: 658090
[10727ms] DBG -- BUS_BUSY
[10727ms] DBG ---- SELECTION
[10727ms] DBG ------ SELECTING 1 with initiator ID 0
[10727ms] DBG ---- COMMAND: RezeroUnit/Rewind
[10727ms] DBG ------ OUT: 0x01 0x00 0x00 0x00 0x00 0x00
[25046ms] DBG ---- STATUS
[25046ms] DBG ------ IN: 0x00
[25046ms] DBG ---- MESSAGE_IN
[25046ms] DBG ------ IN: 0x00
[25047ms] DBG -- BUS_FREE
[25049ms] Tape rewound successfully
[25069ms] DBG -- BUS_BUSY
[25069ms] DBG ---- SELECTION
[25069ms] DBG ------ SELECTING 1 with initiator ID 0
[25069ms] DBG ---- COMMAND: Read6
[25069ms] DBG ------ OUT: 0x08 0x00 0x00 0x16 0xBE 0x00
[25519ms] DBG ---- DATA_IN
[25520ms] DBG ---- Total IN: 5822 OUT: 0 CHECKSUM: 25575
[25520ms] DBG ---- STATUS
[25534ms] DBG ------ IN: 0x00
[25534ms] DBG ------ STATUS: 0x00
[25534ms] DBG ---- MESSAGE_IN
[25534ms] DBG ------ IN: 0x00
[25535ms] DBG -- BUS_FREE
[25542ms] Audio frame 1 ABS: 0:0:1:29 PRG: 110:110:110 interp[L:0 R:0 B:0]
[25550ms] DBG -- BUS_BUSY
[25550ms] DBG ---- SELECTION
[25550ms] DBG ------ SELECTING 1 with initiator ID 0
[25550ms] DBG ---- COMMAND: Read6
[25550ms] DBG ------ OUT: 0x08 0x00 0x00 0x16 0xBE 0x00
[25553ms] DBG ---- DATA_IN
[25554ms] DBG ---- Total IN: 5822 OUT: 0 CHECKSUM: 25569
[25554ms] DBG ---- STATUS
[25573ms] DBG ------ IN: 0x00
[25573ms] DBG ------ STATUS: 0x00
[25573ms] DBG ---- MESSAGE_IN
[25573ms] DBG ------ IN: 0x00
[25574ms] DBG -- BUS_FREE

[305231ms] Audio frame 6510 ABS: 0:3:13:15 PRG: 110:110:110 interp[L:0 R:0 B:0]
[305239ms] DBG -- BUS_BUSY
[305239ms] DBG ---- SELECTION
[305239ms] DBG ------ SELECTING 1 with initiator ID 0
[305239ms] DBG ---- COMMAND: Read6
[305239ms] DBG ------ OUT: 0x08 0x00 0x00 0x16 0xBE 0x00
[305245ms] DBG ---- DATA_IN
[305246ms] DBG SD card readSector(22976425) slow transfer, buffer0x2002C7A8 vs. 0x200315B8
[305247ms] DBG SD card writeSector(22976425) slow transfer, buffer0x2002C7A8 vs. 0x200315B8
[305249ms] DBG SD card writeSectors(22976426) slow transfer, buffer0x20031614 vs. 0x200315B8
[305253ms] DBG ---- Total IN: 5822 OUT: 0 CHECKSUM: 9514
[305253ms] DBG ---- STATUS
[305253ms] DBG ------ IN: 0x00
[305253ms] DBG ------ STATUS: 0x00
[305253ms] DBG ---- MESSAGE_IN
[305253ms] DBG ------ IN: 0x00
[305254ms] DBG -- BUS_FREE

[502790ms] Audio frame 107488 ABS: 0:53:42:26 PRG: 110:110:110 interp[L:289 R:321 B:284]
[502797ms] DBG -- BUS_BUSY
[502797ms] DBG ---- SELECTION
[502797ms] DBG ------ SELECTING 1 with initiator ID 0
[502797ms] DBG ---- COMMAND: Read6
[502797ms] DBG ------ OUT: 0x08 0x00 0x00 0x16 0xBE 0x00
[502804ms] DBG ---- DATA_IN
[502805ms] DBG ---- Total IN: 5822 OUT: 0 CHECKSUM: 47557
[502805ms] DBG ---- STATUS
[502813ms] Start of null frames detected
[502813ms] DBG ------ IN: 0x00
[502813ms] DBG ------ STATUS: 0x00
[502813ms] DBG ---- MESSAGE_IN
[502813ms] DBG ------ IN: 0x00
[502814ms] DBG -- BUS_FREE

[1240370ms] DBG -- BUS_BUSY
[1240370ms] DBG ---- SELECTION
[1240370ms] DBG ------ SELECTING 1 with initiator ID 0
[1240370ms] DBG ---- COMMAND: RequestSense
[1240370ms] DBG ------ OUT: 0x03 0x00 0x00 0x00 0x12 0x00
[1240371ms] DBG ---- DATA_IN
[1240372ms] DBG ---- Total IN: 18 OUT: 0 CHECKSUM: 60992
[1240372ms] DBG ---- STATUS
[1240372ms] DBG ------ IN: 0x00
[1240372ms] DBG ---- MESSAGE_IN
[1240372ms] DBG ------ IN: 0x00
[1240373ms] DBG -- BUS_FREE
[1240374ms] RequestSense response: 0xF0 0x00 0x08 0x00 0x00 0x16 0xBE 0x12 0x00 0x00 0x00 0x00 0x00 0x05 0x00 0x00 0x31 0x00 sense_key 8 asc 0x00 ascq 0x05
[1240374ms] End of data detected on tape
[1240375ms] Audio frame 124189 ABS: 0:0:0:0 PRG: 0:0:0 interp[L:16988 R:17020 B:16983]
[1240384ms] Ejecting media on SCSI ID: 1
[1240384ms] DBG -- BUS_BUSY
[1240384ms] DBG ---- SELECTION
[1240384ms] DBG ------ SELECTING 1 with initiator ID 0
[1240384ms] DBG ---- COMMAND: StartStopUnit
[1240384ms] DBG ------ OUT: 0x1B 0x01 0x00 0x00 0x02 0x00
[1240385ms] DBG ---- STATUS
[1240385ms] DBG ------ IN: 0x00
[1240385ms] DBG ---- MESSAGE_IN
[1240385ms] DBG ------ IN: 0x00
[1240386ms] DBG -- BUS_FREE
[1240387ms] Finished imaging drive with id 1
[1240387ms] Audio: 16988 left channel interpolations
[1240387ms] Audio: 17020 right channel interpolations
[1240387ms] Audio: 16983 both channel interpolations
[1240387ms] Audio: 107163 good frames / 124188 total frames

@archivistocrat
Copy link

archivistocrat commented Feb 9, 2026

The resulting .img file - I am assuming this is currently defined for output as the tape drive and audio is an unknown format. The log reports Type = Not Supported, trying direct access

Is this how the output was intended and will always be, or could a new type be written in to define raw, if not convenient processing to wav ? Most cases users I presume will want a wav output, some advanced may still want this raw data.

edit - thinking of raw audio and looking up a bit, I threw the img file into a couple of audio packages. The audio from the test tapes is indeed in there! But without a header for the file, the byte order or whatever else is unclear and would need to be defined for clean audio. There is loads of noise on a basic raw import. Again my understanding and persistence to try ends there.

This is quite the development though, the code is now indeed functionally working alongside the updated main. At least with Sony SDT9000 drives

@dericed Your previous uploaded test output files, did you have any further success interpreting the raw data correctly? I tried a few of them importing as raw audio again and found the same issue of noise, also your mp3 etc with that baked in

@archivistocrat
Copy link

archivistocrat commented Feb 10, 2026

Tried the usb bridge mode in windows - not expecting a thing... but there was a thing. Windows behaved strangely unreliable. As well as Pico 2, "Bluescsidevice" appeared for a while and a constant unstable popup alerting to put media into drive X... but only when a tape is inserted. I would presume because the drive is not switched into audio mode that the dat tape is not recognised. I don't have any dds tapes with data on to otherwise have seen the difference in behaviour.

does that suggest a connection is somewhat going through? In time is there any viability technically to enable this function for tape drives and audio mode

@erichelgeson
Copy link
Contributor Author

erichelgeson commented Feb 10, 2026

There's nothing in this PR related to USB MSC - that is only for mass storage devices, eg HDD/removable media. Someone could write an app to send raw scsi commands over usb to tapes, but that's outside the scope of this PR.

@archivistocrat
Copy link

I've since now discovered read_dat and compiled the decoder part to run on mac. It does exactly what I was envisaging and can be used with the raw file (without the tape drive code that runs normally before it).

It interprets the audio data from the non audio data and removes invalid frames, automatically processing tracks into header written wav files.

And so for reading audio DAT tapes in capable drives (SDT9000 at least), I affectively call this code here now functional as would be expected. But the raw data needs high level decoding with a tool such as read_dat.

Could any of read_dat code be implemented in some form to auto process the raw data output and leave wav on the SD card as part of the function?

I've got to clean my drive and run more tests to be properly certain of full output - my tapes were stored poorly by their owner and have dropout glitches which I want to be sure is the tape over the drive and bluescsi operation.

@dericed
Copy link

dericed commented Feb 16, 2026

Hi @archivistocrat, there's an ffmpeg patch at https://lists.ffmpeg.org/archives/list/ffmpeg-devel@ffmpeg.org/message/FCGZCROZHDVCP77AWETVKQWGP2VEAZKQ/ that can demux the datastream read from DAT tape (there you can use ffmpeg -i datastream_from_bluescsi_of_dat_tape.hda -c copy output.wav). Ping to @JeromeMartinez. Also the dvrescue command line programs can assess the datastream and report on metadata and error presence in the datastream frames: https://old.mediaarea.net/download/snapshots/binary/dvrescue/ (for that run dvrescue datastream_from_bluescsi_of_dat_tape.hda)

@archivistocrat
Copy link

archivistocrat commented Feb 26, 2026

Great stuff thanks for info and linking those. Haven't been able to patch ffmpeg and compile a build but did patch the read_dat code with improvements said to have been brought over from that work..?

From my testing, a good known tape transfers on this PR/branch perfectly, just slower than realtime. Then work to decode the raw data with the tools mentioned once compiled/patched. Just still the initial errors having to recycle the power a few times to get it going. Went into the drive and removed the tired and black auto-cleaning brush before a full cleanup. The problem tapes still had the same dropouts.

I have now gone to buy the cables and the LSI card for testing problematic tapes with the old apps for error correction, which will decide whether to continue bothering or not.

It was fun to link the hdd led in my old IDE enclosure into the bluescsi and cut a hole out back for the SD card, have now cut +line in an old usb cable for serial data only. However I'll now have to cut another hole in back and wire in a 68HD connector for the software/PCI card use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants