Using Gtk Wave Cleaner to record and clean up your old vinyl music

## An important note on GWC editing

GWC commits all changes to the original file instantly, and saves the deltas needed for undo to get back to the original, so on exit all your changes are already saved. When you exit (or open a new file) GWC will notify you that changes have been made, and give you the chance to undo them all.

# Creating your wavfiles

- CLEAN YOUR RECORD AS WELL AS POSSIBLE!! The safest method is to use distilled water, and spray it on with a perfectly clean spray bottle. Let it sit for a few minutes and then wipe it off with clean, soft, pure cotton cloth. Don't do this on the turntable itself, lay the record on a soft cloth on top of a firm flat surface. Any lint that gets on the record from the cloth will come off easily with your regular record duster that you will apply while the record is on the turntable and spinning. There are plenty of places on the internet that have suggestions for how to clean LPs. The other thing to try is to play the LP once before you copy it to disk, the action of the needle in the groove may be able to dislodge more remaining particles.

- Make sure you stop any programs or processes which use a lot of cpu or memory, or intensive disk access !!
  Otherwise your recording software may fail to record some parts of the audio, without telling you there has been a problem !!

- Record your track(s). I now use a tool like brec for OSS and arec for ALSA, and record a number of tracks (i.e. one entire side of an LP) at once. Because GWC can handle extremely large audio files, it is more convenient to work with one single file. With cdrdao you can even burn CDs using only one audio file for all the tracks. Be sure to get some "silent" audio at the start of each recording, this information is used by GWC to assess the background noise level for noise elimination.

- If you try to open a wav file created by software such as a recent ffmpeg, GWC will produce an error like this: "Failed to open /root/whistle.wav, 'Error : Cannot open file in read/write mode due to string data in header.'". Libsndfile does not support RDWR mode for these files - one workaround is to open and save the file in mhwaveedit. Or if you are creating the files using ffmpeg try adding "-flags bitexact" into your command line (although this will reduce ffmpeg's performance), or writing to a different libsndfile supported format such as au or aiff.

# Selecting audio

- To select sections of audio for GWC to operate on you click and drag in the displayed audio waveform.

- Start dragging anywhere between the centers of the left and right channels to select both channels, or start dragging above or below this region to select just one channel.
- If you do not make a selection GWC will operate on all the audio in the current view, but note that if you have clicked in the top or bottom quarter of the waveform it will only operate on the left or right channel.

- Use edit markers to help you navigate and select sections of audio. There are 200 markers available. You set them by using the "B" and "E" keys, and clear them using the "Markers>Clear markers" menu item. "B" toggles the first marker at the start of the currently selected region. "E" toggles the second marker at the end of the currently selected region.

- When you select a region within 10 pixels of either an edit marker or a song marker, it will "snap" to that marker. This allows you to zoom in to a portion of the audio data, set a marker, zoom and pan to another portion, set another marker, and then zoom back out and select the region between the markers -- giving you a fine level of control on the precision of the selected region.

- You may also press the 'm' key, to automatically select the region between edit markers. A button and icon are in the works...

# Unselecting audio

- To clear the selection click in the displayed audio waveform without dragging. Any subsequent cleaning operations will be applied to all the audio in the current view, but note that if you click anywhere between the centers of the left and right channels any subsequent cleaning operations will be applied to both channels; if you click above or below this area they will be applied to only the left or right channel.

# Steps to restore audio quality

- ## Denoise

  ##

- Select a sample region which is entirely free of music.

- If you have a "clean" LP, (i.e. almost no crackle in the "silent" region) you may use the declicker in the silent region to remove a few clicks, but make sure the result doesn't sound goofy.

- Press the sample noise button (the one with the eyedropper).

- If you do not have a good noise sample and cannot splice one in from another recording you can use Generate pink noise to overwrite a selected region with pink and or white noise, which is a good approximation for hiss. You can then use this for your noise sample.

- Now select and test denoising on a couple of different areas on the audio file, just to be sure it works. Take the defaults of:

FFT Size=4096
reduction=0.5
smoothness=11
number of samples=16
gamma=0.95
Windowing Function=Hanning-overlap-add
Noise Suppresion Method=Lorber & Hoeldrich

- Try denoising a few seconds at the start of the track (include some of the pre-track noise section to see how well the denoise algorithm works on pure noise). Play the denoised region, see if you like it. Now do an Edit->Undo (Ctrl-Z)
  Repeat the above process at the end of the track and somewhere in the middle. This gives you a good idea of how the noise sample at the start of the track will work as an estimate of the actual noise at the middle and end of the track.
  If you find the result sounds "metallic" or "burbly", back off on the reduction amount, remember to use Edit->Undo (Ctrl-Z). You can also try varying the gamma factor. I have found if it gets too close to 1.0, it can distort the final sound a little. Anything between 0.5 and 0.99 is probably worth trying.

- When you are satisfied you have the settings you want, go for the gold and select the entire track and denoise the whole thing. In most cases the defaults given above will work quite well, so don't think this is hard, it's really easy! At this point you may skip saving the undo data, which for most songs is tens of megabytes and will take some time to save.

- ## Declicking

- There are 3 levels of declicking:

1. Declick-strong - searches for and repairs the loudest clicks.

2. Declick-weak - searches for and repairs weaker clicks.

3. Declick-manual - If both of the above methods failed to repair a click, you can zoom in on the click by listening, highlighting, zooming in on the selection as described above. Then, making sure you have only the damaged portion of the audio data selected (in most cases this will be less than 100 samples), push this button, and it repairs the highlighted selection (or current view) -- don't use on more than about 200 samples!

- In general you should start with Declick-strong, followed by Declick-weak, and use Declick-manual as a last resort.

- The highest quality declicking is done "manually". I have had cases where automatic declicking has a "false positive", and inadvertently degrades the signal in a few places. I do manual declicking by either going to spectrogram view (View>Spectral View), and looking for spikes which show up as bright lines, or just listening and highlighting an area around where I hear the click. There is no better click detector than your ears! I have found for a window which is 600 pixels wide, about 22050 samples (about 1/2 second at the 44100 Hz sample rate, which is CD quality...) displayed in the spectrogram view works quite well.

- There is an optional FFT click detector implemented now. The settings are the dB above average that the click amplitude must be in order to be marked and or fixed. Humans generally can detect a 3 dB change, so that's the default level for weak click detection. While the FFT click detector appears to work better than the old click detector, it is only based on some limited observations of mine, so this is not always the case. It is also MUCH SLOWER.

- <HINT> - use the spacebar to start and stop playback!!!
  left hand on spacebar, right hand on mouse - very efficient.
  You can get a good idea where the click is by watching where the cursor is when you hear the click</HINT>

- If you hit the "s" key during playback, GWC will stop the playback and highlight the last 1/2 second of audio played

- ## Decrackling

- Recordings from very dirty or damaged vinyl may have thousands of small "clicks" per second, which sounds like bacon frying. First try to remove this with the decrackling algorithm. Use the default settings in preferences.

- Decrackling will also attenuate the high frequencies somewhat.

- If decrackling fails, I have sometimes had success by repeatedly applying the "remove strong clicks" filter over an area until the reported repairs is zero.

- ## Estimating

  Sometimes, there are large sections in the audio (200 to 8000 samples) that are just bad. It may sound like a "thunk" or a dropout. The estimation repair looks at the frequencies to the left and right of the selection (or current view), and blends those frequencies across the repair area. The result will be better than what was there to begin with, as of version 0.20-08 this works quite well, but remember, UNDO is your friend!

- ## Finishing up

  - You may want to look at the reverb and DSP filters if the audio needs a little bit of "presence". Reverb uses the TAP Reverb software to apply reverberation, and ~/.reverbed will override the built-in list of reverb settings, if it exists. For this application, I recommend your wet levels be very small, try -30 Db for wet, -1 Db for Dry, and 1500 ms with the "Ambience (Thick) - HD" Reverb setting. TODO: explain DSP Frequency Filters

  - Eliminate blank portions at start and end of track -- highlight the area at the start of the track and use the scissors icon to indicate you want that deleted, do the same for the end of the track. You can't eliminate sections in the middle of the track. Umm, I haven't tested what would happen if you tried, it could be bad. Always back up your data :-)

  - You can use the functions in the File menu to split your wav file into separate tracks, export a selection as wav, ogg or mp3, or create a TOC file to use with cdrdao (Do an internet search for more info on that great program).

  - For TOC files and splitting you must insert song markers to identify the songs - "Markers>Detect songs" can usually do this automatically.

  - Exit. -- GWC will ask if you really want to save your changes.

  - I wrote a little utility -- wavlist, which will list the *.wav files and append the time in minutes:sec to the list so you can use it with something like gcover to create jewel case covers.

# Changing keyboard shortcuts:

Most keyboard shortcuts (i.e. not the hard-coded ones listed below) can be changed if this is enabled in your gtk configuration - refer to the included gtkrc-example.txt for this and other useful options.

The shortcut keys are saved to ~/.config/gtk-wave-cleaner/accels

# Keyboard shortcuts for hidden features:

- spacebar - start and stop playback
- 'a' - Create or append "cdrdao.toc", with the currently selected (or viewed) audio segment
- 'u' - increase the scale on audio display
- 'd' - decrease the scale on audio display
- 'r' - reset the scale on audio display to 1.0
- 's' - stop playback, and automatically highlight last 1/2 second of audio played
- '2' - when zoomed in, go back by one revolution of a 33 1/3 rpm record
- '3' - when zoomed in, go foward by one revolution of a 33 1/3 rpm record
- TODO: there are more hidden away in gwc.c, but we should give them all menu entries so the shortcuts are user configurable

# Settings

- Declick
  - Weak Declick Sensitivity - Set this to something greater than 1 (1.5 is the largest you should try) to detect even weaker clicks (but you will get more "false positives"), set it lower to detect a little bit stronger clicks.
  - Strong Declick Sensitivity - This takes the value 0.75 by default. Lower values will only detect stronger clicks, higher values will detect weaker clicks.
  - FFT Weak Declick Sensitivity - Set this to something greater than 2 to detect even weaker clicks (but you will get more "false positives"), set it higher to detect a little bit stronger clicks.
  - FFT Strong Declick Sensitivity - This takes the value 5 by default. Lower values will only detect stronger clicks, higher values will detect weaker clicks.
  - Use FFT click detector - Check this box to use FFT click detection. It appears to generate fewer false positives and fewer false negatives, based on limited testing.
- Iterate in repair clicks until all repaired - The click detection algorithm compares each candidate click against the overall sound profile in the general region of the candidate click. If the click "looks" a lot like the other sound energy (for example a cymbal crash contains a lot of the same frequencies as a click), then the candidate is ignored. But, sometimes a stronger click may mask out a weaker click because of this comparison process. So, this option causes the click detector to run on a region of the audio after any click is repaired, to re-check for more possible clicks in the absence of those clicks that were repaired. The iterate function does not yet work for FFT click detection/removal

- Decrackle -
  - Decrackle level -
  - Decrackling window -
  - Decrackling average window -
- Denoise
  - FFT_SIZE - You have to think about this standing on your head. (Took me a while at least). Since the samples are say, 1/44100 of a second apart, the highest frequency detectable by the FFT will always be 1/22050 of a second, regardless of the fft window size. A larger and larger fft window size allows you to detect lower and lower frequencies, and to get more of an "averaging" effect of the higher frequencies which are present in the fft window.
  - Reduction - The amount of noise you want removed from the audio, as a proportion. If you use 1.0, then all noise is removed, but unfortunately you get nasty artifacts in the resulting audio, it may get burbly or metallic sounding. In general, you should set this value as low as possible (0.3 for Blackman window, 0.5 for others), and test a few spots in the audio file (remembering to "undo" each test!!!).
  - Smoothness - For the Blackman window, it determines how the windowing function "steps along" the audio file. In general, this should be set between 5 and 11, usually just leave this at 11
  - # noise samples - The denoise algorithm sub-samples the audio data you marked for "sampling". Because noise varies from one millisecond to the next, GWC will take many sub-samples and take the "average" noise signature from those sub-samples. You should usually just leave this at 16. Don't worry if the (number of noise samples)*FFT_SIZE is greater than the sample area, GWC will just overlap the sub-samples.
  - gamma - The Ephraim-Malah and Lorber-Hoeldrich noise reduction algorithms attempt to reduce the metallic sounding artifact in denoising by holding the noise removal process very constant from one window frame to the next. Gamma is the parameter that controls this, if you set it to 0, you essentially get Weiner noise reduction on every frame, set it close to 1, and you get some weird sounding stuff. Setting it in the range of 0.5 to 0.95 usually is pretty good. Play around with this and the reduction amount if you have that metallic sound after denoising.
  - Windowing Function NEED SOME PICTURES HERE
    - Blackman - Try this second
    - Hybrid Blackman-Full Pass - Fastest, may work well for relatively "clean" audio files with only a little hiss.
    - Hanning-overlap-add - Usually, this is the one you want.
  - Noise Suppression Method
    - Weiner - A little better than Power Spectral Subtraction.
    - Power Spectral Subtraction - Crudest.
    - Ephram-Malah 1984 - Pretty darn good.
    - Lorber & Hoeldrich - Large improvement over Ephram-Malah.
- MP3 settings
  - A bunch 'o settings here -
- OGG settings
  - A bunch 'o settings here -
- Miscellaneous
  - Seconds of audio preselected when "s" key is struck -
  - Seconds of audio preselected when "n" key is struck -
  - Normalize values for declick, denoise? - The normalize option asks libsndfile to normalize the audio data on the interval -1.0 to 1.0, it appears to make no difference, and is really only there for testing. Set to 1 for normalization, 0 for non-normalized data.
  - Silence estimate in seconds for marking songs -
  - Log frequency in spectrogram -