Virtual OS/2 International Consumer Education
VOICE Home Page: http://www.os2voice.org
April 2004

Newsletter Index
< Previous Page | Next Page >
Feature Index

editor@os2voice.org


Digital Radio Recordings

By Per Johansson © April 2004

Introduction

We live in the era of transition to digital electronics (as if you haven't noticed!). This article shows how to receive and record digital radio transmissions, storing the result on a CD.

This is essentially a how-to article, but I include sections of technical background information, that you can safely skip if you are not interested. If you are like me, you'll just browse the images anyway before actually reading the text. :-)

I'm not an audio expert, so if you find any errors, or solutions, be sure to tell me!

History

I became seriously interested in music in the late 1970's. At that time, you could either buy music on analogue media such as vinyl discs and cassette tapes, or you could use your cassette tape recorder to copy music from other media or from radio broadcasts (which is allowed for personal use). In case you wanted to record something from television, it was more tricky, as TV sets usually had no external sound connectors. I simply used microphones in front of the speaker! One day, my parents bought a portable TV set with a headphone output. I bought an adapter cable and plugged it into the cassette recorder, to record TV programs. It turned out to be a bad idea, since the TV set got overheated and badly burnt...

I routinely recorded interesting concerts from the radio on cassette. This technique still works, of course, although these days you may prefer to use other recording media. To this end, I connect one of the stereo amplifier's sound signal outlets to the input of the computer's sound card, so I can record radio broadcasts, vinyl discs or whatever to WAVE files.

MPEG

The Moving Picture Experts Group (MPEG) is a working group of ISO/IEC, see http://www.iso.ch/iso/en/prods-services/popstds/mpeg.html and http://www.chiariglione.org/mpeg/ . This is a set of international standards. The one that's interesting in this context is this one:

ISO/IEC 11172-3:1993
Information technology -- Coding of moving pictures and associated audio for digital storage media at up to about 1,5 Mbit/s -- Part 3: Audio

It defines the encodings MPEG-1 Layers I, II and III, often referred to as MP1, MP2 and MP3. The layers are compatible in a hierarchical way, i.e. an MP3 decoder is able to decode bitstreams encoded in MP2 and MP1.

Unfortunately, some proprietary formats are currently in widespread use, cutting us off from listening to many radio broadcasts and other sound recordings from the Internet at the whims of the owners of the recordings and the format used.

DAB

Even though there are several electronic digital devices for home use by now, analogue connections still seem to be the default when you want to exchange audio and video between them. For instance, listening to a live radio broadcast means that the sound is digitally recorded and produced, and stay that way until the broadcast begins. Since radio broadcasting normally is done using FM or AM, the digital sound is sent through a digital-to-analogue converter, transmitted, and if you record it with your computer, sent through an analogue-to-digital converter, so you have it in digital format again. This, of course, means quality loss, and other problems inherent in the FM and AM technologies.

DAB (Digital Audio Broadcasting) was invented to replace the analogue part of the audio distribution. The audio, together with accompanying information, is sent encoded using MP2 through a bitstream of usually 192 kbit/s. At that bitrate, you can broadcast six channels on one DAB ensemble (frequency). The frequency remains the same all over the broadcasting area, making RDS (the FM information add-on) obsolete, and much more room for many more broadcasts. You can opt out of certain categories of announcements, that usually are intended to warn vehicle drivers of accidents and such, but are useless for other listeners, and a pain while recording concerts. You can also broadcast other data than audio.

There's no international standard by ISO or IEC. DAB is developed by the "Eureka 147 Consortium", that seems to have no web page. See also http://www.worlddab.org/ . Be warned that their crippled site neither can be read correctly in Mozilla, nor in Netscape 4.

DAB broadcasting started in Sweden in 1995, first in the world besides the UK. Some countries, notably the USA, use other systems than DAB for digital radio. When I thought I had enough money, in 1998, I went to a well-stocked radio shop to buy a tuner. I hardly believed my ears when the man at the shop replied that the only existing tuners were high-end experimental ones, with a price tag to match. I had to wait three years until I could buy the Technics ST-GT 1000 at a discount shop in Germany, for "only" €600!

Lack of tuners hampered the development of digital broadcasting, and here in Sweden to this day only the public service radio company is doing geographically limited "experimental" broadcasts, at the time of writing consisting of six channels. There's also a data transmission channel called SR +, that you may be able to use through the Optical Out RDI connector, but I leave that as an exercise for the reader (As a former university student, I have got used to see that phrase!).

Anyway, the tuner has an optical digital audio output. The manual does not say what the output format is. The actual format is specified in the international standard IEC 60958 - Digital audio interface (sometimes referred to as IEC 958, which is an older designation). The format is also known by its former name S/PDIF (Sony/Philips Digital Interface). Old names sometimes remain in use for quite some time. The Hoontech input is marked "SPDIF IN". See rec.audio.pro FAQ http://www.vex.net/~pcook/RecAudioPro/digital.html#Q5.6 for more information.

The DVD/CD/VCD/MP3 player I bought later also had the same kind of output. For some reason, the DVB (Digital Video Broadcasting) set-top box I bought in 1998, has only analogue outputs, which sort of confirms my initial statement that connections are still analogue by default. (The absence of digital connectors may also be due to hardware manufacturers giving a hand to intellectual property owners' desire to control and prevent unauthorised distribution of their work, a controversial issue these days, judging from inflamed discussions on USENET.)

By the way, this kind of radio tuners is just one way to receive DAB. You can also use a PCI card, or the PSION Wavefinder with a USB connector. Using such devices you can record the MP2 stream directly, without having it decoded. MP2 recordings can be played in MP3 players.

For discussion on DAB, check out news://alt.radio.digital/.

Computer Hardware

Of course, I wanted to make use of that digital output to record radio programs, instead of routing them through the stereo amplifier analogue connector, as described above. To this end, I needed a digital input for the computer. The same analogue problem remains here, the soundcard I have (Sound Blaster Live! 1024 - bought mainly because of the ongoing 3rd party development of an OS/2 driver) comes with analogue connectors (except for a proprietary digital out for some speaker system) only, although the word "digital" is heavily used in the manual. However, as the manual says, you can use the Audio Extension connector to connect to Creative's optical digital I/O card. You were supposed to shell out some extra money for that device, of course. Worse, it couldn't be found on Creative's web. Further investigation revealed that the device was no longer offered, but instead the Korean company Hoontech had developed a similar device, the ST DB III Digital Bracket. It seems to be a well-known company, and its products are readily available - through musical equipment stores! I checked with the closest store, and they had it in stock, for €70. The next day, I returned to buy a 5 metre optical cable for €30, that I hadn't thought of the day before.


Fig.1: Soundcards

The digital card doesn't need a PCI slot, but it needs a slot in the chassis, so I rearranged the PCI cards to put the card next to the sound card. I connected the digital card to the audio extension port of the sound card, and the optical cable to the radio. The picture shows the two cards connected, taken out of the computer. The sound card is the big one, and the digital optical card is the little one to the left. The black cable to the left is optical input, the green is audio output to the speakers. The two cables on the rear side are sound from the DVD player and the CD recorder. Once again, none of these devices have any digital input or output, but this particular sound card doesn't have any digital ("S/PDIF") CD connector either. The little green card on top of the sound card is Hoontech's "S/B Interface Board", mounted on the audio extension port and connected by the grey cable to the Hoontech's "Digital Bracket". It's also connected to the little green card to the right, which is an "Amplifier Connecting Board". I'm supposed to connect it to an "S/PDIF Amplifier", but I leave that as another exercise for the reader.

Unfortunately, no sound was heard in eComStation, not even with the latest Universal Audio Device Driver 1.08. I wasn't sure if the fault was with the driver, or if the LB mixer wasn't aware of the new digital input, or if the problem was something else. Booting from Windows 2000 became another problem, since the system was confused by my rearrangement of the cards. Finally, everything worked as expected, and the digital radio sound was heard through the speakers. The default mixer had no setting for the sound level, though.

Back in eComStation, I began asking around for what may be the problem and the solution. My faith was restored when I read at the ALSA web site, the Linux people were using the Hoontech card with success. Finally, by a stroke of luck, the very same day I bought the card, version 1.09 of the sound driver had been released, with an accompanying mixer! It showed 172 different parameter settings, and I tried them out until I found a combination that made the sound work. I could listen to it through the speakers, and record it.

Two problems remained. The first: I use the green output with the speakers. If I want to use the headphones instead, I have to disconnect the speakers, or buy an adapter to plug them in at the same time. There's also a black output, although I still haven't found out how to use it, other than playing WAVE sound files.

The second problem has plagued me as long as I have been an OS/2 user. Most of the time, but not always (perhaps due to the wind direction, the atmospheric pressure, the solar activity, the relative position of the planets, who knows?), the speaker sound dies as soon as a WAVE sound file has been played, and I have to set the mixer values again. The sound files somehow act as an on/off gate for all sounds. I even dumped MMOS2 and installed the CW-Multimedia classes instead, but the problem remains. The mixer values that have to be reset are:

Control ID: 59, Name: [PCM Playback Switch], value 1: 1
Control ID: 60, Name: [PCM Playback Volume], value 1: 28, value 2: 28

Computer Software

Now, I had digital sound available from the DAB tuner (and the stereo DVD player if I wanted to), so I could start recording, right? Not really. There are two native (or naïve) solutions for audio recording and editing: the OS/2 Audio Editor, and Ceres Sound Studio. As many people have discovered, both are abandonware, and usually won't work for audio files bigger than x MBytes. A one hour recording would create about 600 MiByte, which is big in this context. The applications will just hang and crash until you give up and look at a better solution.


Fig.2: Digital Tape Recorder working

For the recording, a good application is Digital Tape Recorder by Paul Ratcliffe. There's a review in the VOICE Newsletter April 2001 and it's now in version 1.0 beta 10. The picture shows a recording to the file dab48-3.WAV after 64 minutes. No problem with the file size here! You can set the recorder to 48 000 Hz, 16 bits, since that's what the sound card puts out. It's good for MP3 encoding. If you are sure you want to create an audio CD only, you can set it to 44 100 Hz, since you'll have to convert sooner or later. I'm not sure what's best for the final quality, but I suspect doing the conversion later using sox (see below) is the best option.

Editing

So I had a WAVE file that I called dab_fasching_1_48.WAV (dab48-3.wav on the image, changed to a more descriptive name) of about 700 MiByte, and I wanted to edit it, perhaps to several tracks, or at least get rid of interruptions and stuff at the beginning and the end. I seemed out of luck, since the two mentioned applications are the only audio editors for OS/2.

Audacity

Following a tip from USENET, I found "Audacity: A Free, Cross-Platform Digital Audio Editor". It is indeed cross-platform, although there's no OS/2 version. Instead, I got the win32 version, that comes in a ZIP package. It works using Odin 20020627 (the version that works with RealPlayer).


Fig.3: Audacity with loaded file

I start Audacity, do File - Open - dab_fasching_1_48.WAV. It takes about two minutes to load, and I get this image. I can listen to the file, but there's no marker and no digits showing where I am. Often, a window is shown with the text "handle being used simultaneously on another thread". This means that I can't use Audacity as is for editing. Perhaps I could with another Odin version and some research, or if someone would create a native Audacity version.

Playrec

Carsten Arnold (http://www.ca-arnold.de/) has a command-line program for playing and recording WAVE files: PlayRec version 0.17.

The process is well described in VOICE Newsletter June 2002. It's about recording LPs, but the process is similar. The program versions remain the same too. I could as well use Digital Tape Recorder to listen to the songs, but PlayRec has better precision than one second if you need it.

I start PlayRec from a command prompt with

playrec dab_fasching_1_48.WAV


Fig.4: PlayRec playing

I pause when the first song is finished, just before the speaker starts to speak, at 00:02:18.


Fig.5: PlayRec pause

I can move backwards and forwards until I find the exact location for the break. I make a note what the time is. Next stop is when the next song starts, at 00:02:40. I repeat until the whole recording is done.

CopyWave

Carsten Arnold also has a command-line program for copying WAVE files: CopyWave version 1.14. Using the information I gathered from playing the WAVE file, I copy the tracks one by one. At the command prompt:

copywave dab_fasching_1_48.WAV dab_fasching_1_48_1.WAV /st:00:00:00 /et:00:02:18


Fig.6: CopyWave working

To avoid some of the work, I created an 1-2-3 file to format the commands.


Fig.7: The 1-2-3 worksheet

Cell C6:

@LEFT($B$3;@LENGTH($B$3)-4)&"_"&@STRING(@ROW(A1..A1);10002)&".WAV"

Cell D6:

+$B$1&" "&$B$3&" "&C6&" /st:"&A6&" /et:"&B6

Cell E6:

+"\sox\sox "&C6&" -r 44100 "&@REPLACE(C6;@FIND("48";C6;1);2;"441")&" resample"

sox - Sound eXchange : universal sound sample translator

I also have to convert the files to 44 100 Hz since they were recorded with 48 000 Hz. Of course, I could have done the recording directly from the soundcard at 44 100 Hz, but as mentioned, the soundcard's output is 48 000 Hz, so conversion has to be done anyway, and 48 000 Hz recording is better as first take.

For conversion, I use the program sox 12.17.1. It's available from the Hobbes archive, http://hobbes.nmsu.edu/cgi-bin/h-browse?sh=1&dir=/pub/os2/apps/mmedia/sound/convert. Homepage is http://sox.sourceforge.net/.

This is the conversion command I use, meaning copy the file to a new file with the rate 44 100 Hz and resample. I include the sample rates in the file names too.

sox dab_fasching_1_48_1.WAV -r 44100 dab_fasching_1_441_1.WAV resample

There are many options to do the conversion. Check the documentation or the many discussions on USENET.

When everything song is converted, then it's all set to create the Audio CD using RSJ CD Writer.


Fig.8: RSJ recording

LAME MP3 Encoding

Having the recording in MP3 format may be convenient, so I'll shortly describe how I do it.

If I had access to the MP2 stream as mentioned above, I could have used it directly in a MP3 player, due to the compatibility. Possibly I would have to give the files the MP3 suffix to force the player to understand them!

I don't have this access, so I have to (re)encode the WAVE files to MP3, using some of the many tools available. This is a good reason to do the original recording in 48 000 Hz, since an MP3 encoder can read that frequency, and I skip an unnecessary conversion.

Have a look at the article "Keeping up with the Gates - MP3 encoding under OS/2" in VOICE Newsletter February 2002.

As mentioned, there are a few encoders available. I used LAME version 3.94 MMX beta 1. The reason for the choice was that there was a very recent version available. It can be found at the Hobbes archive, and home page is http://lame.sourceforge.net/.

This command encodes the first track to 128 kbit/s. It mainly uses default values. I have an Athlon processor, so I use that variant of LAME.

lame -h dab_fasching_1_48_1.WAV dab_fasching_1_128_1.mp3


Fig.8: LAME

Note: all prices mentioned are converted to € from the original currency.

References:

MPEG info: http://www.iso.ch/iso/en/prods-services/popstds/mpeg.html
MPEG info: http://www.chiariglione.org/mpeg/
DAB: http://www.worlddab.org/
rec.audio.pro FAQ: http://www.vex.net/~pcook/RecAudioPro/digital.html#Q5.6
DAB discussion: news://alt.radio.digital/
dtape review: http://www.os2voice.org/VNL/past_issues/VNL0401H/vnewsf7.htm
Carsten Arnold's home page: http://www.ca-arnold.de/
Recording LPs with playrec and copywave: http://www.os2voice.org/VNL/past_issues/VNL0602H/vnewsf6.htm
sox for OS/2: http://hobbes.nmsu.edu/cgi-bin/h-browse?sh=1&dir=/pub/os2/apps/mmedia/sound/convert
sox home page: http://sox.sourceforge.net/
Keeping up with the Gates - MP3 recording under OS/2: http://www.os2voice.org/VNL/past_issues/VNL0202H/vnewsf5.htm
LAME home page: http://lame.sourceforge.net/


Feature Index
editor@os2voice.org
< Previous Page | Newsletter Index | Next Page >
VOICE Home Page: http://www.os2voice.org