This experimental page started off experimenting with the CANVAS for drawing and displaying audio samples. It is possible to do some DSP maths on the samples, and use the CANVAS to visualize the output of functional blocks. It has HowTo and Theory notes to help the page author. It contains notes in the page source. It uses WebAudio for playing the sounds. Audacity can record signals from a phone line with a suitable circuit and cheap sound card. This page can decode the audio samples exported from Audacity to the text sent using the V.21 modems. It can also be tuned to V.21, EDT, BAUDOT, BELL103. Test samples can be generated.
It is easy to make mistakes, so this can be tweeked to suit.
This page uses IIR Goetzel resonators / filters to look for the modem's FSK tones that encode the 1's and 0's. These are decoded by an adjustable 300 baud UART to decode text that Audactity cannot decode.
[samples]--[ notch filter ]--+--[ iir filter ]--[ mark energy ]--+--[ comparitor ]--[ UART ]--[code] \--[ iir filter ]--[ space energy ]--/
Audio samples | --- | optional notch filter mark | -+- | iir filter mark '1' | --- | mark energy ? | --- | comparator | --- | UART | --- | character codes |
---|---|---|---|---|---|---|---|---|---|---|---|---|
\- | iir filter space '0' | --- | space energy ? | --- |
Originally, Samples were copied from Audacity and pasted between two DIV tags and read when the page was opened. Can I decode the encoded data? This is good to get it working. Later the samples are stored in a TextArea. The IIR filters and UART parameters could be adjusted to until the encoded text is decoded. New samples exported by Audacity could be copied and pasted into this text Area. The decoded text could be copied and used to annotate the Audacity captures. Instead of using captured samples, this page generates samples to decode This makes the page smaller. These generated samples could also be played out using WebAudio, based on an example that generated random noise. These audio samples can be played into the modem.
* getSamples() * analyseSamples() uses samplesA[] and the iir filters output and the UART use op1A[] to op4A[] * Graph() plots debug output. A trace can be added like a scope. For the UART, the state can be visualized as a trace. * Use WebAudio to listen to the filtered output in op4A[]. * playing the generated samples into the modem can also be used to test the modem. * The Webaudio examples played the sound, but did not have a panic button to mute the sounds. This needs a re-factor. Note: My mobile is struggling to load this page, but it works on my PC.
The red lines are the IIR output, the blue lines are debug. It is still being tested. Looking for 0x41 , STOP , start , 1,0,0,0, 0,0,1,0, 1
x:
|
|
|
|
|
x scale:
|
Y scale: |
presets: | | |
IIR Goetzel resonators tuned to:- mark:[1,red]: Hz and space:[0,orange]: Hz, resonance - mag: mag must be less than 1 iir smoothing
A Notch Filter to remove MARK frequencies: - designed using http://jaggedplanet.com/iir/iir-explorer.asp
NOTE: V.21 is DUPLEX, one end uses a pair of frequencies, the other end another pair.
V.21 MARK: SPACE: MARK:
Filter designer: http://jaggedplanet.com/iir/iir-explorer.asp
NOTCH ANS 2100HZ
#define NBQ 2 REAL biquada[]={0.9802510163831233,-1.4029516825028896,0.979859571303725,-1.374238052846466}; REAL biquadb[]={0.9999999999999998,-1.4027228552933624,0.9999999999999998,-1.4027228552933624}; REAL gain=1.0203506341124682;
NBQ
REAL biquada[]={
REAL biquadb[]{
GAIN
UART:baudot baud: 50,110,300,75,600,1200
V.21 2)The nominal characteristic frequencies; channel No. 1 (FA = 1180 Hz and Fz = 980 Hz); channel No. 2 (FA = 1850 Hz and Fz= 1650 Hz). BAUDOT 1400,1800 BELL103 - The MARK and SPACE seem to be inverted. https://www.dsprelated.com/showthread/comp.dsp/65894-1.php v.21 bell103 mark space
Decoded:
:maskMSBfound
found
Capture audio using Audacity. Export samples. Copy and paste them into the box below. mono, 8000 samples per second.
NOTE: Andriod UI stalls up if generated samples are loaded into text area. WorkAround: - do not update TextArea.
//On Android the statement below chokes the UI when there are 8000*seconds samples. document.getElementById( "samples" ).value = generatedSamples
This section generates samples to decode to keep the web page smaller.
It can also generate test signals that can be acoustic coupled into a phone call.
Generation of samples to acoustic couple into a phone, should disable full duplex tone generation:
The diagram below usefully describes duplex and half duplex
Some modems can send in both directions at the same time. e.g V.21, V.23, BELL103, others cannot e.g. BAUDOT, and EDT
extra stopBits : random extra number of stop bits between characters: bits repeat : to allow CI repeat_noise : to allow CI
Send - BAUDOT: Use @ for SHIFT_LTRS , and # or SHIFT_FIGS/numbers. Start with "@#@"
This page can generated test signals, so it can do these when needed.
For V.21, the user would typically holdback sending characters until carrier is seen from the other end.
For BAUDOT, carrier is sent for 145ms before the carrier is sent to spin up the detectors. An also for short period after the characters have been sent.
Also filter received characters if the Carrier Detect is not asserted. Some UARTS detect frame errors, ( e.g. PIC16F877 ) I remember the terms Front and Back porch come from Analogue TV sync.
- V.21: The recorded signals may contain V.21(low) used from the "Orignate" end and V.21(high) from the "Answer" end.
It is possible to use these buttons to generate the signals and using the Web Audio, Acoustic couple it into a phone. We can test if the modem on the other end detects and decodes the signals. The modem may need some V.21 mark carrier, before characters are sent. Some UARTS filter out line noise by detecting Frame Errors. ( e.g. microchip PIC16F877 ) The Modem tone detectors need time to resonate.
V.21: without carrier in reverse direction. To Acoustic couple into phone.
This this web page Webpage drives USB modem can be used. Plug phone and modem into the same line. Answer the modem pressing the ATA button. Pick up handset and hold headphones to the phones microphone. You should hear the modem trying to train. Press the "send using V21(low) modem " button and the text should appear on the webpage
The modem does not get signals when the call is answered from the underlying telephony layer.
V.18 "calling tone" CI 0x00,0x41,
The "calling" tone is sent in short bursts, while awaiting an ANS tone.
| |Front and back porch. Generate extra carrier or mark before text for ms and after text for: ms
EDT: ( V.18 annex C - half DUPLEX, 300ms front porch )
BELL103 - The MARK and SPACE seem to be inverted. v.21 bell103 mark space
BAUDOT: Add Shifts: or TypeHere: ( experimental! )
BAUDOT reference | audio to BAUDOTDTMF is used for Dialling.
DTMF: duration(ms): inter Digit pause(ms):
DTMF:
pad:
B.3 Timing The DCE shall detect characters at least 40 ms in length with silent intervals of at least 40 ms. The DCE shall transmit DTMF characters at least 70 ms in length with silent intervals of at least 50 ms.
This page does not decode DTMF see: A DTMF decoder
The string below can be used to encode / decode text sent using DTMF.
// add // Table B.1/V.18 − Line-to-DTE code conversion (DTMF to 7-bit) // ~ is a subsitute for the real code. // var codes = " "+ // pad two spaces as slice "behknqtwz "+ // "adgjmpsvy\b"+ //* "cfilorux.?"+ //# "1234567890"+ //*# "+-=:%(),\r~"+ //** "~~~~~~~~~~"+ //#* "ADGJMPSVY~"+ //##* "BEHKNQTWZ "+ //## "CFILORUX; " //### //-------------- //"1234567890" Hello. GA is sent as ##32#4#4#5#90##*3##*10 or ##3 2 #4 #4 #5 0 ##*3 ##*1 0 with spaces between characters. It has a prefix and a single digit
Audacity was used to record the modem signals on the phone line. Audacity's spectrum and spectrogram can indicate what to look for. But it cannot decode DTMF or text carried by V.21 modems. It can export the samples and these can in pasted into this web page
The picture below shows an incoming call to a modem. You can see the ringing, the 2100Hz ANS tone and the V.21(h) carrier, the V.21(l) carrier and a burst of text. It is also possible to measure the bit rate.
However it cannot decode V.21. So you can use this web page to decode the burst of text, and I have added a notch filter to remove the V.21(h) carrier.
A modem using the ITU V.8 spec, has other intersting bursts of characters to decode. Other pages can decode DTMF and BAUDOT captured using Audacity.
The notch filters used Filter designer used for the notch filers.
Typically the Modem takes a serial signal, using voltages encoding the "1"'s and "0" using MARK and SPACE and uses FSK frequency Shift keying.
[computer program]--[UART]--[modem]--[telephone system]--[modem]--[UART]--[Computer Program]
Very useful diagrams from https://docs.rs-online.com/a02c/0900766b800af005.pdf - data sheet for V21 modem.
It is quite simple to analyse the samples exported from Audacity using JavaScript. The samples are passed into IIR filters to detect the V.21 FSK signals. Logic is used to find the "1"'s and "0"'s. These are fed into the UART.
Countdown State machines are used for the FSK logic, UART and DEBUG.The UART emits characters. Parity may need to be stripped, and the decoded text can be displayed.
input --- filters --- comparator --- UART 8000 samples per seconds 300 baud = 26.667 UARTS normally use a x16 clock 300 x 16 is 4800Hz clock START - SPACE "0" - V.28 more than 3V - PIC TX low - PIC RX low - STOP - MARK "1" - V.28 less than -3V - PIC TX High - PIC TX High - UART - for each time slice increment t START,bit0,1,2,3,4,5,6,7,STOP use a count down state machine, decrement each sample. 8000 samples per second. 0 - stop 1 START - SPACE - "0" - RS232 or V.28 more than 3V - Microcontroller TX low STOP - MARK - "1" - RS232 or V.28 less than -3V - Microcontroller TX High Note: The MAX232 chips invert the voltages. Microcontrollers TX and RX are not. Serial:- -----_____x====x====x====x====x====x====x====x====x----x------------------------- START 0 1 2 3 4 5 6 7 stop til next start bit. Drawn using wavedrom:-Web Audio API: AudioBuffer
Theory and notes - Overview
This page uses IIR Goetzel resonators / filters to look for the modem's FSK tones that encode the 1's and 0's. These are decoded by an adjustable 300 baud UART to decode text that Audactity cannot decode.
[samples]--[ notch filter ]--+--[ iir filter ]--[ mark energy ]--+--[ comparitor ]--[ UART ]--[code] \--[ iir filter ]--[ space energy ]--/Theory and notes
These modems use AFSK modulation at 300 baud and 300 bps, at the following frequencies (in Hertz): Bell 103 Originate 1170 = Carrier 1070 = Space (Carrier - 100Hz) 1270 = Mark (Carrier + 100Hz) Answer 2125 = Carrier 2025 = Space (Carrier - 100Hz) 2225 = Mark (Carrier + 100Hz) ITU-T v.21 Originate 1080 = Carrier 1180 = Space (Carrier + 100Hz) 980 = Mark (Carrier - 100Hz) Answer 1750 = Carrier 1850 = Space (Carrier + 100Hz) 1650 = Mark (Carrier - 100Hz) START - SPACE - "0" - RS232 or V.28 more than 3V - Microcontroller TX low STOP - MARK - "1" - RS232 or V.28 less than -3V - Microcontroller TX High Note: The MAX232 chips invert the voltages. Microcontrollers TX and RX are not. Serial:- -----_____x====x====x====x====x====x====x====x====x----x------------------------- START 0 1 2 3 4 5 6 7 stop til next start bit. Drawn using wavedrom:-BAUDOT: - 5 bit * carrier (for 150ms) + 0 + 11000 + 1 (for 40ms) * * 0 - 1800Hz - SPACE * 1 - 1400Hz - MARK * START 0 * STOP 1 * * BAUD rates: 45.45, 47.6, 50 * NOTE:- Mechanical Teletypes used 45.45 BAUD, electronic Teletypes used 50 Baud * ITU V.23 2 Modulation rates and characteristic frequencies for the forward data-transmission channel F0 FZ FA symbol 1, symbol 0, mark space Mode 1: up to 600 bauds 1500 Hz 1300 Hz 1700 Hz Mode 2: up to 1200 bauds 1700 Hz 1300 Hz 2100 Hz 4 Modulation rate and characteristic frequencies for the backward channel The modulation rate and characteristic frequencies for the backward channel are as follows: FZ FA mark space Modulation rate up to 75 bauds 390 Hz 450 Hz In the absence of any signal on the backward channel interface, the condition Z signal is to be transmitted
BAUDOT Spectrum from Audacity and decode using this page
![]()
Text converted to ITU V.18 Annex B and captured using AUDACITY