{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "collapsed_sections": [
        "kEg9hg2Di2sW",
        "EHQTLC_FinNH",
        "ng-QBzmEtxWs",
        "qb_X_FHTiFH9",
        "V9WJC1e5jZ4f",
        "Yb3OsPolPBXM",
        "nW72SVI1SKbb",
        "xM1683-1Vy5x",
        "kv1LwdF1WjHK",
        "KPzVMFSXYgRB"
      ]
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "\n",
        "**Name:**\n",
        "\n",
        "**Date:**\n",
        "\n",
        "**Description of activity:**"
      ],
      "metadata": {
        "id": "WBWRgm19obVt"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Mount Google Drive\n"
      ],
      "metadata": {
        "id": "ng-QBzmEtxWs"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from google.colab import drive\n",
        "drive.mount('/drive')\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "_3laEwn6werC",
        "outputId": "5c5d6c7d-ad32-49dc-9390-183a01ab1c8f"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mounted at /drive\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Import Libraries"
      ],
      "metadata": {
        "id": "0XSi7YkicN35"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from IPython.display import Audio, display\n",
        "from scipy.io.wavfile import read, write\n",
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n"
      ],
      "metadata": {
        "id": "u38vjrZHcCYG"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Reverse a sound\n",
        "\n",
        "In this set of exercises we will write two functions working with sounds in reverse.\n",
        " \n",
        "\n",
        "1.   Write a function to reverse a sound.  (This is the function in the [Sound Manipulations](https://www.cs.kzoo.edu/cs103/Readings/SoundManipulations.pdf) reading.)\n",
        "2.   Write a new function, <code>mirrorHalf</code> that mirrors the first half of the sound onto the second half.  The resulting sound should have the first half of the original sound, followed by the reverse of the first half of the sound.\n",
        "\n",
        "Test both of these functions below by reading in a sound file and then calling each of the new functions with the data from your sound file.  You should display an Audio control for each of the new sounds as well as the original sound, and you should plot all three sound arrays (in separate plots).\n"
      ],
      "metadata": {
        "id": "RQzbMo8wcRbL"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Define your functions here\n",
        "\n"
      ],
      "metadata": {
        "id": "oaKaAYWUuTp_"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Test your functions here.\n",
        "\n"
      ],
      "metadata": {
        "id": "tPy5nT7_1jlh"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [],
      "metadata": {
        "id": "OZaBY15kXJ4g"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Changing a Section\n",
        "**(OPTIONAL, if you have time)**\n",
        "Write a new function that changes the volume of a just a section of a sound.  The function should take an array of sound data, a starting index, an ending index, and a multiplication factor as parameters.  It should create a new sound array the same length as the original.  It should then loop through the samples in the new sound.  For each sample, if it is between the starting index and the ending index, it should be assigned to be the value of the correspoonding sample of the original sound times the multipication factor.  Otherwise it should assigned to be the same value as the corresponding sample in the original sound.  At the end of the function, the new sound is returned.\n",
        "\n",
        "Test your new function."
      ],
      "metadata": {
        "id": "63cAlSK6aF3q"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# (OPTIONAL) Define your new function here\n",
        "\n"
      ],
      "metadata": {
        "id": "GMmMkUWVaVUG"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Test your new function here\n",
        "\n"
      ],
      "metadata": {
        "id": "JR4ul4kMabzZ"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Changing the pitch\n",
        "\n",
        "In this exercise, you will define two functions to change the pitch of a sound. These functions will be similar to the <code>quarter</code> and <code>quadruple</code> functions that we used to make images smaller and larger.\n",
        "1.  Define a new function, <code>halfFrequency</code>, that takes an array of sound data as its parameter.  This function first creates a new array, twice as long as the original sound, of all zeros to be the data for the new sound.  It then loops through the new sound data array, getting sample values from the original data array to assign to samples in the new array.  The loop is set up to go through all samples in the new sound.  Since there are twice as many samples in this new sound as there are in the original, you will need to divide the index in half in order to access the value of the corresponding sample in the original sound. \n",
        "2.  Define a new function, <code>doubleFrequency</code>, that takes an array of sound data as its parameter.  It should create a new array, half the length of the original sound.  It should then loop through the samples in the new array, getting sample values from the original array to assign to samples in the new array.  Since there are only half as many samples in the new sound, you will need to multiply the index by 2 in order to access the value of the corresponding sample in the original sound.\n",
        "\n",
        "Then test these functions below by reading in a sound file and calling these functions.  You should display an Audio control as well as figures to play the sounds and compare the original sound with the new sounds with modified pitches."
      ],
      "metadata": {
        "id": "qb_X_FHTiFH9"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Define your functions here"
      ],
      "metadata": {
        "id": "6t4b1xQCXUZy"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Test your functions here\n",
        "\n",
        "\n",
        "\n"
      ],
      "metadata": {
        "id": "yKQXPVmnfNos"
      },
      "execution_count": 1,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Saving and Submitting\n",
        "\n",
        "Once you have created results that you are pleased with, skim through your notebook and make sure everything looks the way you expect.  Make sure that your Code cells have been run and that your results for the sound plots are showing.  If it all looks good, save this notebook as a pdf.  (Go to File -> Print -> Save as PDF)\n",
        "\n",
        "Submit your PDF file on Kit."
      ],
      "metadata": {
        "id": "KjGmnShmZ3l7"
      }
    }
  ]
}