{ "metadata": { "name": "", "signature": "sha256:f50ddd5f96951e3a4bd117adfc40133b15c129b8f04d9b391396a08431c3aae2" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 8: Speech Coding and Channel Coding" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 8.1, Page 227" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math\n", "\n", "#Variable declaration\n", "Pdiff=-3.; #in dB\n", "AMR1=12.2; #in kbps\n", "AMR2=7.95; #in kbps\n", "AMR3=4.75; #in kbps\n", "\n", "#Calculations\n", "#CG(dB)=10math.log{(DPDCH(kbps)+DPCCH)/(DPDCH(AMR bit rate (kbps))+ DPCCH)}\n", "CG1=10*math.log10((AMR1+AMR1*10**(Pdiff/10))/(AMR2+AMR1*10**(Pdiff/10)));\n", "CG2=10*math.log10((AMR1+AMR1*10**(Pdiff/10))/(AMR3+AMR1*10**(Pdiff/10)));\n", "\n", "#Results\n", "print 'By reducing the AMR bit rate from 12.2 to 7.95 kbps coverage gain becomes %.2f dB'%CG1;\n", "print 'By reducing the AMR bit rate from 7.95 to 4.75 kbps coverage gain becomes %.2f dB'%CG2;" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "By reducing the AMR bit rate from 12.2 to 7.95 kbps coverage gain becomes 1.15 dB\n", "By reducing the AMR bit rate from 7.95 to 4.75 kbps coverage gain becomes 2.27 dB\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 8.2, Page 239" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import numpy as np\n", "import sympy\n", "from sympy import symbols\n", "\n", "#Variable declaration\n", "K=4; #constraint length\n", "r=1./2; #code rate(n/k)\n", "x=symbols('x');#Defining x as a ploynomial variable\n", "G1=1+x**2+x**3;\n", "G2=1+x+x**2+x**3;\n", "ins=np.array([1, 0, 1, 1, 1]);#input(first bit first)\n", "\n", "#Calculations&Results\n", "#with reference to Fig 8.9 on page no 239\n", "g1=np.array([1, 0, 1, 1]); #converting from G1 polynomial to bit form\n", "g2=[1, 1, 1, 1];##converting from G2 polynomial to bit form\n", "x1=np.convolve(g1,ins)\n", "x2=np.convolve(g2,ins)\n", "V1=x1%2;\n", "V2=x2%2;\n", "print \"Multiplexing the V1 and V2 to get required output sequence as\"\n", "a=5;\n", "for i in range(0,6):\n", " print '%d%d'%(V2[a],V1[a]);\n", " a=a-1;\n", " " ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Multiplexing the V1 and V2 to get required output sequence as\n", "10\n", "10\n", "10\n", "00\n", "10\n", "11\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example 8.3, Page 246" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import numpy as np\n", "\n", "#Variable declaration\n", "BitStream=np.array([0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1]);#Last bit to first bit\n", "\n", "# Interleaver\n", "Input1=[[1, 0, 0, 0],[1,0,0,0],[1,1,1,0],[0,0,0,0]] #Writing data row wise\n", "\n", "#Calculations&Results\n", "print \"GIven Bit stream is\",BitStream\n", "print \"Input to interleaver is\",Input1\n", "\n", "Output1=np.array([0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1]); # Reading data column wise\n", "print \"Output of interleaver is\",Output1\n", "#De-interleaver\n", "Input2=[[1, 1, 1, 0],[0,0,1,0],[0,0,1,0],[0,0,0,0]] #Writing o/p data row wise\n", " # Let From 6th to 9th bits have Burst Error \n", "print \"Input to de-interleaver is\",Input2\n", " #Output of deinterleaver\n", " \n", "Output2= [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1]; \n", "print \"Output of de-interleaver is\",Output2\n", "print \"Bits with Burst error were from 6th to 9th. But in output of de-interleaver, they relocated to positions 3rd, 6th, 10th and 14th.\";" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "GIven Bit stream is [0 0 0 0 0 1 1 1 0 0 0 1 0 0 0 1]\n", "Input to interleaver is [[1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 0], [0, 0, 0, 0]]\n", "Output of interleaver is [0 0 0 0 0 1 0 0 0 1 0 0 0 1 1 1]\n", "Input to de-interleaver is [[1, 1, 1, 0], [0, 0, 1, 0], [0, 0, 1, 0], [0, 0, 0, 0]]\n", "Output of de-interleaver is [0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1]\n", "Bits with Burst error were from 6th to 9th. But in output of de-interleaver, they relocated to positions 3rd, 6th, 10th and 14th.\n" ] } ], "prompt_number": 3 } ], "metadata": {} } ] }