Referral links

Unlike other ads on this page, the two links below are to services I use - if you're looking for a new SIM or broadband connection I can personally recommend them, and these are specific referral links that I can get bonuses from if you sign up, so please use them :-)

Get a free giffgaff Sim Broadband from £5.99 a month with an included wireless router when you sign up to Plusnet - terms apply

Monday, 21 April 2014

90/99 minute audio CD writing with Linux


[Short link to this article if you need it: http://goo.gl/D9n7tX - or retweet me!]

There is an executive summary/how-to at the end of the main article if you're just looking to get on and do it! This has been quite a popular blog entry, so if you've found it useful, please get in touch and let me know!

INTRODUCTION

It seemed like such an easy thing to do. Use Linux to write a continuous mix audio CD of some tracks of 2013 to a 90-minute blank CD-R with track splits and CD-Text information. Bear in mind that some things I'm covering here are NOT specific to 90-minute discs, but are true for audio CD writing on Linux in general. I'm writing this to document my experiences since I struggled to find the comprehensive information anywhere else. For reference in this article my use of "wodim" and "cdrecord" are interchangeable - the machine I was using used wodim 1.1.11 - "cdrecord" was symlinked to it.

For the uninitiated, most CD-Rs on the market are 80 minute long, and can sometimes be "overburned" by around 88 seconds. Longer CD-Rs of 90 and 99 minutes are sometimes available at higher cost, although these are technically in violation of Philips+Sony's Orange book specification, so they cannot be guaranteed to work either in your writer or anything that's reading them, and most software doesn't know how to recognise them, hence the need to use overburning to write anything more than 80 minutes long. The ability to overburn effectively is dependent on your drive.

TRIAL AND ERROR - THE FULL STORY

Firstly I fired up the Brasero disk burner (As an aside it's not helpful when typing that name into Unity's Dash that Ubuntu dynamically searches for products on Amazon now - especially when you're 4 characters into that particular program name...) set up the track breaks, add the track info for CD-Text, insert the 90-minute blank and ... it wasn't interested. No, for the purposes of this I really did not want to burn over several discs:


So a bit of searching around got me nowhere fast, other than speculation (and a suggestion that k3b might be a better choice). Either way, Brasero wasn't looking like the universal tool I needed. A friend suggested he'd managed to write 90 minute CD-Rs using cdrecord directly. But my requirements were a little harder than writing a data disc so I tried a couple of things. Firstly I tested with a smaller audio CD with Brasero writing the image to a file (and cue sheet for the track break/CD-Text info) to an image file and trying to burn the image manually to a CD-RW with cdrecord (If you're not familiar with cuesheet use, I'll cover that at the end):

    cdrecord dev=/dev/sr0 -text -dao cuefile=MyAudio1.cue

This seemed to work ok until I went to play it. Random tracks (didn't seem to be a pattern to which ones, and it varied depending on which tracks I'd included) but always the same ones if the same image was burned again) seemed to have a low volume buzz in the background. Quite odd since it was a continuous input file. I never managed to figure out why, so ultimately that was useless.

While having a play around with cuesheets it became apparent that I didn't actually need brasero's image file - just the cue sheet (for the record brasero's track splitting was ok, other than the fact it seemed to always end up splitting with the tracks starting at 2 and put track 1 at the end - bear that in mind when typing in the track names!) I could edit the cue sheet myself, reset the type in the first line from "MOTOROLA" to "WAVE" and change the image file name to the source .wav file.


Good plan, but that didn't quite work either. I got this:


   Inappropriate audio coding in 'MyAudio1.wav' on line 1 in 'MyAudio1.cue'.

So cdrecord claimed the wav file was invalid - did I need Brasero's image after all? Was I back to square 1? Not quite ... turns out (and this is not unreasonable given the format of CDs) that cdrecord won't accept a .wav file that isn't in 44.1kHz, and my source file was in 48kHz. The error message above from cdrecord is a little ambiguous in that respect and I may raise that with them.

So the next step: fire up audacity, load the file, use the drop down in the bottom left of the screen (as per the screen shot on the right) to switch it to 44.1kHz (44100Hz) and re-export. NOTE: It's worth pointing out here that Brasero didn't care about the source file being 48kHz and would auto-convert behind the scenes when writing to a normal sized CD:

   sxa@sainz:/dev/shm$ file *.wav
   MyAudio1.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 48000 Hz
   MyAudio2.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz

Much better - it got rid of that error message but once again it still didn't work. This time cdrecord objected that the amount of data in the final track didn't end on a CD-frame (2352-byte) boundary:

   wodim: Bad audio track size 42302672 for track 25.
   wodim: Audio tracks must be at least 705600 bytes and a multiple of 2352.
   wodim: See -pad option.

Sadly it's suggestion to use "-pad" didn't seem to do anything useful and I still got the same error message - I'm guessing that probably doesn't work when the track info comes from a cuesheet. So back into Audacity, set the time counts at the bottom to work in CD-DA frames instead of seconds (as per screen shot above left), highlight the whole thing, manually drop the "end" frame number by 1 from whatever it was (you'll lose up to 1/74 of a second but I think you can probably live with that!) and export the selection to a .wav again.

So now I have a 44.1kHz CD-DA framed .wav file and a brasero-generated (slightly edited to point at a .wav) cue file. For the record, I tested with a smaller .wav file first to my CD-RW and it did solve the "buzz" problem from earlier - I figured it was better to try that before potentially wasting a 90-minute blank!

I'd seen reports that overburning (required for anything over 80 minutes) was much more reliable at slower speeds, so I gave cdrecord the parameter to reduce the write speed to 2x:

   cdrecord dev=/dev/sr0 -text -dao cuefile=MyAudio1.cue -v -overburn speed=2

Now the drive (an LG GSA-4120B) seemingly wasn't interested in hanging around and so the speed was increased to 4 (automatically, this was still using the above command). It completed and - I'm delighted to say - seemed to work. Played in the three players I tried, and the CD-Text information was there!

I also have 99 minute blanks but haven't needed them yet - I assume they'd work as well as the 90s as long as your drive is happy with them. The audio I had was only about 89 minutes long so it wasn't worth using the longer ones.

I remember playing with, and running a very early website dedicated to digital audio extraction (DAE - now more commonly referred to as "ripping") and MP3 files before most people knew about them, and here I am looking at lower level CD-DA stuff again. It's all coming full circle...



EXECUTIVE SUMMARY

I'm adding this section as a summary checklist for the next time I need to do this - it just summarises the rest of the article. Here's how to burn a continuous audio file with CD-Text to a 90-minute CD-R under Linux (assuming your drive supports it)
  1. Ensure your source audio file is in a CD-native 44.1kHz sample rate
  2. Make sure your file has a size that contains a number of CD-DA frames equal to a multiple of 2532 bytes
  3. Export to a standard uncompressed PCM .wav file
  4. Create a cue sheet with the CD-Text details (Brasero makes this fairly easy)
  5. Write the disc using the lowest possibly speed for increased reliability:
    cdrecord dev=/dev/sr0 -text -dao cuefile=MyFile.cue -v -overburn speed=2
For steps 1 and 2 you can use the "Audacity" editor - make sure your screen looks something like this before saving with File->Export Selection - ensure it's an exact number of total frames (I suggest setting it to one less than whatever it was originally when you highlight the whole waveform with CTL-A):




If you've never used a cue sheet before, there Wikipedia article is a good reference, but here's a quick example of the start of one in case you want to bypass creating it with Brasero showing the first three tracks. Just add as many as you need (although as mentioned, the track PERFORMER entries don't get picked up by cdrecord):


  FILE "/mnt/scd13/2013top34-90minues.wav" WAVE
  TITLE "sxa's 2013 top tracks mix"
  PERFORMER "@sxa555"
  TRACK 01 AUDIO
   TITLE "Mozart's House"
   PERFORMER "Clean Bandit"
   INDEX 01 00:00:00
  TRACK 02 AUDIO
   TITLE "Royals (Zoo Station Remix)"
    PERFORMER "Lorde"
    INDEX 01 03:32:24
   TRACK 03 AUDIO
    TITLE "All I Want Is You"
    PERFORMER "Agnes"
    INDEX 01 06:56:24

[etc.]



REFERENCES:
  1. Cue file format
  2. CD-DA frames tip from billw58 in audacity forums
  3. cdrecord man page with the "88 second" overburn reference (search "-overburn")
  4. Ubuntu's inclusion of amazon search results into Dash
  5. Article which gave me the hint about the missing PERFORMER entry

No comments:

Post a Comment