| 1 |
<html> |
| 2 |
<head> |
| 3 |
<title>HivelyTracker Documentation</title> |
| 4 |
</head> |
| 5 |
<body> |
| 6 |
<h1>Mixing Notes</h1> |
| 7 |
I have decided to include a very full description of sound, sound reproduction, |
| 8 |
how sound is generated digitally, and how digital audio is mixed, so that people |
| 9 |
can gain a full understanding of digital audio mixing in general, and HivelyTrackers |
| 10 |
"mix gain" and "autogain" features specifically. It starts off really basic, as in |
| 11 |
school science class, so most people will probably want to skip to the last parts.<br /> |
| 12 |
<br /> |
| 13 |
<h1>1. Sound and sound reproduction</h1> |
| 14 |
Sound is the compression and decompression of air, which creates a "sound wave". As |
| 15 |
a sound wave passes a point in space, the pressure of the air at this point |
| 16 |
fluctuates. This is detected by small hairs in our ears that move in reaction to |
| 17 |
this tiny fluctuation in air pressure.<br /> |
| 18 |
<br /> |
| 19 |
Speakers create sound waves by moving a cone back and forth. When the cone moves |
| 20 |
forwards, it pushes the air infront of it forwards, creating a slightly higher |
| 21 |
pressure in the air immediately in front of it. This high pressure area dissipates |
| 22 |
into the surrounding atmosphere as a sound wave. Similarily, when the cone moves |
| 23 |
backwards, it creates a low pressure wave in front of the cone. If you move the cone |
| 24 |
forwards and back at a steady rate, it creates a regular pattern of pressure moving |
| 25 |
through the room. If the speaker is moving back and forth at a constant rate between |
| 26 |
20 times a second and 20000 times a second, it creates a tone within the audible |
| 27 |
spectrum (IE it can be heard by humans as a constant tone).<br /> |
| 28 |
<br /> |
| 29 |
Sound waves are communicated to the speakers as a voltage. If the voltage across |
| 30 |
the speaker terminals is constant, the speaker will be held at a constant position |
| 31 |
(and you will hear silence since there are no pressure changes occuring). If you |
| 32 |
increase the voltage across the terminals, the speaker cone will move one way. If |
| 33 |
you reduce the voltage, the cone will move the other way. So, fluctuations in air |
| 34 |
pressure are represented as fluctuations in voltage across the speaker terminals.<br /> |
| 35 |
<br /> |
| 36 |
<h1>2. How computers create sound</h1> |
| 37 |
Sound is stored and processed inside the computer as a list of numbers. Each number |
| 38 |
corresponds to a position for the speaker cone. An eight bit sample uses one byte |
| 39 |
per speaker position. A signed byte contains a number from -128 to 127. -128 might |
| 40 |
mean that the speaker should be pulled fully back, and 127 might mean push it fully |
| 41 |
forwards. The computer sends a sequence of these numbers through a digital to |
| 42 |
analogue converter which turns them into a voltage, which is amplified and passed |
| 43 |
to the speakers. The speed at which the computer sends numbers to the digital to |
| 44 |
analogue converter is the sample rate. A 44.1Khz sample sends 44100 samples to each |
| 45 |
speaker every second.<br /> |
| 46 |
<br /> |
| 47 |
If you sent a sine wave to an 8-bit channel, with the peak values of 127 and -128, |
| 48 |
with a wavelength of 1/440th of a second, you'd hear a loud tone at A-4. It would be |
| 49 |
loud because the speaker is moving as far as possible (-127 to 128), and it would be |
| 50 |
"A-4" because the frequency for A4 is 440Hz. On a graph, the signal looks like this:<br /> |
| 51 |
<br /> |
| 52 |
<center><img src="images/wave01.png"></center><br /> |
| 53 |
<br /> |
| 54 |
<h1>3. Mixing sound</h1> |
| 55 |
So, each speaker is sent a sequence of numbers representing a sound wave. But each |
| 56 |
channel can only take one sequence of numbers; what if we want to play more than one |
| 57 |
sounds at the same time in the same channel? We need to combine the sounds. All you |
| 58 |
have to do is add the two signals together. Imagine we want to play a sine wave at |
| 59 |
440Hz and another one at 880Hz at the same time. If they are at maximum volume, |
| 60 |
it would look like this:<br /><br /> |
| 61 |
<center> |
| 62 |
<img src="images/wave01.png"><br /> |
| 63 |
<h1>+</h1><br /> |
| 64 |
<img src="images/wave02.png"><br /> |
| 65 |
<h1>=</h1><br /> |
| 66 |
<img src="images/wave03.png"><br /> |
| 67 |
</center><br /> |
| 68 |
But theres a problem! The resulting wave has numbers greater than 127, and smaller |
| 69 |
than -128. These numbers don't fit into the limits of the sound channel, and so |
| 70 |
the wave is clipped (the flat lines at the top and bottom). The solution is to half |
| 71 |
the volume of the source waveforms:<br /><br /> |
| 72 |
<center> |
| 73 |
<img src="images/wave04.png"><br /> |
| 74 |
<h1>+</h1><br /> |
| 75 |
<img src="images/wave05.png"><br /> |
| 76 |
<h1>=</h1><br /> |
| 77 |
<img src="images/wave06.png"><br /> |
| 78 |
</center><br /> |
| 79 |
This works great! But there are a couple of downsides. Firstly, each individual sound is now |
| 80 |
half the volume. Secondly, each sample is effectively a 7bit sample instead of an |
| 81 |
8bit sample, so its quality isn't as good.<br /> |
| 82 |
<br /> |
| 83 |
<h1>4. What does this mean for HivelyTracker?</h1> |
| 84 |
HivelyTracker modules can have up to multiple 16 channels. The simplest way to have |
| 85 |
16 channels is to add the sample data for each channel and divide by the number of |
| 86 |
channels. The problem is, each extra channel you use degrades the overall sample |
| 87 |
quality, and makes each channel quieter. Also, not all channels are going to be at |
| 88 |
maximum volume all the time, so it may be possible to keep the channels slightly |
| 89 |
louder before mixing. How much louder depends on the module.<br /> |
| 90 |
<br /> |
| 91 |
Instead of this method, Hively gives you a "Mix Gain" control, to manually set the |
| 92 |
volume of the channels when mixing. At "100", it keeps all the channels at the default |
| 93 |
volume for replaying AHX songs with 100% stereo seperation (see next section). |
| 94 |
You can set mix gain from 0% (silent) to 200% (twice as loud) to manually get the |
| 95 |
best balance between audio quality and clipping. The "Autogain" button scans through |
| 96 |
the entire module and calculates the highest setting for "Mix Gain" that doesn't |
| 97 |
have any clipping.<br /> |
| 98 |
<br /> |
| 99 |
<h1>5. Mix Gain vs. Stereo Seperation</h1> |
| 100 |
By default HivelyTracker pans each channel to the left or to the right in the same |
| 101 |
order as the Amiga sound chip (IE left, right, right, left). How far they are panned |
| 102 |
depends on the "Stereo Seperation" setting in prefs. With stereo seperation at 100%, |
| 103 |
for a 4 channel module, channels 1&4 only show up in the left channel, and channels |
| 104 |
2&3 only show up in the right, and so each speaker-channel only has two waveforms |
| 105 |
added together. With stereo seperation at 0%, both stereo-channels contain all four |
| 106 |
module channels, and so could need a lower mix gain for the same module.<br /> |
| 107 |
<br /> |
| 108 |
When you load an AHX module into HivelyTracker, the Mix Gain is set to a predefined |
| 109 |
level depending on your "Default stereo seperation" setting: |
| 110 |
<br /> |
| 111 |
<table border="1"> |
| 112 |
<tr><td><b>Default Stereo Seperation</b></td><td><b>Mix Gain Preset</b></td></tr> |
| 113 |
<tr><td>0% (mono)</td><td>73</td></tr> |
| 114 |
<tr><td>25%</td><td>74</td></tr> |
| 115 |
<tr><td>50%</td><td>79</td></tr> |
| 116 |
<tr><td>75%</td><td>86</td></tr> |
| 117 |
<tr><td>100%</td><td>100</td></tr> |
| 118 |
</table> |
| 119 |
<br /> |
| 120 |
HVL modules can have a variable number of channels, and each channel can be panned |
| 121 |
independantly, and so instead of using this kind of preset, the "default stereo |
| 122 |
seperation" value and mix gain value are saved with the module. When you load |
| 123 |
the HVL module in, the "default stereo seperation" value of the module is used |
| 124 |
instead of your own setting, so you hear the song how the author intended. |
| 125 |
<br /> |
| 126 |
<a href="index.html">Back to index</a> |
| 127 |
</body> |
| 128 |
</html> |