Audacity & Processing existing NBTV files...

A "new fashioned" televisor, using an Arduino to drive the motor and display.

Moderators: Dave Moll, Andrew Davie, Steve Anderson

Audacity & Processing existing NBTV files...

Postby Andrew Davie » Sun Apr 16, 2017 3:38 am

I've settled on my own '8-bit' format for storage of NBTV files on the Micro SD card in my televisor. Although I haven't yet tested the sound, I'm going to cross that bridge when I come to it - for now, at least, I'm pretty certain that I want my video to be 8-bit unsigned, with NO synch "pulses". Since I want to be able to play existing NBTV tracks, I pretty much need to be able to convert from the club standard format to my internal format, not just convert new tracks from video source. I am doing it manually at the moment, and I thought I'd take a few minutes to write the process down.

My "standard" is as follows...
* 8-bit video left-channel. 0-255 range. 8-bit audio right-channel.
* 19200Hz (this gives 32 scanlines of 48 pixels)
* synch bits NOT present in the video data - they are inferred from the sample # in the file

The task, then, is to convert a typical NBTV WAV file into the above format, using Audacity. Install it!
Next, we need to install a plugin that's going to allow us to do 'DC-offsets' to the video track. Place the DC-Offset tool file in the Audacity plugins folder, and restart Audacity.

You will need to install a plugin to audacity to perform the DC-offset step in the instructions below. Grab it from http://forum.audacityteam.org/viewtopic.php?f=42&t=68463

Just dot-points for now...
  • Load NBTV format WAV file. It's likely to be a CD-format file with 44100Hz frequency
  • Set the project rate to 19200Hz in the bottom left area. Audacity has an insane remapping of some number keys to different things, so you can't type in numbers in there unless you either cut/paste '19200' from somewhere, or remove the idiotic key mapping. To do the latter, delete whatever is assigned to '1' in preferences/keyboard.
  • We should see two waveforms on the screen - left track (video) on top, and right-track (audio) on bottom. First thing is to resample to 19200Hz - select Tracks/Resample and type in 19200.
  • Next we want to split the tracks so we can process the video separately. There's a little black down-arrow/triangle in the top left of the track window area. Select that, and then 'Split Stero to Mono'
  • Make sure the top (video) track is highlighted - should have a yellow border around the entire. It is probably displaying a smallish (in height) waveform about halfway up (i.e,. with its base somewhere near 0). We have to do some manipulation to get rid of the synch pulses, and then to 'stretch' it to use the full range. Although it's a signed waveform (having positive and negative values) in audacity, when we output to an 8-bit WAV file, the values become unsigned (with 0 at the bottom). So we'r going to have to do some manipulation to make that happen.
  • Zoom in (use the magnifying + for horizontal, and drag the bottom of the yellow-bordered area for vertical) and determine the amount of DC offset (if any) you need to apply to have the synch pulses negative and the video data positive.
  • Now the DC-offset tool applies to all the tracks, and we don't want our audio track to change. So, double-click the audio (bottom) track, and hit command-c or menu/copy or Ctrl-C whatever floats your boat to copy it to the clipboard. We're just copying it so we can put it back in a sec... but for now we need to DELETE the track. Mark it again and press the delete key. Or, we could have used "cut" (Ctrl-X or Command-X) in the earlier step. In any case, we want it blank but held in our clipboard.
  • Select "effect/DC offset" and change the drop-boxes to "add offset" and "absolute" and then set the value to the amount you determined a couple of steps back. For example, to shift the whole track downwards by 0.1 you enter -0.1 into the offset box. Hit OK.
  • OK, so we've just manipulated the video track so that the synch pulses are negative, and the rest of the 'video' is positive. We've also buggered the audio track, but it's safely in our clipboard, so all OK. Time to clip off the negative values. Click on the video (upper) track, and then select "Effect/Nyquist prompt". Tick the box "use legacy syntax" and then in the entry area put "(s-max s 0)" without the quotes. Click OK.
  • Now we're going to "expand" the video so that it uses the full range of available values when it's represented as 8-bit unsigned. We need to do another offset first, so that half of the range of the video is positive, and half is negative. I eyeball this, and in the one I'm looking at now, the highest value is at about 0.5. So, for your example, find this, and subtract half of it using the "effect/DC offset". In my case I'm using -0.25.
  • Now it's time to amplify the track so that the upper ranges of the values are at the extremes (-1 and +1) of the available range. Choose "effects/amplify" and the default amplifaction should be the maximum without clipping. Should be OK to choose that value, but if you want more you will need to set "enable clipping" on the dialog box. You can undo (Command-Z or Ctrl-Z) if you get this wrong and want to try a different value. Once you're done, the waveform should occupy the whole height of the window it's in. Now we're getting somewhere.
  • So let's put back our saved audio track... double-click the audio track again, and paste (command-v or Ctrl-V or menu/paste) the clipboard. It should jump back to what it was before. Bango!
  • We need to recombine the tracks - in fact we choose that little black triangle droplist again and choose "make stereo rack".
  • Time to export. Select "file/export audio". We change the format droplist at the bottom to "other uncompressed files" and then click on the "options" button. Choose "WAV (Microsoft)" for the header, and "unsigned 8-bit PCM" for the encoding. Click OK. Now type your filename in the "save as" entry area, select the detination directory and then "save". I'm going to start using .nbtv8.wav as for my file naming, to make it clear what format they are. For example, "test.nbtv8.wav"

If all that worked, then you have just convered an existing NBTV WAV file into my "8-bit" format and it will pretty much look like the original when being played. However, it's now 19200Hz instead of 44100Hz - and 8-bit audio/video instead of 16-bit so will be roughly 20% of the size.
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: Audacity & Processing existing NBTV files...

Postby Andrew Davie » Sun Apr 16, 2017 4:54 pm

It seems that some NBTV files are AC-coupled - that is, they do not have a constant "position" for "zero". In these cases (e.g,. track 30 of the club test pattern CD) I have absolutely no idea how to use Audacity to convert to my format. In my opinion right now, AC-coupling is a pain in the butt!
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: Audacity & Processing existing NBTV files...

Postby Steve Anderson » Sun Apr 16, 2017 5:17 pm

I think you'll find that 99% of NBTV source video files are AC coupled. Even if DC-coupled on the disc/whatever, if the source is designed for audio it more than likely be AC coupled. There is no requirement in audio for DC coupling. This has been the headache of NBTV since day one and still is. This also applies to the recording of NBTV signals. If the equipment used is designed for audio it's bound to be AC coupled.

The signal requires DC restoration. In the 'Handbook' section (or is it the Club Shop) on the NBTV web-site there's details of Klaas's DC restorer/clamp.

This could be done in software, I did have a bash at it a few years ago and it was moderately successful, it still needed some tweaking though.

Some software have 'software capacitors' within them to eliminate any DC offset in the source material when recording. Your soundcard is likely to be AC coupled too.

I might add that this equally applies to 525/625 television, but with the frequencies involved it's easier.

Steve A.
User avatar
Steve Anderson
"Fester! Don't do that to 'Thing'"
 
Posts: 5361
Joined: Fri Mar 30, 2007 10:54 pm
Location: Bangkok, Thailand

Re: Audacity & Processing existing NBTV files...

Postby Andrew Davie » Tue Apr 18, 2017 12:32 am

For those curious, here is a snippet of the 8-bit sound conversion of the Doctor Who episode I use as a test. I just copied the 8-bit sound to both channels so you can listen to it through a set of headphones. I'm happy enough with this quality - to me this is perfectly ok quality for a televisor.

completelyMad.8bit.wav
(504.86 KiB) Downloaded 432 times
User avatar
Andrew Davie
"Gomez!", "Oh Morticia."
 
Posts: 1590
Joined: Wed Jan 24, 2007 4:42 pm
Location: Queensland, Australia

Re: Audacity & Processing existing NBTV files...

Postby Steve Anderson » Tue Apr 18, 2017 5:05 pm

Yep, sounds OK to me for speech and sound effects where the levels are tightly controlled as most productions for TV are. Movies generally have a much higher dynamic range so the quieter sequences might get lost in the dirt (noise/quantization). A rule of thumb is noise and distortion can be approximated by multiplying the number of bits by 6db and adding 2db more. 8-bits results in a distortion of -50db, approx. 0.3% at full-scale. It gets progressively worse as the signal level drops.

16-bit yields the familiar figures for an audio CD of -98db, 0.00125%...assuming perfect A-D and D-A processing.

Steve A.
User avatar
Steve Anderson
"Fester! Don't do that to 'Thing'"
 
Posts: 5361
Joined: Fri Mar 30, 2007 10:54 pm
Location: Bangkok, Thailand


Return to Andrew Davie's Arduino Televisor

Who is online

Users browsing this forum: No registered users and 1 guest

cron