{
  "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": "fba9614e-2feb-4ba9-a6f5-0e9ef155bd99"
      },
      "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": [
        "# Splicing Sounds\n",
        "\n",
        "Splicing audio involves cutting up and rearranging your sound clips to create a unique piece of music or sound design. It's one of the most popular methods used by musicians and producers when creating an original soundtrack or remixing existing songs.\n",
        "Historically, splicing was a process where audio tape or film could be edited by literally cutting it apart and reassembling the pieces. One simply listens to the tape (or looks at the film), finds the point where an edit is desired and uses a razor to cut it. Generally a fixture known as a splicing block (similar to a miter box in woodworking) was used to help make precise and straight cuts. A product known as splicing tape was used to reassemble tapes that had been sliced. It's simply a small piece of tape that sticks to the back side of the audio tape to hold it together. A skilled editor could splice and reassemble audio tape very quickly with almost no sonic side effects (of course this depended somewhat on the recording and where edits needed to occur). \n",
        "\n",
        "To splice our digital sounds, we will need to be able to cut our sounds apart, and then be able to paste them together.  In this activity, we will write two functions to do this: <code>cropSound</code>, and <code>pasteSounds</code>.\n",
        "\n",
        "**Cropping a Sound**\n",
        "\n",
        "Write a function called <code>cropSound</code> which crops a section of a sound and returns just the cropped piece. Your function should take as parameters the sound data array, the index to start cropping, and the number of samples to include in the cropped sound.\n",
        "<br>Design Questions (to think about): How big do we want the resulting sound to be? Does it depend on how long the original sound is? How do we know how long the original sound is?\n",
        "\n",
        "**Pasting sounds together**\n",
        "\n",
        "Pasting sounds together is like piecing them together, with the end of one sound pasted, or taped, to the beginning of the other sound.\n",
        " \n",
        "Write a function called <code>pasteSounds</code> which takes two sound data arrays as parameters. It should create a new data array large enough to hold both sound arrays.  It then needs to loop through the first sound data arrays, copying sample values to the new array.  Next it need to loop through the second sound data array, copying sample values to the new array, but not at the beginning of the new array.  (Why not?). The indices of the new array should be shifted to start at the end of the first sound's values.  The new array will get returned at the end of the function.\n",
        "\n",
        "**Testing**\n",
        "\n",
        "Test the <code>cropSound</code> function by reading in a sound file and then cropping out part of that sound. You should display an Audio control for the new, shorter, sound as well as the original sound, and you should plot both sound arrays.\n",
        "\n",
        "Test the <code>pasteSounds</code> function by passing the data from the sound file you used to test the <code>cropSound</code> function and the data from the cropped piece of that sound into this function as parameters.  Display an Audio control and plot of this result.\n",
        "\n",
        "**(OPTIONAL, if you have time) Experiment**\n",
        "\n",
        "Experiment with cropping and pasting other sounds.  **One thing to note:**  The sounds being pasted together must have the same sample rate!"
      ],
      "metadata": {
        "id": "RQzbMo8wcRbL"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Define the functions here\n",
        "  \n",
        "\n",
        "\n"
      ],
      "metadata": {
        "id": "oaKaAYWUuTp_"
      },
      "execution_count": 1,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Test your functions here.\n",
        "\n"
      ],
      "metadata": {
        "id": "tPy5nT7_1jlh"
      },
      "execution_count": 2,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Forward and Reverse\n",
        "\n",
        "Write a new function, <code>forwardAndReverse</code>, that returns a new sound array. The first half of this sound array is an original sound. The second half of this sound is the original sound in reverse. The function should take a sound data as a parameter, then create a new, empty data array, with the appropriate length. It will need to call on the <code>reverse</code> function (from a previous activity) to get the reversed version of the original sound, and then paste the two sounds together."
      ],
      "metadata": {
        "id": "qZc1NF-vqfAH"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Write and test forward and reverse here\n"
      ],
      "metadata": {
        "id": "TUu5edRp3XaK"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "# (OPTIONAL, if you have time) Cropping a Sound by Time\n",
        "\n",
        "Write a new function, <code>cropSoundByTime</code> that takes four parameters: the sound, the number of seconds into the sound to start cropping, the number of seconds to include in the resulting sound, and the sample rate. The function computes which sample index to start the cropping and how many sample are needed and then passes the appropriate parameters to the <code>cropSound</code> function. It returns the result that gets passed back from the <code>cropSound</code> function.\n",
        "\n",
        "Test your new function."
      ],
      "metadata": {
        "id": "63cAlSK6aF3q"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Define cropSoundByTime here\n",
        "\n"
      ],
      "metadata": {
        "id": "GMmMkUWVaVUG"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Test your new function here\n"
      ],
      "metadata": {
        "id": "JR4ul4kMabzZ"
      },
      "execution_count": 3,
      "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"
      }
    }
  ]
}