Changes
/* Writing */
A sound is recorded by making a measurement of the amplitude of the sound at regular intervals which are defined by the ''sampling rate'' and to a vertical resolution (between the lowest and highest points on the wave) that is called the ''bit-depth''. The act of taking the measurement is often called ''sampling'' and each measurement unit is called a ''sample''. A file which contains samples is often called a waveform, sound sample, audio sample, ''etc.''
The sampling rate defines the rate/frequency at which the measurements are taken. The higher the sampling rate, the faster/more frequently the measurements are taken, and the higher the maximal frequency that can be represented by the signal. Conversely, the lower the sampling rate, the slower the measurements are taken, and the maximal frequency that can be stored is lower. The sample rate is described by the "Hz" unit of measurement. The "Hz" unit of measurement means "per second". Therefore, a sampling rate of 44010 44100 Hz , a.k.a. 44.1 kHz, means 44010 that 44100 measurements are taken each second (in other words, one measurement every 1/44010 44100 th of a second).
If the sampling is too low, then changes in the sound which occur between each measurement will not be measured. Because higher audio frequencies are defined by oscillating more rapidly, this means that lower sampling rates can store only lower frequencies. Therefore, the faster the measurements are taken, the more accurate the recording will be, and thus the higher the quality of sound that can be recorded. Of course, at high sample rates, because there are many more measurements taken, the resulting size of the file (containing the audio data) can be large.
As should be familiar to CPC users with a little technical knowledge, a sample that uses 8-bits for storage can represent 256 distinct amplitude levels, and a sample which uses 16-bits for storage can describe 65536 distinct amplitude levels. The higher the number of bits used by each sample for storage, the larger the range of distinct amplitude levels that can be represented. Therefore, the higher the number of bits used by each sample for storage, the higher the quality of sound that can be recorded. Moreover, the number of bits is directly related to the dynamic range of the resulting signal; that is, how much of a difference there is between the quietest and loudest sounds that it can represent. 16-bit signals provide a nominal 96 dB of dynamic range. All of that sound theory is, of course, irrelevant to the CPC as it only gets 1-bit of information out of the tape signal level.
===What settings should you use?===
All modern sound cards should support 8-bit and 16-bit samples and sample rates of 22050 Hz and 44100 Hz. Some sound cards will support a greater range of recording rates which can be lower and higher than these values. The familiar format of CD audio uses a sampling rate of 44100 Hz and a bit-depth of 16-bits. These values are more than adequate to represent almost all real-world signals for listening by humans - and also, conveniently, are fine for Amstrad tapes, too! In fact, in theory, because the standard Amstrad tape routines have a maximal frequency of 2500 Hz, settings as low as 8000 Hz and 8 bits would probably be fine. However, you will probably want to use higher settings, just in case and/or to keep in line with more common formats such as CD audio, especially if you intend to archive your recordings.
===Illustrations and explanations of digital audio===
[[Image:wave7.gif]]
''Fig 7. An amplitude/time graph showing the sampled waveform. As explained in the note for Figure 4, this is only a visual representation of the digitally stored audio, '''not''' of the signal that would be output by any competent audio card. However, it does illustrate how low sampling rates reduce the bandwidth of frequencies: This waveform was generated at a low sample rate, and therefore the resulting waveform is much more coarse compared to Fig 4. Notice that although the general shape is similar to the original waveform, much of the smoothness is is lost between the time of each measurement. The loss of smoothness also means loss of information: the lower the sample ratingsampling rate, the more information is lost; in other words, the maximal frequencies frequency that the signal can represent is lower. Similarly, lower bit-depths mean that the signal is less accurate, and in extreme cases can generate audible noise, . Therefore, to record a sound, it is best to use relatively high sampling rate and bit-depth; CD audio's 44.1 kHz and 16-bit should be more than adequate for most uses. Due to the way the CPC hardware process the sound signal, 16-bit has zero advantage over 8-bit for CPC cassettes. To sum it up, 44.1kHz and 8-bit is recommended for storage of CPC cassettes.''
Notes:
* A 8-bit signed sample has values between -128 and 127. In this range, -128 represents a low amplitude, and 127 high amplitude, and the amplitudes increase linearly from -128 to 127.
Both methods can represent the same data, just in different ways (techies will be able to compare this to their knowledge of Z80 assembly), so there is no advantage to using either. The original reason for the two methods is due to the original method to playback the sound. Modern sound cards can play audio stored in both ways.
On a side note, the WAV sound container only allows 8-bit unsigned samples, so there is no ambiguity as to how to interpret 8-bit samples.
Note that both (albeit more obvious in the latter) share a feature typical of binary-encoded numbers: there is no exact 'centre' value, because the total number of possible values is even. In the context of audio, this means that, if the signal spanned the entire range, its centre (average) would be slightly off-zero (in this case, below), which is known as a DC offset. However, even if this did occur, it would be negligible and certainly not audible by humans!
The fact there is no 'centre' value is actually a good thing, as the CPC has to convert the sound signal that comes in to a single bit, determining whether the signal is low or high.
== Duplication of cassettes ==
A loader on the computer must therefore be able to identify the actual sound of the data from other sounds that are on the cassette. If it can't do this, then there will be loading errors.
If you are transfering a cassette using samp2cdtCSW2CDT, then you are advised to use an original (i.e. a cassette created directly from a master cassette), or a first generation copy (i.e. a cassette copied from an original).
== Loader ==
1. The CPC464 and CPC464+ have a cassette player built in. To connect a cassette player to the CPC664, CPC6128 or KC Compact then you must use a lead.
2. It is not known exactly how the amplitude of the sound from the cassette corresponds to the final "0" or "1" measurement.
=== Writing ===
If the state of bit 5 is changed at a fixed frequency, then the graph of the state of bit 5 over time will be a square wave. However, the resulting audio written on the cassette will not be a perfect square wave because nature will attempt to convert the waveform into a sine wave.
The exact definition of the loading systems's audio waveform is defined by the loader program.
== Example of a typical loading system ==
;;
;; B = &F5 (I/O address of PPI 8255 input port B)
;; C = previous data read from PPI port B ld d,0 ;; initialise count to 0 .loop inc d ;; increment count in a,(c) ;; read input to PPI 8255 port B xor c ;; exclusive-or with previous data read from PPI 8255 port B and %10000000 ;; isolate bit 7
;; if result is 0, then the state of bit 7 that has
;; been read is the same as the previous state. i.e. bit 7 has not changed state.
;; if result is not 0, then the state of bit 7 has changed.
;; e.g. if bit 7 was previously 1, it is now 0. if bit 7 was previously 0, it is now 1. jr z,loop
;; when execution reaches here we know that bit 7 has changed state and D
;; contains the number of tests.
== Various Audio file formats ==
There are numerous Audio file formats, each of which can store audio, but each has it's its own structures and representation for the data.
The "format" of a file describes the internal structure, order and encoding of the data within the file.
==Links==