arduinocelentano / cdimage

A tool for burning visible pictures on a compact disc surfase
GNU General Public License v3.0
145 stars 6 forks source link

Best way to determine disc geometry? #3

Open MysticAx0lotl opened 2 years ago

MysticAx0lotl commented 2 years ago

Hi there! I have a bunch of Staples CDs that I can't really do anything with (they're extremely low-quality), so I thought I'd repurpose them for this project. What's the best way to go about determining the geometry of these discs for the best results?

arduinocelentano commented 2 years ago

Hello. I've updated README and added some suggestions regarding calibration. It's not an ultimate solution you might be looking for, but it may give you a clue.

hackerb9 commented 2 years ago

You may want to change the README so it doesn't look like the Calibration section is necessary to use the software with the 4 discs you mentioned. (Perhaps add a Usage section between "Before you start" and "Calibration".)

hackerb9 commented 2 years ago

I am confused by the Calibration section. What are the multiple functions which need to be optimized?

In defcdparams.c, I see that two variables need to be solved for: initial track size (tr0) and multiplier for each following track (dtr). Finding two unknowns can be done with ordinary algorithms (hill climbing, for example).

Additionally, unless I'm mistaken — which is quite possible — those variables could be found independently.

It seems like, no matter what dtr is, the the first track's size can be found by a binary search: write 111111… in a track of length min, then a gap of 00000 until the guess for tr0, write a single 1 dot, then a gap of 00000 until max, then write a line of 11111. Check if the dot is above or below the point where the laser has gone to the next track and refine the search.

Using a binary search, you can check over a thousand possibilities with only ten disks.

Once tr0 is found, a similar binary search should work for finding dtr. Instead of arcs, one could create 2-D images that say "too low", "too high", and "perfect", each using a different dtr: min, max, and guess. If the word "perfect" is skewed in the same direction as "low", then set min ⇐ guess. Likewise for "high" and max. Then set guess ⇐ (min+max)/2 and try again.

Of course, I'm probably missing something.

Perhaps the problem is that you'd like to waste less than ten disks on the search? If so, I imagine it'd be possible to craft a single image which tries multiple dtr simultaneously. There's no need for the "too low" and "too high" to actually be printed since the word "perfect" will be skewed clockwise or counter-clockwise depending upon whether the guess for dtr is too low or too high. Instead, multiple choices can be printed inside squares, each with a different guess at the dtr. The user can select which two should be the next min and max by finding the point where the skew changes from clockwise to counterclockwise.

Does this sound plausible?

arduinocelentano commented 2 years ago

Thank you for your suggestions. Yes, it sounds reasonable. I just meant, it is definitely neither quick nor "user friendly" procedure. As for small dots, I don't think one can easily distinguish them with the naked eye. We are speaking about microns. Moreover, there is still some metadata you could not control and which might happen to look like a dot... I don't know, it should be tested. Maybe a microscope would be needed. And yes, I accept that a calibration image or a set of calibration images might be finally constructed. Another issue is that once a particular disc is calibrated, we cannot be sure that other discs of the same model are exactly equivalent. Would be great if manufacturers shared this data, but I have never seen such information.

jlarnal commented 2 years ago

A simple calibration image I'm using.

targetsingleray

hackerb9 commented 2 years ago

A simple calibration image I'm using.

Yup, a single ray is a reasonable way to do it. Has it worked for you and how many disks did it take to find the correct values?

jlarnal commented 2 years ago

I've just stuck my nose in the project yesterday.

So far, it (the picture) allowed me to single out one of the 4 brands presets (namely the Verbatim SERL2) as a close approximate of the geometry. On the first try. Later on I tried my luck at unDEFER's CDPAINT approach, and lost the rest of my night trying to get the "check mark" appear using his defcd.exe utility. No luck there, I got to a point where the "gray ring" one's supposed to find ended up missing completely.

Later on, I went on searching the complete integration formula for Archimede's spiral** (the audio track's shape) and understood there was a typo/misinterpretation in CDIMage track creation dialog : "1st track length" is actually the number of spiral turns. 😵

To be continued.

** ( look down the page for formulas ) TL.DR : yes, a single ray is the fastest way I know of to check out the radial alignment of a spiral coils.

jlarnal commented 2 years ago

One thing bugging me.... We're playing in the 1.38xxx spiral pitch ballpark here...

But according to the Red Book :

11.3 Physical Track pitch The spiral shall have a pitch of 1,6 μm ± 0,1 μm.

Then the minimal track pitch should be 1.5µm, not less. Wierd...

Anyway, I'll try to fiddle with the blank media's ATIP report (using cdrecord.exe -atip) to calculate a good start point for trk & dtr.

hackerb9 commented 2 years ago

One thing bugging me.... We're playing in the 1.38xxx spiral pitch ballpark here...

But according to the Red Book :

11.3 Physical Track pitch The spiral shall have a pitch of 1,6 μm ± 0,1 μm.

Then the minimal track pitch should be 1.5µm, not less. Wierd...

Red Book only applies to CD Digital Audio disks. CD-Rs are defined by the Orange Book. IIRC, by the time they got to the Orange Book, the language had stopped being relatively easy to understand and become something clearly written by a Standards Body. I also seem to recall the "spiral pitch" is no longer specified and one has to derive it from other factors. However, 1.38 makes sense since CD-Rs increased the storage capacity over 650MB CD-ROMs by decreasing the pitch. What is the storage capacity of your CD-Rs?

jlarnal commented 2 years ago

@hackerb9

The CD-RWs I'm using are Verbatim 8-12x 700MB bought specifically for the occasion, as CDImage presets are medias of this capacity. They're not the very same products though. 🤔 I read years ago that the 50 to 80MB gain of 700MB discs was gained by pushing the tolerances to the limit. But 1.386µm do make more sense in term of gain ratio, you're right.

I tried the "bruteforce" method (using a spreadsheet to keep track of my steps) and obtained some satisfactory (but not perfect) results with those blanks at 22951.175 turns and a 1.3865953µm pitch, after approximately 14 attempts.

Here are two samples :

P1050498 This one is from a crude low-res bitmap

P1050499 This one nears the 3000x3000 pixel limit of the program

I guess I could try to correct any skew/bending by 'preconstraining' the images in GIMP with a swirl effect filter, thus counteracting the final distorsions, but that would be.... ooof ! 😖 Too much work for a quitter like me ! 😅 I would however love to push the envelope and recompile CDIMAGE with a larger raster size, but I'm afraid Qt SDK always had beef with my computer (which is getting old and bloated).

I've ported converter.cpp to C# and will try fiddling with vector graphics (namely SVG artwork) as input ( if I ever find a nice library to handle the per-pixel color picking).

To be continued...

chiqiu23 commented 1 year ago

@jlarnal Thanks for all the info! I have also been trying to burn pictures on Verbatim 8-12x 700MB, but they were all a bit distorted. Were you able to find better parameters than the "22951.175" and "1.3865953" mentioned here?

jlarnal commented 1 year ago

@chiqiu23

Nope, those are the last settings I used. As I mentioned, I'm a pragmatic "quitter", and once I obtained the last result you saw in pictures, my thirst for discovery was satisfied. 😅

chiqiu23 commented 1 year ago

@jlarnal Could you explain how you "brute force" to get those two numbers? I'm also trying to find the appropriate parameters for my CD-RWs. However, I don't really understand what "1st track length" and "track delta" mean and so unsure of where to start. Thanks again!

hackerb9 commented 1 year ago

"Brute force" means blindly trying every option. I'm guessing @jlarnal was slightly less than a brute in that they probably checked to see whether the image was better or worse than the previous results and corrected for that. You'll probably want to write the parameter numbers on the CDs using a marker as you'll have too many to remember.

jlarnal commented 1 year ago

@chiqiu23 By "brute-force", I mean tweaking a value ever so slightly in CDImage, making it into a disc, observing (by eye) the result, writing down the observation on a spreadsheet, then rinse & repeat. Simple empirical approach.

Remember : you are working with two parameter : track length and track pitch. And the track is a continuous spiral. What you are trying to do, if you're using the test image I poster on 2022/10/05, is having a series of dots, on a spiral, aligned to form a single ray. That's it. Tricky, but approximately doable. One most likely cannot find the perfect values, but one can reach a "satisfying" result.

Acheron-of-hell commented 9 months ago

@jlarnal did you ever change the start radius? im down to my last 4 CD Rs im making little progress