WAV Noise Shaping
=================

Version 0.20

This version does a simple 1st order noise shaping process to
generate a 16bit LPCM wave file from a given 24bit LPCM
source file.


Before use
==========

Before you can use the !WAV_NoiseShaping application you should
edit the "settings" file inside the application directory.

This contains two lines. As supplied these will be something like:


SCSI::SSD.$.CD_tracks.wav_in
SCSI::SSD.$.CD_tracks.wav_out


The first line is the full pathname for the location where the application
will look for input 24 bit LPCM wave files.

The second line is the full pathname for the location where the application
will generate the output 16 bit versions it creates.

So before you use the program, edit the file to specify the locations
you wish to use for the input and output files.

The application should work then provided that the input file:
  
  1) Has a sample rate that isn't greater than 384k samples/sec.
  
  2) Has 24bit LPCM samples.
  
  3) Is stereo
  
  4) Has the basic standard 44-byte Wave file header with *no*
     extra header chunks for other purposes. i.e. it can't cope
     with 'tagged' files or extra metadata.



Purpose
=======

The purpose of the application is to allow you to create 16bit versions
of LPCM wave files from 24bit ones by using a simple 'Noise Shaping'
process. The sample rate of the result is the same as that of the
source file. The advantage of Noise Shaping is that - particularly for
files with high sample rates - the result will usually have a better
resolution than simply truncating (even with dither) from 24bit to 16bit.

At present the RISC OS operating system can't cope with 24bit sample
values. So 24bit files either fail to play, or will be truncated to
16bit. That may mean a *worse* sound than is possible for a genuine 16bit
file! Noise Shaping can therefore mean you are able to get a result
which is better when played.

The amount of improvement offerred by using Noise Shaping rather than
plain truncation (with dither) tends to scale with the sample rate.
i.e. It probably will only help a little if you use this program
on 44.1k/48k 24bit source material. It should be beneficial for 96k rate
material, and even more beneficial for 192k rate material. However
in practice what you get may end up being limited by the quality of
the input at whatever rate!

You may also find that a FLAC file of the Noise Shaped 16bit version
is considerably smaller than one of 24bit version. This is because in reality
almost all real-world 24bit audio recordings waste many bits over-specifying
the background noise. 


Using the application
=====================

To use the !WAV_NoiseShaping application you can run it in the usual way by
double-clicking on the application's icon. It will then open a TaskWindow
and display the input and output directories it expects to use. It then asks
you for the name of the input file in the input directory. 

Type this in and press return.

The output file should then be generated and placed into the specified
output directory. Note that this will be approximately 2/3rds of the size
of the input file and will have its file name prefixed by "ns_".

As the content is processed the program will report how far it has got
by giving the amount done in seconds of audio.

Note that some audio recordings may have sample values that reach right 
up to the clipping maximum. That can mean that the output can't be
dithered and Noise Shaped with full accuracy. If this occurs the clipping
will be reported in the TaskWindow and the number of bits (16bit resolution)
of any possible overload that has been clipped will be reported.

With high quality audio recordings the sample values in the 24 bit source
material should never get this close to clipping because it means any
following processing (including in the DAC used to render the recording
into an analogue output) may clip. However, sadly, in reality many
professional recordings are clipped or adjusted to the max and can
lead to such problems. However if the clipping is only reported to be
at a level of 1 or 2 bits the change produced by the Noise Shaping is
likely to be minor compared to the effect when the 24 bit file is
rendered by a DAC anyway.


You are welcome to re-use the source code of this application as and
how you wish. There is no warranty. Use at your own risk. If using this
program causes your hair to fall out or your cat to die laughing, that's
your responsibility, not mine. :-)

But with luck, you may find the results enjoyable and interesting.

Jim Lesurf
17 Feb 2017
