cybercase / webminidisc

Upload your Music to NetMD MiniDisc devices thanks to WebUSB and WASM
GNU General Public License v2.0
306 stars 88 forks source link

Feature request: use TOC cloning for gapless SP-Download PC -> MD #99

Open Stuckalf opened 2 years ago

Stuckalf commented 2 years ago

Hi and thx for this great piece of software for MD lovers!

Would it be possible to get a "gapless TOC-cloning version" in the near future to implement a gapless transfer of WAV, FLAC etc. in SP mode? AFAIK each track (transfered to MD via SP mode) gets a tiny gap at the end (maybe filling up the rest of the md data block with zeros, comparable to MP3 padding - my guess). Of course I've tested the transfer in SP mode with a fresh rip of an original CD (I only rip in WAV or FLAC - so no annoying MP3 padding occurs).

I'd like to see a future version of Web Minidisc with the option to transfer natively gapless records (like "Dark Side of the Moon" from Pink Floyd) to MD in SP mode (for best quality) as one single track (!!!) for the whole album. What we'd get is only one track on the MD perfectly gapless. Now the trick: After transfering "all tracks in one big track" Web Minidisc could create a new TOC with the correct track length and entries for the whole album and "TOC clone" the disc with that newly created TOC - voila: a perfect gapless MD with correctly splitted tracks.

Possible?

asivery commented 2 years ago

Hello @Stuckalf , From what I know, it's possible to implement a functionality like this, but I'm not sure if transferring the whole disc as a single track is the easiest method. It should be possible to manipulate the boundaries of tracks in the TOC after transferring them instead. Also, keep in mind that the NetMD standard doesn't support TOC cloning or TOC editing in any way, and it can only be done on devices supported by netmd-exploits. You can experiment with moving track boundaries using Web Minidisc Pro's factory mode (available from the menu). After selecting a track in the factory mode's UI, you should see its 'Link' value. You can then select a fragment with that index in the track fragment table (Hold shift to display the indices instead of properties) and change the track's beginning position. The position is given in a "cluster.sector.group" format as hex. Every group is a 11.6ms piece of mono audio (for SP stereo 2 groups are read by the player at the same time to play both channels, so to move a stereo track by 11.6ms, you would need to move it by two groups), every track consists of 11 groups, every cluster consists of 32 sectors. I'll let you know if I implement this feature in a more user-friendly way later down the line.

Stuckalf commented 2 years ago

Thanks for your reply and the extra info on sound groups. I'll try to get the correct track boundaries for some test tracks. Anyway a user-friendly solution through software while transfering the tracks might be the best way to go. Hope we're all lucky and get a better solution sometime.

Stuckalf commented 2 years ago

Couldn't find any option in the menu to switch to factory mode. I'm normally using my Sharp IM-DR410. Is the factory mode of Web Minidisc depending on a special Minidisc Recorder model? These are my options in the menu: Reload TOC, Rename Disc, Wipe Disc, Exit, Enable Full-Width Title Editing, Dark Mode, Retro Mode (beta), About, Changelog, Support and FAQ, Fork me on GitHub No factory mode available, it seems.

asivery commented 2 years ago

Ah, sorry. I wrongly assumed you were using a Sony portable unit... Unfortunately the factory mode is only available on Sony NetMD portables. Unless Sharp has their own factory mode, it seems it's impossible to do any TOC edits on your unit. If I remember correctly, NetMD Wizard can transfer cue files without gaps, I haven't tested that functionality though.

Stuckalf commented 2 years ago

Ok, I tried it with my Sony MZ-N505. So editing the track boundaries would be comparable to cutting the end of a track by dividing it with an MD deck and deleting the newly created track (which should contain the unwanted audio silence).

But... The (audible) resulting gap between tracks isn't always 11.6 ms. It might be a bit more or less because the length of the originally transfered tracks doesn't have to be a multiple of 11.6 ms. So you get a smooth trackchange only by pure chance.

Therefore my idea was to use one big track (containing all audio data) and spilt the tracks after the transfer (with the track length information from the transfer list). Of course you are still only able to cut in 11.6 ms blocks - but these track changes would at least be absolutely seamless! I hope you get my point. Indeed I'm using this way for transfering gapless albums to MD: Copy all tracks to one big track with Foobar, transfer this one big track to Net MD and then divide the tracks manually with my Sony MDS-JE530. It works, but to divide the tracks manually feels so unnecessary if it could be a part of the transfer as described.

kai-h commented 1 year ago

I too would dearly love to have true gapless playback. When I was listening to MDs in the 90s and 00s, I recorded everything to them at 1x speed via the optical port, which inherently gave gapless playback on mixed albums. Now that I'm dumping music to the device via Net MiniDisc (which is an amazing piece of software that's really breathed new life into this old format), I'm getting half a second or so gap between tracks. I'll see if I can edit a track - the Factory Mode is not showing up under the ellipsis menu for my Sony MZ-NH600 Hi-MD walkman, I'll have to see if it appears when I connect my MDS-S500 deck. Clearly the MD format is capable of gapless playback, if the audio is recorded as a single stream.

I appreciate that it could get very complicated, but would it be possible to cheat somewhat behind the scenes and if you have two tracks that need to play back with gapless playback, and they're not an exact multiple of 11.6 ms, could you "borrow" a few samples from the following track to pad out the first track in order to fill an entire frame?

Stuckalf commented 1 year ago

could you "borrow" a few samples from the following track to pad out the first track in order to fill an entire frame?

I'd recommend it the other way round. Cut the first track at a full 11.6 ms frame and put the rest of the first track as padding onto the beginning of the next track (and so forth for the following tracks). It would be annoying if each following track might miss it's beginning (which would be the case if you'd borrow some samples from the second track to pad the first track, because you would indeed cut the beginning of the second track).

kai-h commented 1 year ago

Thinking about it, you're probably on the right track – make the first track a few ms shorter and add this to the start of the next track. If we're rounding up or down to the nearest 11.6ms, it's probably better to have the track marker drop a few ms early, rather than late which may result in missing part of the first beat.

Stuckalf commented 1 year ago

@asivery: I tried with my MZ-N505 and could get into the factory mode. While downloading a TOC went fine, an upload wasn't possible. The upload-button in the menu is disabled. Is this because of the 1.300 firmware of the N505?

asivery commented 1 year ago

@Stuckalf It's because of the N505 itself - it's a Type-R device. The exploits in current webminidisc work only on Type-S devices. Expect Type-R support in 2 weeks maybe... I recently got an N505 and have slowly been getting exploits to work on all Type-R devices.

Stuckalf commented 1 year ago

Any news on that topic or exploit?

asivery commented 1 year ago

@Stuckalf Kind of - I have managed to implement ATRAC download for all known Type-R portables, but not TOC editing. It seems that Sony has completely overhauled the firmware code for triggering a TOC edit, and I haven't been able to piece together the Type-R code for it yet.

Stuckalf commented 1 year ago

So if I'd buy and use a Sony MZ-N510 with Web Minidisc Pro then TOC cloning would be possible?

asivery commented 1 year ago

@Stuckalf Just a few hours ago I got it working on the N505. I'll soon publish a new version

Stuckalf commented 1 year ago

Absolutely great - would be nice if you'd post a comment when the new version is online. Thank you very much for your efforts on this topic!

asivery commented 1 year ago

@Stuckalf It's now live at https://web.minidisc.wiki/

Jo2003 commented 1 year ago

With the new exploit (SP Download) it would be possible to cut the atrac files in the correct position before transferring them to the device. So it works with LP2 already.

asivery commented 1 year ago

@Jo2003 That's very interesting - I didn't think of that being the one of that exploit's use cases. Did you confirm that in LP the only problem is that some silence gets added to the beginning / end of tracks when converting, and that it isn't the player that adds the silence? If so, that could work really well - I think atracdenc has better support for encoding ATRAC1 than ATRAC3.

Jo2003 commented 1 year ago

@asivery The gap of silence is added by the player to complete the atrac block to the needed size. If you pre-encode in SP1 you can cut the already encoded audio exactly at the block border. After that you send the track to the player and no padding needs to be added. In that case the track marker might be slightly moved to the original position (max. some ms), but this doesn't matter at all. atracdenc creates good quality ATRAC1.