{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lab1 - Time Domain Lab\n", "\n", "### Written by Miki Lustig and Frank Ong 2014" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This week we will interact with physical time-domain signals. The first task will involve generating and recording sounds on your computer. \n", "In the second we will use the computer sound system as a simple sonar. The last task will involve sampling the Automatic Dependent Survaillance Broadcast (ADS-B) frequency band (around 1090MHz) using the rtl-sdr and looking at packets sent from airplanes in the bay area. " ] }, { "cell_type": "code", "collapsed": false, "input": [ "# Import functions and libraries\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import pyaudio\n", "from numpy import pi\n", "from numpy import sin\n", "from numpy import zeros\n", "from numpy import r_\n", "from scipy import signal\n", "\n", "# Task II\n", "import threading,time\n", "\n", "# Task IV\n", "from rtlsdr import RtlSdr\n", "from numpy import mean\n", "from numpy import power\n", "from numpy.fft import fft\n", "from numpy.fft import fftshift\n", "from numpy.fft import ifft\n", "from numpy.fft import ifftshift\n", "%matplotlib inline" ], "language": "python", "metadata": {}, "outputs": [] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Part 1: Chirping" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For this assignment you will have to use iPython, and a laptop equipped with a speaker and a microphone. When playing a sound and recording on the computer speaker, the signal goes through several systems. In particular it goes through the response of the speaker, the room we are in and the response of the microphone recording system.\n", "\n", "A chirp is a a signal in which the frequency increases linearly with time. In this assignment we will generate a chirp signal and use it to measure the amplitude of the frequency response of our speaker-room-microphone system.\n", "\n", "A simultaneous frequency is defined as the derivative of the phase of a signal, $f = \\frac{d\\phi (t)}{2\\pi dt} $. For example, the simultanious frequency of $cos(\\phi(t))=cos(2\\pi f_0 t)$ is $f = \\frac{d\\phi (t)}{2\\pi dt} = f_0$. \n", "\n", "\n", "For a linear chirp, the frequency changes linearly over time. The simultaneous frequency is therefore defined as \n", "\n", "